ctucx.git: nixfiles

ctucx' nixfiles

commit e352e0e8842ac17c731877c5faa2b80bf77073c4
parent 75ddcb86746d95c80dd553c8644b561ddc13fed4
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 16 Jun 2022 12:59:04 +0200

fix for nixos-{deploy,rebuild} scripts on nix 2.8
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/nix/sources-dir.nix b/nix/sources-dir.nix
@@ -9,6 +9,7 @@ in
     lib.concatStringsSep "\n" ([
       "mkdir $out"
     ]
-      ++ lib.mapAttrsToList (name: source: "ln -s ${source.outPath} $out/${name}") sources
+#      ++ lib.mapAttrsToList (name: source: "ln -s ${source.outPath} $out/${name}") sources
+      ++ lib.mapAttrsToList (name: source: "cp -r --reflink=auto ${source.outPath} $out/${name}") sources
     )
   )
diff --git a/nixos-deploy b/nixos-deploy
@@ -1,8 +1,8 @@
  #!/usr/bin/env bash
 set -eo pipefail
 
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
+#tmp=$(mktemp -d)
+#trap 'rm -rf "$tmp"' EXIT
 
 cd "$(dirname "$0")"
 

@@ -20,12 +20,12 @@ fi
 echo "deploying $machine to $target"
 sleep 1
 
-cp --no-preserve=mode -r $(nix-build nix/sources-dir.nix --no-out-link) $tmp/sources
+#cp --no-preserve=mode -r $(nix-build nix/sources-dir.nix --no-out-link) $tmp/sources
 
 set -x
 system_drv=$(
   nix-instantiate "<nixpkgs/nixos>" -A config.system.build.toplevel \
-    -I "$tmp/sources" \
+    -I "$(nix-build nix/sources-dir.nix --no-out-link)" \
     -I "nixos-config=machines/$machine/configuration.nix"
 )
 nix-copy-closure --to $target $system_drv
diff --git a/nixos-rebuild b/nixos-rebuild
@@ -1,8 +1,8 @@
 #!/usr/bin/env sh
 
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
+#tmp=$(mktemp -d)
+#trap 'rm -rf "$tmp"' EXIT
 
-cp --no-preserve=mode -r $(nix-build $(temp=$( realpath "$0"  ) && dirname "$temp")/nix/sources-dir.nix --no-out-link) $tmp/sources
+#cp --no-preserve=mode -r $(nix-build $(temp=$( realpath "$0"  ) && dirname "$temp")/nix/sources-dir.nix --no-out-link) $tmp/sources
 
-nixos-rebuild -I "$tmp/sources" "$@"
+nixos-rebuild -I "$(nix-build $(temp=$( realpath "$0"  ) && dirname "$temp")/nix/sources-dir.nix --no-out-link)" "$@"