mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-09-11 12:15:29 +03:00
on nixpkgs versions prior to the commit that changed config.system.build's type from a lazy attribute set to a submodule. Prior to this type change, there is no system.build.kexec_tarball option declared, so the NixOS module system does not resolve priorities/overrides in the config.build.kexec_tarball definition. That is, with lib.mkForce, the config.build.kexec_tarball definition ends up being something like: { _type = "override"; content = <...>; priority = 50; } Removing lib.mkForce allows us to successfully and sensibly interpolate the value (== outPath) of system.build.kexec_tarball in system.build.kexec_bundle's builder script. Likewise, no lib.mkOverride for system.build.raw.
62 lines
1.8 KiB
Nix
62 lines
1.8 KiB
Nix
{ config, pkgs, lib, modulesPath, options, ... }: let
|
|
|
|
clever-tests = builtins.fetchGit {
|
|
url = "https://github.com/cleverca22/nix-tests";
|
|
rev = "a9a316ad89bfd791df4953c1a8b4e8ed77995a18"; # master on 2021-06-13
|
|
};
|
|
|
|
inherit (import ../lib.nix { inherit lib options; }) maybe;
|
|
in {
|
|
imports = [
|
|
"${toString modulesPath}/installer/netboot/netboot-minimal.nix"
|
|
"${clever-tests}/kexec/autoreboot.nix"
|
|
"${clever-tests}/kexec/kexec.nix"
|
|
"${clever-tests}/kexec/justdoit.nix"
|
|
];
|
|
|
|
system.build = rec {
|
|
kexec_tarball = maybe.mkForce (pkgs.callPackage "${toString modulesPath}/../lib/make-system-tarball.nix" {
|
|
storeContents = [
|
|
{ object = config.system.build.kexec_script; symlink = "/kexec_nixos"; }
|
|
];
|
|
contents = [];
|
|
});
|
|
|
|
kexec_tarball_self_extract_script = pkgs.writeTextFile {
|
|
executable = true;
|
|
name = "kexec-nixos";
|
|
text = ''
|
|
#!/bin/sh
|
|
set -eu
|
|
ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ { print NR + 1; exit 0; }' $0`
|
|
|
|
tail -n+$ARCHIVE $0 | tar xJ -C /
|
|
/kexec_nixos
|
|
|
|
exit 1
|
|
|
|
__ARCHIVE_BELOW__
|
|
'';
|
|
};
|
|
|
|
kexec_bundle = pkgs.runCommand "kexec_bundle" {} ''
|
|
cat \
|
|
${kexec_tarball_self_extract_script} \
|
|
${config.system.build.kexec_tarball}/tarball/nixos-system-${config.system.build.kexec_tarball.system}.tar.xz \
|
|
> $out
|
|
chmod +x $out
|
|
'';
|
|
};
|
|
|
|
boot.loader.grub.enable = false;
|
|
boot.kernelParams = [
|
|
"console=ttyS0,115200" # allows certain forms of remote access, if the hardware is setup right
|
|
"panic=30" "boot.panic_on_fail" # reboot the machine upon fatal boot issues
|
|
];
|
|
systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ];
|
|
networking.hostName = lib.mkDefault "kexec";
|
|
|
|
formatAttr = "kexec_tarball";
|
|
filename = "*/tarball/*.tar.xz";
|
|
}
|