From 6f9edd8870d10f789221a9a7429b98650a2cf755 Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Wed, 8 Feb 2023 01:36:23 -0500 Subject: [PATCH] Add ISO build --- flake.nix | 9 ++++++++- machines/ephemeral/iso.nix | 12 ++++++++++++ machines/{ => ephemeral}/kexec.nix | 30 +++--------------------------- machines/ephemeral/minimal.nix | 28 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 machines/ephemeral/iso.nix rename machines/{ => ephemeral}/kexec.nix (67%) create mode 100644 machines/ephemeral/minimal.nix diff --git a/flake.nix b/flake.nix index 24d91d3..387638f 100644 --- a/flake.nix +++ b/flake.nix @@ -87,11 +87,18 @@ mkKexec = system: (nixpkgs.lib.nixosSystem { inherit system; - modules = [ ./machines/kexec.nix ]; + modules = [ ./machines/ephemeral/kexec.nix ]; }).config.system.build.kexec_tarball; + mkIso = system: + (nixpkgs.lib.nixosSystem { + inherit system; + modules = [ ./machines/ephemeral/iso.nix ]; + }).config.system.build.isoImage; in { "x86_64-linux"."kexec" = mkKexec "x86_64-linux"; + "x86_64-linux"."iso" = mkIso "x86_64-linux"; "aarch64-linux"."kexec" = mkKexec "aarch64-linux"; + "aarch64-linux"."iso" = mkIso "aarch64-linux"; }; }; } diff --git a/machines/ephemeral/iso.nix b/machines/ephemeral/iso.nix new file mode 100644 index 0000000..48daeef --- /dev/null +++ b/machines/ephemeral/iso.nix @@ -0,0 +1,12 @@ +{ modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/cd-dvd/iso-image.nix") + ./minimal.nix + ]; + + isoImage.makeUsbBootable = true; + + networking.hostName = "iso"; +} \ No newline at end of file diff --git a/machines/kexec.nix b/machines/ephemeral/kexec.nix similarity index 67% rename from machines/kexec.nix rename to machines/ephemeral/kexec.nix index 965dacf..c101816 100644 --- a/machines/kexec.nix +++ b/machines/ephemeral/kexec.nix @@ -6,8 +6,11 @@ imports = [ (modulesPath + "/installer/netboot/netboot.nix") (modulesPath + "/profiles/qemu-guest.nix") + ./minimal.nix ]; + networking.hostName = "kexec"; + # stripped down version of https://github.com/cleverca22/nix-tests/tree/master/kexec system.build = rec { image = pkgs.runCommand "image" { buildInputs = [ pkgs.nukeReferences ]; } '' @@ -42,31 +45,4 @@ contents = [ ]; }; }; - - boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "e1000" "e1000e" "virtio_pci" "r8169" ]; - boot.kernelParams = [ - "panic=30" "boot.panic_on_fail" # reboot the machine upon fatal boot issues - "console=ttyS0" # enable serial console - "console=tty1" - ]; - boot.kernel.sysctl."vm.overcommit_memory" = "1"; - - environment.systemPackages = with pkgs; [ - cryptsetup - btrfs-progs - ]; - environment.variables.GC_INITIAL_HEAP_SIZE = "1M"; - - networking.useDHCP = true; - - networking.hostName = "kexec"; - - services.openssh = { - enable = true; - challengeResponseAuthentication = false; - passwordAuthentication = false; - }; - - services.getty.autologinUser = "root"; - users.users.root.openssh.authorizedKeys.keys = (import ../common/ssh.nix).users; } \ No newline at end of file diff --git a/machines/ephemeral/minimal.nix b/machines/ephemeral/minimal.nix new file mode 100644 index 0000000..10452fa --- /dev/null +++ b/machines/ephemeral/minimal.nix @@ -0,0 +1,28 @@ +{ pkgs, ... }: + +{ + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "e1000" "e1000e" "virtio_pci" "r8169" ]; + boot.kernelParams = [ + "panic=30" "boot.panic_on_fail" # reboot the machine upon fatal boot issues + "console=ttyS0" # enable serial console + "console=tty1" + ]; + boot.kernel.sysctl."vm.overcommit_memory" = "1"; + + environment.systemPackages = with pkgs; [ + cryptsetup + btrfs-progs + ]; + environment.variables.GC_INITIAL_HEAP_SIZE = "1M"; + + networking.useDHCP = true; + + services.openssh = { + enable = true; + challengeResponseAuthentication = false; + passwordAuthentication = false; + }; + + services.getty.autologinUser = "root"; + users.users.root.openssh.authorizedKeys.keys = (import ../common/ssh.nix).users; +} \ No newline at end of file