New rebuild mechanism

Put most of it as a flake app, so we can mess with it without relying on
`rb` being rebuilt. Also nom nom!
This commit is contained in:
Geoffrey Frogeye 2024-06-10 02:11:04 +02:00
parent 7b9d9053bf
commit 17f0ba3370
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
8 changed files with 115 additions and 85 deletions

View file

@ -82,24 +82,9 @@ sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#d
trap - ERR
rm "$luks_pass_file"
# Generate hardware-config.nix
sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#nixos-generate-config" -- --no-filesystems --root "$mountpoint"
# --no-filesystems because they are imported via disko
sudo rm "$mountpoint/etc/nixos/configuration.nix"
# Plug system configuration into this git repo
sudo mkdir -p "${mountpoint}/etc/nixos"
echo "{
description = \"$name system config\";
inputs.entrypoint.url = \"git+file:$flake_uri\";
outputs = { self, entrypoint, ... }:
{
nixosConfigurations.$name = entrypoint.nixosConfigurations.$name.extendModules {
modules = [ ./hardware-configuration.nix ];
};
};
}" | sudo tee "${mountpoint}/etc/nixos/flake.nix" > /dev/null
# Everything there should be covered by (and conflicts with) the repo anyways.
# Save that system configuration uses this repo
sudo mkdir -p "${mountpoint}/etc"
sudo ln -sfn "${flake_uri}" "${mountpoint}/nixos"
# Install NixOS! Or create a new generation.
sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#nixos-install" -- --no-root-password --root "$mountpoint" --flake "${mountpoint}/etc/nixos#${name}"