From 5637ab54fc7c9f48c84001ecb3b8affd12cbda21 Mon Sep 17 00:00:00 2001 From: Swarsel Date: Tue, 24 Dec 2024 14:00:37 +0100 Subject: [PATCH] feat: improve install ISO --- SwarselSystems.org | 53 ++++++++++++++++++++++++++++++++---- hosts/nixos/iso/default.nix | 31 +++++++++++++++++++-- hosts/nixos/toto/default.nix | 4 +-- programs/bash/.bash_history | 1 + programs/etc/issue | 5 ++++ 5 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 programs/bash/.bash_history create mode 100644 programs/etc/issue diff --git a/SwarselSystems.org b/SwarselSystems.org index ab2f82f..39798e8 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -1747,7 +1747,7 @@ This is a slim setup for developing base configuration. swapSize = "8"; rootDisk = "/dev/vda"; withImpermanence = true; - withEncryption = false; + withEncryption = true; }; } ./hardware-configuration.nix @@ -1814,7 +1814,7 @@ This is a slim setup for developing base configuration. wallpaper = self + /wallpaper/lenovowp.png; impermanence = true; isBtrfs = true; - isCrypted = false; + isCrypted = true; initialSetup = true; }; @@ -1837,8 +1837,26 @@ This is a slim setup for developing base configuration. This is a live environment ISO that I use to bootstrap new systems. It only loads a minimal configuration and no graphical interface. After booting this image on a host, find out its IP and bootstrap the system using the =bootstrap= utility. +For added convenience, the live environment displays a helpful text on login, we define it here (will be put into =/etc/issue=): + +#+begin_src bash :tangle programs/etc/issue + ~SwarselSystems~ + IP of primary interface: \4 + The Password for all users & root is 'setup'. + Install the system remotely by running 'bootstrap -n -d [--impermanence] [--encryption]' on a machine with deployed secrets. + Alternatively, run 'swarsel-install -d -f ' for a local install. For your convenience, an example call is in the bash history (press up on the keyboard to access). + +#+end_src + +Also, an initial bash history is provided to allow for a very quick local deployment: + +#+begin_src shell :tangle programs/bash/.bash_history +swarsel-install -f chaostheatre -d /dev/vda +#+end_src + + #+begin_src nix :tangle hosts/nixos/iso/default.nix - { self, pkgs, inputs, config, lib, modulesPath, ... }: + { self, pkgs, inputs, outputs, config, lib, modulesPath, ... }: let pubKeys = lib.filesystem.listFilesRecursive "${self}/secrets/keys/ssh"; in @@ -1855,9 +1873,32 @@ This is a live environment ISO that I use to bootstrap new systems. It only load "${self}/profiles/iso/minimal.nix" + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = [ + "${self}/profiles/common/home/settings.nix" + ] ++ (builtins.attrValues outputs.homeManagerModules); + } ]; - environment.etc."issue".text = "\\4\n"; + home-manager.users.swarsel.home = { + file = { + ".bash_history" = { + source = self + /programs/bash/.bash_history; + }; + }; + }; + home-manager.users.root.home = { + stateVersion = "23.05"; + file = { + ".bash_history" = { + source = self + /programs/bash/.bash_history; + }; + }; + }; + + # environment.etc."issue".text = "\x1B[32m~SwarselSystems~\x1B[0m\nIP of primary interface: \x1B[31m\\4\x1B[0m\nThe Password for all users & root is '\x1B[31msetup\x1B[0m'.\nInstall the system remotely by running '\x1B[33mbootstrap -n -d [--impermanence] [--encryption]\x1B[0m' on a machine with deployed secrets.\nAlternatively, run '\x1B[33mswarsel-install -d -f \x1B[0m' for a local install.\n"; + environment.etc."issue".source = "${self}/programs/etc/issue"; networking.dhcpcd.runHook = "${pkgs.utillinux}/bin/agetty --reload"; isoImage = { @@ -1903,7 +1944,9 @@ This is a live environment ISO that I use to bootstrap new systems. It only load system.activationScripts.cache = { text = '' - mkdir -p /home/swarsel/.local/share/nix/ + mkdir -p -m=0777 /home/swarsel/.local/state/nix/profiles + mkdir -p -m=0777 /home/swarsel/.local/state/home-manager/gcroots + mkdir -p -m=0777 /home/swarsel/.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}}' | tee /home/swarsel/.local/share/nix/trusted-settings.json > /dev/null 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}}' | tee /root/.local/share/nix/trusted-settings.json > /dev/null diff --git a/hosts/nixos/iso/default.nix b/hosts/nixos/iso/default.nix index c9abaaf..61c07d8 100644 --- a/hosts/nixos/iso/default.nix +++ b/hosts/nixos/iso/default.nix @@ -1,4 +1,4 @@ -{ self, pkgs, inputs, config, lib, modulesPath, ... }: +{ self, pkgs, inputs, outputs, config, lib, modulesPath, ... }: let pubKeys = lib.filesystem.listFilesRecursive "${self}/secrets/keys/ssh"; in @@ -15,9 +15,32 @@ in "${self}/profiles/iso/minimal.nix" + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = [ + "${self}/profiles/common/home/settings.nix" + ] ++ (builtins.attrValues outputs.homeManagerModules); + } ]; - environment.etc."issue".text = "\\4\n"; + home-manager.users.swarsel.home = { + file = { + ".bash_history" = { + source = self + /programs/bash/.bash_history; + }; + }; + }; + home-manager.users.root.home = { + stateVersion = "23.05"; + file = { + ".bash_history" = { + source = self + /programs/bash/.bash_history; + }; + }; + }; + + # environment.etc."issue".text = "\x1B[32m~SwarselSystems~\x1B[0m\nIP of primary interface: \x1B[31m\\4\x1B[0m\nThe Password for all users & root is '\x1B[31msetup\x1B[0m'.\nInstall the system remotely by running '\x1B[33mbootstrap -n -d [--impermanence] [--encryption]\x1B[0m' on a machine with deployed secrets.\nAlternatively, run '\x1B[33mswarsel-install -d -f \x1B[0m' for a local install.\n"; + environment.etc."issue".source = "${self}/programs/etc/issue"; networking.dhcpcd.runHook = "${pkgs.utillinux}/bin/agetty --reload"; isoImage = { @@ -63,7 +86,9 @@ in system.activationScripts.cache = { text = '' - mkdir -p /home/swarsel/.local/share/nix/ + mkdir -p -m=0777 /home/swarsel/.local/state/nix/profiles + mkdir -p -m=0777 /home/swarsel/.local/state/home-manager/gcroots + mkdir -p -m=0777 /home/swarsel/.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}}' | tee /home/swarsel/.local/share/nix/trusted-settings.json > /dev/null 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}}' | tee /root/.local/share/nix/trusted-settings.json > /dev/null diff --git a/hosts/nixos/toto/default.nix b/hosts/nixos/toto/default.nix index 7047a42..5483e4e 100644 --- a/hosts/nixos/toto/default.nix +++ b/hosts/nixos/toto/default.nix @@ -13,7 +13,7 @@ in swapSize = "8"; rootDisk = "/dev/vda"; withImpermanence = true; - withEncryption = false; + withEncryption = true; }; } ./hardware-configuration.nix @@ -80,7 +80,7 @@ in wallpaper = self + /wallpaper/lenovowp.png; impermanence = true; isBtrfs = true; - isCrypted = false; + isCrypted = true; initialSetup = true; }; diff --git a/programs/bash/.bash_history b/programs/bash/.bash_history new file mode 100644 index 0000000..6ede487 --- /dev/null +++ b/programs/bash/.bash_history @@ -0,0 +1 @@ +swarsel-install -f chaostheatre -d /dev/vda diff --git a/programs/etc/issue b/programs/etc/issue new file mode 100644 index 0000000..f85c154 --- /dev/null +++ b/programs/etc/issue @@ -0,0 +1,5 @@ +~SwarselSystems~ +IP of primary interface: \4 +The Password for all users & root is 'setup'. +Install the system remotely by running 'bootstrap -n -d [--impermanence] [--encryption]' on a machine with deployed secrets. +Alternatively, run 'swarsel-install -d -f ' for a local install. For your convenience, an example call is in the bash history (press up on the keyboard to access).