-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.nix
executable file
·88 lines (78 loc) · 2.79 KB
/
release.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{ stableBranch ? false,
supportedSystems ? [ "aarch64-linux" "armv7l-linux" "x86_64-linux" ],
nixpkgs ? { outPath = ./..; revCount = 56789; shortRev = "gfedcba"; }
}:
let
pkgs = import <nixpkgs> { overlays = [
(self: super: import pkgs/overlay.nix { inherit self super; })
(self: super: import pkgs/top-level.nix { pkgs = self; })
]; };
lib = pkgs.lib;
hardware = import ./hardware { inherit pkgs; };
versionSuffix =
(if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}";
versionModule =
{ system.nixosVersionSuffix = versionSuffix;
system.nixosRevision = nixpkgs.rev or nixpkgs.shortRev;
};
xzImage = config:
with config.system;
pkgs.runCommand "sd-image" { }
''
mkdir -p $out/{img,closure,nix-support}
${pkgs.xz}/bin/xz -c -9 ${build.sdImage} > $out/img/${build.sdImage.name}.xz
ln -s ${build.toplevel} $out/closure/top-level.closure
echo "file sd-image $out/img/${build.sdImage.name}.xz" >> $out/nix-support/hydra-build-products
echo "file closure $out/closure/top-level.closure" >> $out/nix-support/hydra-build-products
'';
vmLoader = config:
config.system.build.qemu.vmScript {
inherit pkgs config;
};
usbLoader = config:
config.system.build.usb.loader {
inherit pkgs config;
};
getConfig = { system, modules }:
(import <nixpkgs/nixos/lib/eval-config.nix> {
inherit system modules;
}).config;
buildVMConfig = board: system: getConfig {
inherit system;
modules = [
board
versionModule
./profiles/minimal.nix
./profiles/buildfarm.nix
./pkgs/modules/qemu-vm.nix
];
};
buildInstallerConfig = board: system: getConfig {
inherit system;
modules = [ board ./profiles/minimal.nix ./profiles/buildfarm.nix ./pkgs/modules/sd-image.nix versionModule ];
};
buildNetbootConfig = board: system: getConfig {
inherit system;
modules = [ board ./profiles/minimal.nix ./profiles/buildfarm.nix ./pkgs/modules/netboot.nix versionModule ];
};
board_conf = board_name: hardware.boards.${board_name};
board_names = lib.attrNames hardware.boards;
getPlatforms = board_name:
(import (board_conf board_name) { inherit pkgs lib; }).meta.platforms;
in lib.genAttrs board_names (board_name:
let
platforms = getPlatforms board_name;
in lib.genAttrs platforms (platform:
let
board = board_conf board_name;
installer-config = (buildInstallerConfig board platform);
netboot-config = (buildNetbootConfig board platform);
qemu-config = (buildVMConfig board platform);
in {
sd-image = xzImage installer-config;
usb-loader = usbLoader netboot-config;
vm-script = vmLoader qemu-config;
rootfs-image = installer-config.system.build.rootfsImage;
}
)
)