forked from elliotberman/jetpack-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
153 lines (139 loc) · 6.19 KB
/
Copy pathflake.nix
File metadata and controls
153 lines (139 loc) · 6.19 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
};
outputs = { self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
allSystems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = nixpkgs.legacyPackages.${system};
inherit system;
});
installer_minimal_config = {
imports = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
self.nixosModules.default
];
# Avoids a bunch of extra modules we don't have in the tegra_defconfig, like "ata_piix",
hardware.enableAllHardware = lib.mkForce false;
hardware.nvidia-jetpack.enable = true;
};
aarch64_config = {
nixpkgs = {
buildPlatform = "aarch64-linux";
hostPlatform = "aarch64-linux";
};
};
aarch64_cross_config = {
nixpkgs = {
buildPlatform = "x86_64-linux";
hostPlatform = "aarch64-linux";
};
};
jetpack5_config = {
hardware.nvidia-jetpack.majorVersion = "5";
};
in
{
nixosConfigurations = {
installer_minimal = nixpkgs.lib.nixosSystem {
modules = [ aarch64_config installer_minimal_config ];
};
installer_minimal_cross = nixpkgs.lib.nixosSystem {
modules = [ aarch64_cross_config installer_minimal_config ];
};
installer_minimal_jp5 = nixpkgs.lib.nixosSystem {
modules = [ aarch64_config installer_minimal_config jetpack5_config ];
};
installer_minimal_cross_jp5 = nixpkgs.lib.nixosSystem {
modules = [ aarch64_cross_config installer_minimal_config jetpack5_config ];
};
};
nixosModules.default = import ./modules/default.nix;
overlays.default = import ./overlay.nix;
packages = {
x86_64-linux =
let
supportedConfigurations = lib.listToAttrs (map
(c: {
name = c.som + lib.optionalString (c.super or false) "-super" + "-${c.carrierBoard}" + lib.optionalString (c ? majorVersion) "-jp${c.majorVersion}";
value = c;
}) [
{ som = "orin-agx"; carrierBoard = "devkit"; }
{ som = "orin-agx-industrial"; carrierBoard = "devkit"; }
{ som = "orin-nx"; carrierBoard = "devkit"; }
{ som = "orin-nano"; carrierBoard = "devkit"; }
{ som = "orin-nx"; carrierBoard = "devkit"; super = true; }
{ som = "orin-nano"; carrierBoard = "devkit"; super = true; }
{ som = "orin-agx"; carrierBoard = "devkit"; majorVersion = "5"; }
{ som = "orin-agx-industrial"; carrierBoard = "devkit"; majorVersion = "5"; }
{ som = "orin-nx"; carrierBoard = "devkit"; majorVersion = "5"; }
{ som = "orin-nano"; carrierBoard = "devkit"; majorVersion = "5"; }
{ som = "orin-nx"; carrierBoard = "devkit"; super = true; majorVersion = "5"; }
{ som = "orin-nano"; carrierBoard = "devkit"; super = true; majorVersion = "5"; }
{ som = "xavier-agx"; carrierBoard = "devkit"; }
{ som = "xavier-agx-industrial"; carrierBoard = "devkit"; } # TODO: Entirely untested
{ som = "xavier-nx"; carrierBoard = "devkit"; }
{ som = "xavier-nx-emmc"; carrierBoard = "devkit"; }
]);
supportedNixOSConfigurations = lib.mapAttrs
(n: c: (nixpkgs.lib.nixosSystem {
modules = [
aarch64_cross_config
self.nixosModules.default
{
hardware.nvidia-jetpack = { enable = true; } // c;
networking.hostName = "${c.som}-${c.carrierBoard}"; # Just so it sets the flash binary name.
}
];
}).config)
supportedConfigurations;
flashScripts = lib.mapAttrs' (n: c: lib.nameValuePair "flash-${n}" c.system.build.flashScript) supportedNixOSConfigurations;
initrdFlashScripts = lib.mapAttrs' (n: c: lib.nameValuePair "initrd-flash-${n}" c.system.build.initrdFlashScript) supportedNixOSConfigurations;
uefiCapsuleUpdates = lib.mapAttrs' (n: c: lib.nameValuePair "uefi-capsule-update-${n}" c.system.build.uefiCapsuleUpdate) supportedNixOSConfigurations;
in
{
iso_minimal = self.nixosConfigurations.installer_minimal_cross.config.system.build.isoImage;
iso_minimal_jp5 = self.nixosConfigurations.installer_minimal_cross_jp5.config.system.build.isoImage;
inherit (self.legacyPackages.x86_64-linux)
board-automation python-jetson;
inherit (self.legacyPackages.x86_64-linux.cudaPackages)
nsight_systems_host nsight_compute_host;
}
# Flashing and board automation scripts _only_ work on x86_64-linux
// flashScripts
// initrdFlashScripts
// uefiCapsuleUpdates;
aarch64-linux = {
iso_minimal = self.nixosConfigurations.installer_minimal.config.system.build.isoImage;
iso_minimal_jp5 = self.nixosConfigurations.installer_minimal_jp5.config.system.build.isoImage;
};
};
checks = forAllSystems ({ pkgs, system, ... }: {
formatting = pkgs.runCommand "repo-formatting" { nativeBuildInputs = with pkgs; [ nixpkgs-fmt ]; } ''
nixpkgs-fmt --check ${self} && touch $out
'';
jetpackSelectionDependsOnCudaVersion = import ./check-jetpack-selection.nix {
inherit lib nixpkgs pkgs system;
overlay = self.overlays.default;
};
});
formatter = forAllSystems ({ pkgs, ... }: import ./treefmt.nix pkgs);
legacyPackages = forAllSystems ({ system, ... }:
let
pkgs =
(import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaCapabilities = [ "7.2" "8.7" ];
cudaSupport = true;
};
overlays = [ self.overlays.default ];
});
in
pkgs.nvidia-jetpack // { inherit (pkgs) nvidia-jetpack5 nvidia-jetpack6; }
);
};
}