forked from Fediversity/simple-nixos-fediverse
Nicolas Jeannerod
e9b5de893d
Co-authored-by: Taeer Bar-Yam <taeer.bar-yam@moduscreate.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Reviewed-on: Fediversity/simple-nixos-fediverse#26 Co-authored-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com> Co-committed-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
38 lines
1.2 KiB
Nix
38 lines
1.2 KiB
Nix
/**
|
|
Convert a NixOS configuration to one for a minimal installer ISO
|
|
|
|
WARNING: Running this installer will format the target disk!
|
|
*/
|
|
nixpkgs: machine:
|
|
let
|
|
installer = { config, pkgs, lib, ... }:
|
|
let
|
|
bootstrap = pkgs.writeShellApplication {
|
|
name = "bootstrap";
|
|
runtimeInputs = with pkgs; [ nixos-install-tools ];
|
|
text = ''
|
|
${machine.config.system.build.diskoScript}
|
|
nixos-install --no-root-password --no-channel-copy --system ${machine.config.system.build.toplevel}
|
|
'';
|
|
};
|
|
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 = ''
|
|
${nixpkgs.lib.getExe bootstrap}
|
|
'';
|
|
|
|
isoImage = {
|
|
compressImage = false;
|
|
squashfsCompression = "gzip -Xcompression-level 1";
|
|
isoName = lib.mkForce "installer.iso";
|
|
};
|
|
};
|
|
in
|
|
(nixpkgs.lib.nixosSystem { modules = [installer];}).config.system.build.isoImage
|
|
|