Some checks are pending
deploy-infra / deploy (push) Waiting to run
/ check-data-model (push) Waiting to run
Nix flake checks / _checks (push) Blocked by required conditions
Nix flake checks / _complete (push) Waiting to run
Nix flake checks / deployment-basic (push) Waiting to run
Nix flake checks / deployment-cli (push) Waiting to run
Nix flake checks / deployment-model-nixops4 (push) Waiting to run
Nix flake checks / deployment-model-ssh (push) Waiting to run
Nix flake checks / deployment-model-tf (push) Waiting to run
Nix flake checks / deployment-panel (push) Waiting to run
Nix flake checks / nixops-deployment-providers-default (push) Waiting to run
Nix flake checks / nixops-deployment-providers-fedi200 (push) Waiting to run
Nix flake checks / nixops-deployment-providers-fedi201 (push) Waiting to run
Nix flake checks / nixops-deployment-providers-forgejo-ci (push) Waiting to run
Nix flake checks / nixops-deployment-providers-test (push) Waiting to run
Nix flake checks / nixops-deployment-providers-vm02116 (push) Waiting to run
Nix flake checks / nixops-deployment-providers-vm02187 (push) Waiting to run
Nix flake checks / nixosConfigurations-fedi200 (push) Waiting to run
Nix flake checks / nixosConfigurations-fedi201 (push) Waiting to run
Nix flake checks / nixosConfigurations-forgejo-ci (push) Waiting to run
Nix flake checks / nixosConfigurations-test01 (push) Waiting to run
Nix flake checks / nixosConfigurations-test02 (push) Waiting to run
Nix flake checks / nixosConfigurations-test03 (push) Waiting to run
Nix flake checks / nixosConfigurations-test04 (push) Waiting to run
Nix flake checks / nixosConfigurations-test05 (push) Waiting to run
Nix flake checks / nixosConfigurations-test06 (push) Waiting to run
Nix flake checks / nixosConfigurations-test11 (push) Waiting to run
Nix flake checks / nixosConfigurations-test12 (push) Waiting to run
Nix flake checks / nixosConfigurations-test13 (push) Waiting to run
Nix flake checks / nixosConfigurations-test14 (push) Waiting to run
Nix flake checks / nixosConfigurations-vm02116 (push) Waiting to run
Nix flake checks / nixosConfigurations-vm02187 (push) Waiting to run
Nix flake checks / panel (push) Waiting to run
Nix flake checks / pre-commit (push) Waiting to run
Nix flake checks / proxmox-basic (push) Waiting to run
Nix flake checks / test-mastodon-service (push) Waiting to run
Nix flake checks / test-peertube-service (push) Waiting to run
Nix flake checks / vmOptions-fedi200 (push) Waiting to run
Nix flake checks / vmOptions-fedi201 (push) Waiting to run
Nix flake checks / vmOptions-test01 (push) Waiting to run
Nix flake checks / vmOptions-test02 (push) Waiting to run
Nix flake checks / vmOptions-test03 (push) Waiting to run
Nix flake checks / vmOptions-test04 (push) Waiting to run
Nix flake checks / vmOptions-test05 (push) Waiting to run
Nix flake checks / vmOptions-test06 (push) Waiting to run
Nix flake checks / vmOptions-test11 (push) Waiting to run
Nix flake checks / vmOptions-test12 (push) Waiting to run
Nix flake checks / vmOptions-test13 (push) Waiting to run
Nix flake checks / vmOptions-test14 (push) Waiting to run
Reviewed-on: Fediversity/Fediversity#525
64 lines
1.9 KiB
Nix
64 lines
1.9 KiB
Nix
/**
|
|
Convert a NixOS configuration to one for a minimal installer ISO
|
|
|
|
WARNING: Running this installer will format the target disk!
|
|
*/
|
|
|
|
{
|
|
nixosConfiguration,
|
|
hostKeys ? { },
|
|
nixpkgs ? (import ../npins).nixpkgs,
|
|
}:
|
|
|
|
let
|
|
inherit (builtins) concatStringsSep attrValues mapAttrs;
|
|
|
|
installer =
|
|
{
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
bootstrap = pkgs.writeShellApplication {
|
|
name = "bootstrap";
|
|
runtimeInputs = with pkgs; [ nixos-install-tools ];
|
|
text = ''
|
|
${nixosConfiguration.config.system.build.diskoScript}
|
|
nixos-install --no-root-password --no-channel-copy --system ${nixosConfiguration.config.system.build.toplevel}
|
|
${concatStringsSep "\n" (
|
|
attrValues (
|
|
mapAttrs (kind: keys: ''
|
|
cp ${keys.private} /mnt/etc/ssh/ssh_host_${kind}_key
|
|
chmod 600 /mnt/etc/ssh/ssh_host_${kind}_key
|
|
cp ${keys.public} /mnt/etc/ssh/ssh_host_${kind}_key.pub
|
|
chmod 644 /mnt/etc/ssh/ssh_host_${kind}_key.pub
|
|
'') hostKeys
|
|
)
|
|
)}
|
|
poweroff
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
imports = [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ];
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
services.getty.autologinUser = lib.mkForce "root";
|
|
programs.bash.loginShellInit = lib.getExe bootstrap;
|
|
|
|
isoImage = {
|
|
compressImage = false;
|
|
squashfsCompression = "lz4";
|
|
isoName = lib.mkForce "installer.iso";
|
|
## ^^ FIXME: Use a more interesting name or keep the default name and
|
|
## use `isoImage.isoName` in the tests.
|
|
};
|
|
};
|
|
in
|
|
(import "${nixpkgs}/nixos/lib/eval-config.nix" {
|
|
modules = [ installer ];
|
|
# Allow system to be set modularly in nixpkgs.system.
|
|
# We set it to null, to remove the "legacy" entrypoint's
|
|
# non-hermetic default.
|
|
system = null;
|
|
}).config.system.build.isoImage
|