Skip to content

Commit a7664a6

Browse files
committedDec 20, 2017
make-disk-image.nix: Really fix write permissions in the store
I think the current one applies the -exec only to those that match '-type d'. Let's switch it to something that humans can understand... (cherry picked from commit 758b4c1) (Yes it should use 'find -print0 | xargs -0' but I'm really afraid of screwing up again in the same way. Nix doesn't allow spaces and/or newlines in store paths anyway and it has -maxdepth 1 -mindepth 1 so it won't fail in practice. If someone can provide a *tested* that doesn't suffer from the same problems, feel free to improve.)
1 parent 22c7923 commit a7664a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎nixos/lib/make-disk-image.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let
125125
fakeroot nixos-prepare-root $root ${channelSources} ${config.system.build.toplevel} closure
126126
127127
# fakeroot seems to always give the owner write permissions, which we do not want
128-
find $root/nix/store -mindepth 1 -maxdepth 1 -type f -o -type d -exec chmod -R a-w '{}' \;
128+
find $root/nix/store -mindepth 1 -maxdepth 1 -type f -o -type d | xargs chmod -R a-w
129129
130130
echo "copying staging root to image..."
131131
cptofs ${pkgs.lib.optionalString partitioned "-P 1"} -t ${fsType} -i $diskImage $root/* /

6 commit comments

Comments
 (6)

copumpkin commented on Dec 20, 2017

@copumpkin
Member

I don't understand how this differs!

dezgeg commented on Dec 20, 2017

@dezgeg
ContributorAuthor

I don't understand either.

dezgeg commented on Dec 20, 2017

@dezgeg
ContributorAuthor
+ mkdir /tmp/destdir
+ mkdir /tmp/destdir/dir
+ touch /tmp/destdir/file
+ find /tmp/destdir/ -type f -o -type d -exec echo '{}' ';'
/tmp/destdir/
/tmp/destdir/dir
+ find /tmp/destdir/ '(' -type f -o -type d ')' -exec echo '{}' ';'
/tmp/destdir/
/tmp/destdir/file
/tmp/destdir/dir

copumpkin commented on Dec 20, 2017

@copumpkin
Member

So the exec is somehow treated as part of the predicate?? Ugh 😄

dezgeg commented on Dec 20, 2017

@dezgeg
ContributorAuthor

Yeah. I suppose it's a "feature" so that one can do uber complex things like find -type f -exec command-if-file '{}' \; -o -type d -exec command-if-directory '{}' \; all in a single find command...

copumpkin commented on Dec 20, 2017

@copumpkin
Member

Makes sense I guess 😄

Please sign in to comment.