add netboot-installer-nixos-unstable

This commit is contained in:
Jörg Thalheim 2023-05-14 20:59:46 +02:00
parent 9089946fc0
commit 25f782b4ce
4 changed files with 98 additions and 1 deletions

View file

@ -1,5 +1,23 @@
{ {
"nodes": { "nodes": {
"disko": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1683508929,
"narHash": "sha256-AqkIrwewCL8+zlkqhNxheF+kOfyakzZDk43SqRTIqRE=",
"owner": "nix-community",
"repo": "disko",
"rev": "2a59f5cf641607dbecb0cfec3ae32247e4aeb311",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"nixos-2211": { "nixos-2211": {
"locked": { "locked": {
"lastModified": 1684141842, "lastModified": 1684141842,
@ -32,8 +50,25 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs": {
"locked": {
"lastModified": 1683442750,
"narHash": "sha256-IiJ0WWW6OcCrVFl1ijE+gTaP0ChFfV6dNkJR05yStmw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eb751d65225ec53de9cf3d88acbf08d275882389",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko",
"nixos-2211": "nixos-2211", "nixos-2211": "nixos-2211",
"nixos-unstable": "nixos-unstable" "nixos-unstable": "nixos-unstable"
} }

View file

@ -3,6 +3,7 @@
inputs.nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable-small"; inputs.nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable-small";
inputs.nixos-2211.url = "github:NixOS/nixpkgs/release-22.11"; inputs.nixos-2211.url = "github:NixOS/nixpkgs/release-22.11";
inputs.disko.url = "github:nix-community/disko";
nixConfig.extra-substituters = [ nixConfig.extra-substituters = [
"https://cache.garnix.io" "https://cache.garnix.io"
@ -11,13 +12,14 @@
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
]; ];
outputs = { self, nixos-unstable, nixos-2211 }: let outputs = { self, nixos-unstable, nixos-2211, disko }: let
supportedSystems = [ "aarch64-linux" "x86_64-linux" ]; supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
forAllSystems = nixos-unstable.lib.genAttrs supportedSystems; forAllSystems = nixos-unstable.lib.genAttrs supportedSystems;
in { in {
packages = forAllSystems (system: let packages = forAllSystems (system: let
netboot = nixpkgs: (import (nixpkgs + "/nixos/release.nix") {}).netboot.${system}; netboot = nixpkgs: (import (nixpkgs + "/nixos/release.nix") {}).netboot.${system};
kexec-installer = nixpkgs: modules: (nixpkgs.legacyPackages.${system}.nixos (modules ++ [self.nixosModules.kexec-installer])).config.system.build.kexecTarball; kexec-installer = nixpkgs: modules: (nixpkgs.legacyPackages.${system}.nixos (modules ++ [self.nixosModules.kexec-installer])).config.system.build.kexecTarball;
netboot-installer = nixpkgs: (nixpkgs.legacyPackages.${system}.nixos [self.nixosModules.netboot-installer]).config.system.build.netboot;
in { in {
netboot-nixos-unstable = netboot nixos-unstable; netboot-nixos-unstable = netboot nixos-unstable;
netboot-nixos-2211 = netboot nixos-2211; netboot-nixos-2211 = netboot nixos-2211;
@ -32,10 +34,15 @@
{ system.kexec-installer.name = "nixos-kexec-installer-noninteractive"; } { system.kexec-installer.name = "nixos-kexec-installer-noninteractive"; }
self.nixosModules.noninteractive self.nixosModules.noninteractive
]; ];
netboot-installer-nixos-unstable = netboot-installer nixos-unstable;
netboot-installer-nixos-2211 = netboot-installer nixos-2211;
}); });
nixosModules = { nixosModules = {
kexec-installer = ./nix/kexec-installer/module.nix; kexec-installer = ./nix/kexec-installer/module.nix;
noninteractive = ./nix/noninteractive.nix; noninteractive = ./nix/noninteractive.nix;
# TODO: also add a test here once we have https://github.com/NixOS/nixpkgs/pull/228346 merged
netboot-installer = ./nix/netboot-installer/module.nix;
}; };
checks.x86_64-linux = let checks.x86_64-linux = let
pkgs = nixos-unstable.legacyPackages.x86_64-linux; pkgs = nixos-unstable.legacyPackages.x86_64-linux;

View file

View file

@ -0,0 +1,55 @@
{ config, lib, modulesPath, pkgs, ... }:
{
imports = [
(modulesPath + "/installer/netboot/netboot-minimal.nix")
../installer.nix
];
# We are stateless, so just default to latest.
system.stateVersion = config.system.nixos.version;
system.build.netboot = pkgs.symlinkJoin {
name = "netboot";
paths = with config.system.build; [
netbootRamdisk
kernel
(pkgs.runCommand "kernel-params" {} ''
mkdir -p $out
ln -s "${config.system.build.toplevel}/kernel-params" $out/kernel-params
ln -s "${config.system.build.toplevel}/init" $out/init
'')
];
preferLocalBuild = true;
};
systemd.network.networks."10-uplink" = {
matchConfig.Type = "ether";
networkConfig = {
DHCP = "yes";
LLMNR = "yes";
EmitLLDP = "yes";
IPv6AcceptRA = "no";
MulticastDNS = "yes";
LinkLocalAddressing = "yes";
LLDP = "yes";
};
dhcpV4Config = {
UseHostname = false;
ClientIdentifier = "mac";
};
};
networking.hostName = "";
# overrides normal activation script for setting hostname
system.activationScripts.hostname = lib.mkForce ''
# apply hostname from cmdline
for o in $(< /proc/cmdline); do
case $o in
hostname=*)
IFS== read -r -a hostParam <<< "$o"
;;
esac
done
hostname "''${hostParam[1]:-nixos}"
'';
}