diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-06-02 21:46:10 +0200 |
---|---|---|
committer | Silas Schöffel <sils@sils.li> | 2024-06-05 18:45:40 +0200 |
commit | 2adfa79ef821cf18f3fb3dbf8f8476c9a1eea539 (patch) | |
tree | e7eb2b07a7697ee7e60fabd7661c1cd27139e044 /system/services/nix-sync | |
parent | fix(nix-sync): Add code-path to create a repo's path, if absent (diff) | |
download | nixos-server-2adfa79ef821cf18f3fb3dbf8f8476c9a1eea539.tar.gz nixos-server-2adfa79ef821cf18f3fb3dbf8f8476c9a1eea539.zip |
fix(nix-sync): Ensure that the `target` for `ln` never ends with a `/`
Otherwise, `ln` tries to create the symlink _in_ the target directory.
Diffstat (limited to 'system/services/nix-sync')
-rw-r--r-- | system/services/nix-sync/default.nix | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/system/services/nix-sync/default.nix b/system/services/nix-sync/default.nix index b4a9803..8de5e3c 100644 --- a/system/services/nix-sync/default.nix +++ b/system/services/nix-sync/default.nix @@ -34,6 +34,12 @@ if lib.strings.hasPrefix "/" repo.path then "" else "/"; + /* + * `ln` tries to create a symlink in the directory, if the target ends with a '/', + * thus remove it. + */ + repoPath = lib.strings.removeSuffix "/" repo.path; + repoCachePath = cfg.cachePath + optionalPathSeparator + repo.path; execStartScript = pkgs.writeScript "nix-sync-exec" '' #! /usr/bin/env dash @@ -52,7 +58,7 @@ [ "$(wc -l < "$out_paths")" -gt 1 ] && (echo "To many out-paths"; exit 1) out_path="$(cat "$out_paths")"; rm ${esa repo.path}; - ln -s "$out_path" ${esa repo.path}; + ln -s "$out_path" ${esa repoPath}; rm "$out_paths"; fi ''; @@ -67,7 +73,7 @@ nix build ${esa repoCachePath} --print-out-paths --experimental-features 'nix-command flakes' > "$out_paths"; [ "$(wc -l < "$out_paths")" -gt 1 ] && (echo "To many out-paths"; exit 1) out_path="$(cat "$out_paths")"; - ln -s "$out_path" ${esa repo.path}; + ln -s "$out_path" ${esa repoPath}; rm "$out_paths"; fi @@ -88,7 +94,7 @@ fi [ -e ${esa repo.path} ] && rm ${esa repo.path}; - ln -s "$out_path" ${esa repo.path}; + ln -s "$out_path" ${esa repoPath}; rm "$out_paths"; fi ''; |