2023-07-05 16:25:21 +08:00
|
|
|
let
|
|
|
|
pkgs = import <nixpkgs> {};
|
|
|
|
|
|
|
|
# copied from nixpkgs/nixos/release.nix. Unfortunately, this isn't exported.
|
|
|
|
makeNetboot = { modules, system, ... }:
|
|
|
|
let
|
|
|
|
configEvaled = import <nixpkgs/nixos/lib/eval-config.nix> {
|
|
|
|
inherit system modules;
|
|
|
|
};
|
|
|
|
build = configEvaled.config.system.build;
|
|
|
|
kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
|
|
|
|
in
|
|
|
|
pkgs.symlinkJoin {
|
|
|
|
name = "netboot";
|
|
|
|
paths = [
|
|
|
|
build.netbootRamdisk
|
|
|
|
build.kernel
|
|
|
|
build.netbootIpxeScript
|
|
|
|
];
|
|
|
|
postBuild = ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products
|
|
|
|
echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products
|
|
|
|
echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
preferLocalBuild = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
autoInstall = pkgs.writeShellScriptBin "auto-install"
|
|
|
|
''
|
|
|
|
set -e
|
|
|
|
parted /dev/nvme0n1 -- mklabel gpt
|
|
|
|
parted /dev/nvme0n1 -- mkpart primary 512MiB 100%
|
|
|
|
parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 512MiB
|
|
|
|
parted /dev/nvme0n1 -- set 2 esp on
|
|
|
|
mkfs.ext4 -L nixos /dev/nvme0n1p1
|
|
|
|
mkfs.fat -F 32 -n boot /dev/nvme0n1p2
|
|
|
|
mount /dev/disk/by-label/nixos /mnt
|
|
|
|
mkdir -p /mnt/boot
|
|
|
|
mount /dev/disk/by-label/boot /mnt/boot
|
|
|
|
nixos-generate-config --root /mnt
|
|
|
|
cp ${./final}/* /mnt/etc/nixos
|
|
|
|
nixos-install --no-root-password --flake /mnt/etc/nixos#artiq
|
|
|
|
'';
|
|
|
|
|
2024-10-30 14:39:54 +08:00
|
|
|
customModule = prioNixbld: {
|
2023-07-05 16:25:21 +08:00
|
|
|
environment.systemPackages = [ autoInstall pkgs.git ];
|
2024-10-30 14:30:25 +08:00
|
|
|
documentation.info.enable = false; # https://github.com/NixOS/nixpkgs/issues/124215
|
|
|
|
documentation.man.enable = false;
|
2023-07-05 16:25:21 +08:00
|
|
|
nix.settings.trusted-public-keys = ["nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc="];
|
2024-10-30 14:39:54 +08:00
|
|
|
nix.settings.substituters = [("https://nixbld.m-labs.hk" + (if prioNixbld then "?priority=10" else ""))];
|
2024-10-30 14:35:25 +08:00
|
|
|
system.stateVersion = pkgs.lib.trivial.release;
|
2023-07-05 16:25:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
2024-10-30 14:39:54 +08:00
|
|
|
{ prioNixbld ? false }: makeNetboot {
|
2023-07-05 16:25:21 +08:00
|
|
|
modules = [
|
|
|
|
<nixpkgs/nixos/modules/installer/netboot/netboot-minimal.nix>
|
2024-10-30 14:39:54 +08:00
|
|
|
(customModule prioNixbld)
|
2023-07-05 16:25:21 +08:00
|
|
|
];
|
|
|
|
system = "x86_64-linux";
|
|
|
|
}
|