Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run extra in subshell so that the environment is not messed up #44

Merged
merged 1 commit into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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