nixos-config/machine/oracle-installer/kexec.nix
Charlotte 🦝 Delenk cfc8962db5
Some checks failed
Hydra nixosConfigurations.not522 Hydra build #26488 of nixos-config:pr618:nixosConfigurations.not522
Hydra packages.aarch64-linux.element-web Hydra build #26495 of nixos-config:pr618:packages.aarch64-linux.element-web
Hydra packages.aarch64-linux.element-desktop Hydra build #26494 of nixos-config:pr618:packages.aarch64-linux.element-desktop
Hydra packages.x86_64-linux.element-web Hydra build #26497 of nixos-config:pr618:packages.x86_64-linux.element-web
Hydra packages.x86_64-linux.element-desktop Hydra build #26496 of nixos-config:pr618:packages.x86_64-linux.element-desktop
Hydra nixosConfigurations.not522-installer Hydra build #26489 of nixos-config:pr618:nixosConfigurations.not522-installer
Hydra nixosConfigurations.oracle-installer Hydra build #26490 of nixos-config:pr618:nixosConfigurations.oracle-installer
Hydra nixosConfigurations.pc-installer Hydra build #26491 of nixos-config:pr618:nixosConfigurations.pc-installer
Hydra nixosConfigurations.thinkrac Hydra build #26493 of nixos-config:pr618:nixosConfigurations.thinkrac
Hydra nixosConfigurations.rainbow-resort Hydra build #26492 of nixos-config:pr618:nixosConfigurations.rainbow-resort
add the oracle installer config
2024-11-19 09:17:44 +01:00

51 lines
1.7 KiB
Nix

{ pkgs, config, ... }:
{
system.build = rec {
image = pkgs.runCommand "image" { buildInputs = [ pkgs.nukeReferences ]; } ''
mkdir $out
cp ${config.system.build.kernel}/${config.system.boot.loader.kernelFile} $out/kernel
cp ${config.system.build.netbootRamdisk}/initrd $out/initrd
echo "init=${builtins.unsafeDiscardStringContext config.system.build.toplevel}/init ${toString config.boot.kernelParams}" > $out/cmdline
nuke-refs $out/kernel
'';
kexec_script = pkgs.writeTextFile {
executable = true;
name = "kexec-nixos";
text = ''
#!${pkgs.stdenv.shell}
export PATH=${pkgs.kexectools}/bin:${pkgs.cpio}/bin:$PATH
set -x
set -e
cd $(mktemp -d)
pwd
mkdir initrd
pushd initrd
if [ -e /ssh_pubkey ]; then
cat /ssh_pubkey >> authorized_keys
fi
find -type f | cpio -o -H newc | gzip -9 > ../extra.gz
popd
cat ${image}/initrd extra.gz > final.gz
kexec -l ${image}/kernel --initrd=final.gz --append="init=${builtins.unsafeDiscardStringContext config.system.build.toplevel}/init ${toString config.boot.kernelParams}"
sync
echo "executing kernel, filesystems will be improperly umounted"
kexec -e
'';
};
};
boot.initrd.postMountCommands = ''
mkdir -p /mnt-root/root/.ssh/
cp /authorized_keys /mnt-root/root/.ssh/
'';
system.build.kexec_tarball = pkgs.callPackage (pkgs.path + "/nixos/lib/make-system-tarball.nix") {
storeContents = [
{
object = config.system.build.kexec_script;
symlink = "/kexec_nixos";
}
];
contents = [ ];
};
}