From 4b439fd3e73abe7c7d63d3da5ec92e00f2704aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Schwarz=C3=A4ugl?= Date: Sat, 5 Jul 2025 03:49:26 +0200 Subject: [PATCH] fix: adapt local installer script --- SwarselSystems.org | 55 ++++++++-------------------- files/scripts/swarsel-install.sh | 33 +++-------------- hosts/nixos/chaostheatre/default.nix | 15 ++------ hosts/nixos/toto/default.nix | 2 +- 4 files changed, 27 insertions(+), 78 deletions(-) diff --git a/SwarselSystems.org b/SwarselSystems.org index c1cd6fd..fbdba59 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -2859,7 +2859,7 @@ This is a slim setup for developing base configuration. I do not track the hardw swapSize = "2G"; # rootDisk = "/dev/nvme0n1"; rootDisk = "/dev/vda"; - profiles.btrfs = lib.mkIf minimal true; + profiles.btrfs = true; # rootDisk = "/dev/vda"; } sharedOptions; @@ -3253,7 +3253,7 @@ I also set the =WLR_RENDERER_ALLOW_SOFTWARE=1= to allow this configuration to ru :END: #+begin_src nix-ts :tangle hosts/nixos/chaostheatre/default.nix - { self, inputs, config, pkgs, lib, ... }: + { self, config, pkgs, lib, minimal, ... }: let mainUser = "demo"; sharedOptions = { @@ -3262,7 +3262,8 @@ I also set the =WLR_RENDERER_ALLOW_SOFTWARE=1= to allow this configuration to ru isLinux = true; isPublic = true; profiles = { - chaostheatre = true; + chaostheatre = lib.mkIf (!minimal) true; + minimal = lib.mkIf minimal true; }; }; in @@ -3274,15 +3275,6 @@ I also set the =WLR_RENDERER_ALLOW_SOFTWARE=1= to allow this configuration to ru { _module.args.diskDevice = config.swarselsystems.rootDisk; } - "${self}/hosts/nixos/chaostheatre/options.nix" - inputs.home-manager.nixosModules.home-manager - { - home-manager.users."${mainUser}".imports = [ - "${self}/modules/home/common/settings.nix" - "${self}/hosts/nixos/chaostheatre/options-home.nix" - "${self}/modules/home/common/sharedsetup.nix" - ]; - } ]; environment.variables = { @@ -3312,6 +3304,7 @@ I also set the =WLR_RENDERER_ALLOW_SOFTWARE=1= to allow this configuration to ru isSwap = true; swapSize = "4G"; rootDisk = "/dev/vda"; + profiles.btrfs = true; } sharedOptions; @@ -15042,34 +15035,8 @@ Autoformatting always puts the =EOF= with indentation, which makes shfmt check f if [[ $local_keys != *"${pub_arr[1]}"* ]]; then yellow "The ssh key for this configuration is not available." green "Adjusting flake.nix so that the configuration is buildable ..." - sed -i '/nix-secrets = {/,/^[[:space:]]*};/d' flake.nix sed -i '/vbc-nix = {/,/^[[:space:]]*};/d' flake.nix sed -i '/[[:space:]]*\/\/ (inputs.vbc-nix.overlays.default final prev)/d' overlays/default.nix - rm modules/home/common/env.nix - rm modules/home/common/gammastep.nix - rm modules/home/common/git.nix - rm modules/home/common/mail.nix - rm modules/home/common/yubikey.nix - rm modules/nixos/server/restic.nix - rm hosts/nixos/sync/default.nix - rm -rf modules/nixos/server - rm -rf modules/home/server - cat > hosts/nixos/chaostheatre/options-home.nix << EOF - { self, lib, ... }: - { - options = { - swarselsystems = { - modules = { - yubikey = lib.mkEnableOption "dummy option for chaostheatre"; - env = lib.mkEnableOption "dummy option for chaostheatre"; - git = lib.mkEnableOption "dummy option for chaostheatre"; - mail = lib.mkEnableOption "dummy option for chaostheatre"; - gammastep = lib.mkEnableOption "dummy option for chaostheatre"; - }; - }; - }; - } - EOF nix flake update vbc-nix git add . else @@ -15144,10 +15111,20 @@ Autoformatting always puts the =EOF= with indentation, which makes shfmt check f sudo mkdir -p /root/.local/share/nix/ printf '{\"extra-substituters\":{\"https://nix-community.cachix.org\":true,\"https://nix-community.cachix.org https://cache.ngi0.nixos.org/\":true},\"extra-trusted-public-keys\":{\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=\":true,\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=\":true}}' | sudo tee /root/.local/share/nix/trusted-settings.json > /dev/null green "Installing flake $target_config" - sudo nixos-install --flake .#"$target_config" + + store_path=$(nix build --no-link --print-out-paths .#nixosConfigurationsMinimal."$target_config".config.system.build.toplevel) + green "Linking generation in bootloader" + sudo "/run/current-system/sw/bin/nix-env --profile /nix/var/nix/profiles/system --set $store_path" + green "Setting generation to activate upon next boot" + sudo "$store_path/bin/switch-to-configuration boot" green "Installation finished! Reboot to see changes" + #+end_src +#+RESULTS: +| trap: | undefined | signal: | exit | | | | | +| [ | Babel | evaluation | exited | with | code | 1 | ] | + #+begin_src nix-ts :tangle pkgs/swarsel-install/default.nix diff --git a/files/scripts/swarsel-install.sh b/files/scripts/swarsel-install.sh index 5234475..b70faf9 100644 --- a/files/scripts/swarsel-install.sh +++ b/files/scripts/swarsel-install.sh @@ -92,34 +92,8 @@ cd .dotfiles if [[ $local_keys != *"${pub_arr[1]}"* ]]; then yellow "The ssh key for this configuration is not available." green "Adjusting flake.nix so that the configuration is buildable ..." - sed -i '/nix-secrets = {/,/^[[:space:]]*};/d' flake.nix sed -i '/vbc-nix = {/,/^[[:space:]]*};/d' flake.nix sed -i '/[[:space:]]*\/\/ (inputs.vbc-nix.overlays.default final prev)/d' overlays/default.nix - rm modules/home/common/env.nix - rm modules/home/common/gammastep.nix - rm modules/home/common/git.nix - rm modules/home/common/mail.nix - rm modules/home/common/yubikey.nix - rm modules/nixos/server/restic.nix - rm hosts/nixos/sync/default.nix - rm -rf modules/nixos/server - rm -rf modules/home/server - cat > hosts/nixos/chaostheatre/options-home.nix << EOF - { self, lib, ... }: - { - options = { - swarselsystems = { - modules = { - yubikey = lib.mkEnableOption "dummy option for chaostheatre"; - env = lib.mkEnableOption "dummy option for chaostheatre"; - git = lib.mkEnableOption "dummy option for chaostheatre"; - mail = lib.mkEnableOption "dummy option for chaostheatre"; - gammastep = lib.mkEnableOption "dummy option for chaostheatre"; - }; - }; - }; - } -EOF nix flake update vbc-nix git add . else @@ -194,5 +168,10 @@ git add /home/"$target_user"/.dotfiles/hosts/nixos/"$target_config"/hardware-con sudo mkdir -p /root/.local/share/nix/ printf '{\"extra-substituters\":{\"https://nix-community.cachix.org\":true,\"https://nix-community.cachix.org https://cache.ngi0.nixos.org/\":true},\"extra-trusted-public-keys\":{\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=\":true,\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=\":true}}' | sudo tee /root/.local/share/nix/trusted-settings.json > /dev/null green "Installing flake $target_config" -sudo nixos-install --flake .#"$target_config" + +store_path=$(nix build --no-link --print-out-paths .#nixosConfigurationsMinimal."$target_config".config.system.build.toplevel) +green "Linking generation in bootloader" +sudo "/run/current-system/sw/bin/nix-env --profile /nix/var/nix/profiles/system --set $store_path" +green "Setting generation to activate upon next boot" +sudo "$store_path/bin/switch-to-configuration boot" green "Installation finished! Reboot to see changes" diff --git a/hosts/nixos/chaostheatre/default.nix b/hosts/nixos/chaostheatre/default.nix index 47a0cba..e3c10d2 100644 --- a/hosts/nixos/chaostheatre/default.nix +++ b/hosts/nixos/chaostheatre/default.nix @@ -1,4 +1,4 @@ -{ self, inputs, config, pkgs, lib, ... }: +{ self, config, pkgs, lib, minimal, ... }: let mainUser = "demo"; sharedOptions = { @@ -7,7 +7,8 @@ let isLinux = true; isPublic = true; profiles = { - chaostheatre = true; + chaostheatre = lib.mkIf (!minimal) true; + minimal = lib.mkIf minimal true; }; }; in @@ -19,15 +20,6 @@ in { _module.args.diskDevice = config.swarselsystems.rootDisk; } - "${self}/hosts/nixos/chaostheatre/options.nix" - inputs.home-manager.nixosModules.home-manager - { - home-manager.users."${mainUser}".imports = [ - "${self}/modules/home/common/settings.nix" - "${self}/hosts/nixos/chaostheatre/options-home.nix" - "${self}/modules/home/common/sharedsetup.nix" - ]; - } ]; environment.variables = { @@ -57,6 +49,7 @@ in isSwap = true; swapSize = "4G"; rootDisk = "/dev/vda"; + profiles.btrfs = true; } sharedOptions; diff --git a/hosts/nixos/toto/default.nix b/hosts/nixos/toto/default.nix index 8dbf1d6..8a37895 100644 --- a/hosts/nixos/toto/default.nix +++ b/hosts/nixos/toto/default.nix @@ -35,7 +35,7 @@ in swapSize = "2G"; # rootDisk = "/dev/nvme0n1"; rootDisk = "/dev/vda"; - profiles.btrfs = lib.mkIf minimal true; + profiles.btrfs = true; # rootDisk = "/dev/vda"; } sharedOptions;