kexec installer package
This commit is contained in:
commit
c318fb3361
4 changed files with 222 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/.direnv
|
||||
/result
|
||||
/.pre-commit-config.yaml
|
123
flake.lock
Normal file
123
flake.lock
Normal file
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1668681692,
|
||||
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"pre-commit-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660459072,
|
||||
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1672617983,
|
||||
"narHash": "sha256-68WDiCBs631mbDDk4UAKdGURKcsfW6hjb7wgudTAe5o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0fc9fca9c8d43edd79d33fea0dd8409d7c4580f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1671271954,
|
||||
"narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1672734157,
|
||||
"narHash": "sha256-uwUBnv0bN1SO4QVIo8KUx/jxRYCy7cW8kzZa+Qsrw9k=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "d0ce0a861260493c6c21f16f59d25076f73cb931",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
95
flake.nix
Normal file
95
flake.nix
Normal file
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
description = "A very basic flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
|
||||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
nixosConfig = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/installer/netboot/netboot-minimal.nix"
|
||||
({ pkgs, ... }: {
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
startWhenNeeded = true;
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keyFiles = [
|
||||
(pkgs.fetchurl {
|
||||
url = "https://github.com/eboskma.keys";
|
||||
sha256 = "uwK4FSLSHiwCJU9U7RBFHIoCmr7uUQLM0JM1u0bi4xo=";
|
||||
})
|
||||
];
|
||||
|
||||
networking = {
|
||||
useDHCP = true;
|
||||
};
|
||||
|
||||
system.stateVersion = "23.05";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
kexecScript = pkgs.writeScript "kexec-installer" ''
|
||||
#!/bin/sh
|
||||
if ! kexec -v >/dev/null 2>&1; then
|
||||
echo "kexec not found: please install kexec-tools" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
kexec --load ./bzImage \
|
||||
--initrd=./initrd.zst \
|
||||
--command-line "init=${nixosConfig.config.system.build.toplevel}/init ${toString nixosConfig.config.boot.kernelParams}"
|
||||
if systemctl --version >/dev/null 2>&1; then
|
||||
systemctl kexec
|
||||
else
|
||||
kexec -e
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
|
||||
checks = {
|
||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
nixpkgs-fmt.enable = true;
|
||||
deadnix.enable = true;
|
||||
statix.enable = true;
|
||||
shellcheck = {
|
||||
enable = true;
|
||||
types_or = [ "executable" ];
|
||||
};
|
||||
shfmt.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
devShells.default = with pkgs; mkShell {
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
name = "kexec-installer";
|
||||
};
|
||||
|
||||
packages.kexec-installer = pkgs.linkFarm "netboot" [
|
||||
{ name = "initrd.zst"; path = "${nixosConfig.config.system.build.netbootRamdisk}/initrd.zst"; }
|
||||
{ name = "bzImage"; path = "${nixosConfig.config.system.build.kernel}/bzImage"; }
|
||||
{ name = "kexec-installer"; path = kexecScript; }
|
||||
];
|
||||
|
||||
packages.default = self.packages.${system}.kexec-installer;
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in a new issue