Skip to content

Commit

Permalink
source: Don't dereference links when linking
Browse files Browse the repository at this point in the history
This ensures overridden symlinks to directories are not attempted to be
linked as a subdir by `ln`.

e.g. with `build/core` already a symlink to something, the following
would not work:

```
   $ mkdir -p build
   $ ln -sf --relative build/make/core build/core
ln: failed to create symbolic link 'build/core/core': Permission denied
```

Observe how the destination is `build/core`, but the link attempted to
be created is `build/core/core`.

From the manpage:

> ```
>     --no-dereference treat LINK_NAME as a normal file if it is a
>                      symbolic link to a directory
> ```
  • Loading branch information
samueldr committed Dec 4, 2021
1 parent d9f9781 commit 7a21c7f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/source.nix
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ let
'') config.copyfiles)
+ (lib.concatMapStringsSep "\n" (c: ''
mkdir -p $(dirname ${c.dest})
ln -sf --relative ${config.relpath}/${c.src} ${c.dest}
ln --no-dereference -sf --relative ${config.relpath}/${c.src} ${c.dest}
'') config.linkfiles);
};
});
Expand Down

0 comments on commit 7a21c7f

Please sign in to comment.