From 4321b00c52ec3259d2413913c6f9a8d8d5db1363 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 22 Oct 2023 22:35:36 +0200 Subject: [PATCH] pkgs/nixfiles: nixfiles-auto-install add entry for new host --- flake.nix | 1 + pkgs/nixfiles/nixfiles-auto-install.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/flake.nix b/flake.nix index 91817dc..388cc00 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,7 @@ storage-2 = { name = "storage-2"; }; web-2 = { name = "web-2"; }; zinc = { name = "zinc"; }; + # nixfiles-auto-install: add new host above _iso = { name = "_iso"; }; }; diff --git a/pkgs/nixfiles/nixfiles-auto-install.sh b/pkgs/nixfiles/nixfiles-auto-install.sh index 9f015cc..3d6ad50 100644 --- a/pkgs/nixfiles/nixfiles-auto-install.sh +++ b/pkgs/nixfiles/nixfiles-auto-install.sh @@ -105,6 +105,10 @@ nixfiles-generate-config --root /mnt --hostname "${hostname}" sed -i "s~# boot\.loader\.grub\.device = \"/dev/sda\";~boot\.loader\.grub\.device = \"${device}\";~g" "/mnt/etc/nixos/hosts/${hostname}/configuration.nix" +if ! grep -w "${hostname}" <(nix eval "/mnt/etc/nixos#clerie.hosts" --apply 'hosts: builtins.concatStringsSep "\n" (builtins.attrNames hosts)' --raw 2> /dev/null) > /dev/null; then + sed -i "s/\(\s*\)# nixfiles-auto-install: add new host above/\1${hostname} = { name = \"${hostname}\"};\n&/g" /mnt/etc/nixos/flake.nix +fi + echo "[I] Install NixOS" NIX_CONFIG=$(printf "extra-experimental-features = flakes nix-command\nextra-substituters = https://nix-cache.clerie.de\nextra-trusted-public-keys = nix-cache.clerie.de:bAt1GJTS9BOTcXFWj3nURrSlcjqikCev9yDvqArMP5g=\n")