Skip to content

Commit

Permalink
fix: run extra in subshell so that the environment is not messed up (#44
Browse files Browse the repository at this point in the history
)
  • Loading branch information
blaggacao committed Jul 30, 2022
1 parent 21272c3 commit 608abdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/hooks/copy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ let
inherit (hookConfig) output extra;
in
''
extra_hook() (
true
${extra}
)
# Check if the file exists
if [[ -f ${output} ]]; then
# Check if we need to update the local copy
Expand All @@ -12,7 +16,7 @@ in
install -m 644 ${configFile} ${output}
# Run extra shell hook
${extra}
extra_hook
else
log "${output} copy is up to date"
fi
Expand All @@ -23,6 +27,6 @@ in
log "${output} copy created"
# Run extra shell hook
${extra}
extra_hook
fi
''
6 changes: 5 additions & 1 deletion lib/hooks/link.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ let
gitignore-sentinel = "ignore-linked-files";
in
''
extra_hook() (
true
${extra}
)
# Check if the link is pointing to the existing derivation result
if readlink ${output} >/dev/null \
&& [[ $(readlink ${output}) == ${configFile} ]]; then
Expand All @@ -22,7 +26,7 @@ in
ln -s ${configFile} ${output}
# Run extra shell hook
${extra}
extra_hook
else
# this was an existing file
error "refusing to overwrite ${output}"
Expand Down

0 comments on commit 608abdd

Please sign in to comment.