Skip to content

Commit d1a9bd5

Browse files
committed
Deprecate nixos options related to packaging
We have a few nixos options that are mirrors of arguments to `stdenv.mkDerivation` (e.g. `patches`, `postPatch`). Let's encourage users to use the overlay system in order customize packaging.
1 parent 773fbb7 commit d1a9bd5

File tree

15 files changed

+601
-612
lines changed

15 files changed

+601
-612
lines changed

UPGRADE_CHECKLIST.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
### Updating
22
- [ ] Update `l4tVersion`, `jetpackVersion`, and `cudaVersion` in overlay.nix
3-
- [ ] Update branch/revision/sha256s in:
3+
- [ ] Update branch/revision/hashes in:
44
- [ ] `overlay.nix`
55
- [ ] `kernel/default.nix`
6-
- [ ] `uefi-firmware.nix`
7-
- [ ] Grep for "sha256 = ", see if there is anything else not covered
6+
- [ ] `pkgs/uefi-firmware/edk2-nvidia.nix`
7+
- [ ] `pkgs/uefi-firmware/jetson-edk2-uefi.nix`
8+
- [ ] `grep -r -e "hash = " -e "sha256 = "` to see if there is anything else not covered
89
- [ ] Update the kernel version in `kernel/default.nix` if it chaged.
910
- [ ] Grep for the previous version strings e.g. "35.4.1"
1011
- [ ] Compare files from `unpackedDebs` before and after

device-pkgs/flash-script.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ flash-tools:
1010
# be used by the bootloader(s) and passed to the kernel.
1111
dtbsDir ? null
1212
, # Optional package containing uefi_jetson.efi to replace prebuilt version
13-
uefi-firmware ? null
13+
uefiFirmware ? null
1414
, # Optional package containing tos.img to replace prebuilt version
1515
tosImage ? null
1616
, # Optional EKS file containing encrypted keyblob
@@ -44,18 +44,18 @@ flash-tools:
4444
4545
${lib.optionalString (partitionTemplate != null) "cp ${partitionTemplate} flash.xml"}
4646
${lib.optionalString (dtbsDir != null) "cp -r ${dtbsDir}/. kernel/dtb/"}
47-
${lib.optionalString (uefi-firmware != null) ''
48-
cp ${uefi-firmware}/uefi_jetson.bin bootloader/uefi_jetson.bin
47+
${lib.optionalString (uefiFirmware != null) ''
48+
cp ${uefiFirmware}/uefi_jetson.bin bootloader/uefi_jetson.bin
4949
5050
# For normal NixOS usage, we'd probably use systemd-boot or GRUB instead,
5151
# but lets replace the upstream L4TLauncher EFI payload anyway
52-
cp ${uefi-firmware}/L4TLauncher.efi bootloader/BOOTAA64.efi
52+
cp ${uefiFirmware}/L4TLauncher.efi bootloader/BOOTAA64.efi
5353
5454
# Replace additional dtbos
55-
cp ${uefi-firmware}/dtbs/*.dtbo kernel/dtb/
55+
cp ${uefiFirmware}/dtbs/*.dtbo kernel/dtb/
5656
''}
5757
${lib.optionalString (tosImage != null) ''
58-
cp ${tosImage}/tos.img bootloader/tos-optee_${socType}.img
58+
cp ${tosImage} bootloader/tos-optee_${socType}.img
5959
''}
6060
${lib.optionalString (eksFile != null) ''
6161
cp ${eksFile} bootloader/eks_${socType}.img

modules/flash-script.nix

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ in
2222
(mkRenamedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "optee" "supplicantExtraArgs" ] [ "hardware" "nvidia-jetpack" "firmware" "optee" "supplicant" "extraArgs" ])
2323
(mkRenamedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "optee" "trustedApplications" ] [ "hardware" "nvidia-jetpack" "firmware" "optee" "supplicant" "trustedApplications" ])
2424
(mkRenamedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "optee" "supplicantPlugins" ] [ "hardware" "nvidia-jetpack" "firmware" "optee" "supplicant" "plugins" ])
25+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "uefi" "edk2NvidiaPatches" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.edk2NvidiaSrc` instead.")
26+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "uefi" "edk2UefiPatches" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.jetsonEdk2Uefi` instead.")
27+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "flashScriptOverrides" "patches" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.flash-tools` instead.")
28+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "flashScriptOverrides" "postPatch" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.flash-tools` instead.")
29+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "optee" "patches" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.opteeOS` instead.")
30+
(mkRemovedOptionModule [ "hardware" "nvidia-jetpack" "firmware" "optee" "extraMakeFlags" ] "Use `nixpkgs.overlays` to modify `pkgs.nvidia-jetpack.opteeOS` instead.")
2531
];
2632

2733
options = {
@@ -57,22 +63,6 @@ in
5763
default = cfg.firmware.uefi.debugMode;
5864
};
5965

60-
edk2NvidiaPatches = mkOption {
61-
type = types.listOf types.path;
62-
description = lib.mdDoc ''
63-
Patches that will be applied to the edk2-nvidia repo
64-
'';
65-
default = [ ];
66-
};
67-
68-
edk2UefiPatches = mkOption {
69-
type = types.listOf types.path;
70-
description = lib.mdDoc ''
71-
Patches that will be applied to the nvidia edk2 repo which is nvidia's fork of the upstream edk2 repo
72-
'';
73-
default = [ ];
74-
};
75-
7666
secureBoot = {
7767
enrollDefaultKeys = lib.mkEnableOption "enroll default UEFI keys";
7868
defaultPkEslFile = mkOption {
@@ -175,16 +165,6 @@ in
175165
};
176166
};
177167

178-
patches = mkOption {
179-
type = types.listOf types.path;
180-
default = [ ];
181-
};
182-
183-
extraMakeFlags = mkOption {
184-
type = types.listOf types.str;
185-
default = [ ];
186-
};
187-
188168
taPublicKeyFile = mkOption {
189169
type = types.nullOr types.path;
190170
default = null;
@@ -298,18 +278,6 @@ in
298278
description = ".xml file describing partition template to use when flashing";
299279
};
300280

301-
patches = mkOption {
302-
type = types.listOf types.path;
303-
default = [ ];
304-
description = "Patches to apply to the flash-tools";
305-
};
306-
307-
postPatch = mkOption {
308-
type = types.lines;
309-
default = "";
310-
description = "Additional commands to run when building flash-tools";
311-
};
312-
313281
additionalDtbOverlays = mkOption {
314282
type = types.listOf types.path;
315283
default = [ ];

overlay-with-config.nix

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ final: prev: (
55
cfg = config.hardware.nvidia-jetpack;
66

77
inherit (prev) lib;
8-
9-
tosArgs = {
10-
inherit (final.nvidia-jetpack) socType;
11-
inherit (cfg.firmware.optee) taPublicKeyFile;
12-
opteePatches = cfg.firmware.optee.patches;
13-
extraMakeFlags = cfg.firmware.optee.extraMakeFlags;
14-
};
158
in
169
{
1710
nvidia-jetpack = prev.nvidia-jetpack.overrideScope (finalJetpack: prevJetpack: {
@@ -27,24 +20,19 @@ final: prev: (
2720
else if lib.hasPrefix "xavier-" cfg.som then "0x19"
2821
else throw "Unknown SoC type";
2922

30-
uefi-firmware = prevJetpack.uefi-firmware.override ({
23+
edk2NvidiaSrc = prevJetpack.edk2NvidiaSrc.override {
24+
errorLevelInfo = cfg.firmware.uefi.errorLevelInfo;
3125
bootLogo = cfg.firmware.uefi.logo;
26+
};
27+
28+
jetsonEdk2Uefi = prevJetpack.jetsonEdk2Uefi.override ({
3229
debugMode = cfg.firmware.uefi.debugMode;
33-
errorLevelInfo = cfg.firmware.uefi.errorLevelInfo;
34-
edk2NvidiaPatches = cfg.firmware.uefi.edk2NvidiaPatches;
35-
edk2UefiPatches = cfg.firmware.uefi.edk2UefiPatches;
3630
} // lib.optionalAttrs cfg.firmware.uefi.capsuleAuthentication.enable {
3731
inherit (cfg.firmware.uefi.capsuleAuthentication) trustedPublicCertPemFile;
3832
});
3933

40-
flash-tools = prevJetpack.flash-tools.overrideAttrs ({ patches ? [ ], postPatch ? "", ... }: {
41-
patches = patches ++ cfg.flashScriptOverrides.patches;
42-
postPatch = postPatch + cfg.flashScriptOverrides.postPatch;
43-
});
44-
45-
tosImage = finalJetpack.buildTOS tosArgs;
46-
taDevKit = finalJetpack.buildOpteeTaDevKit tosArgs;
47-
inherit (finalJetpack.tosImage) nvLuksSrv hwKeyAgent;
34+
armTrustedFirmware = finalJetpack.callPackage ./pkgs/optee/arm-trusted-firmware.nix { };
35+
tosImage = finalJetpack.callPackage ./pkgs/optee/tos-image.nix { };
4836

4937
flashInitrd =
5038
let
@@ -101,7 +89,7 @@ final: prev: (
10189
inherit lib;
10290
inherit (cfg.firmware) eksFile;
10391
inherit (cfg.flashScriptOverrides) additionalDtbOverlays flashArgs partitionTemplate;
104-
inherit (finalJetpack) tosImage socType uefi-firmware;
92+
inherit (finalJetpack) tosImage socType uefiFirmware;
10593

10694
dtbsDir = config.hardware.deviceTree.package;
10795
} // args);

overlay.nix

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,30 @@ in
5959
self.gitRepos
6060
);
6161

62-
inherit (prev.callPackages ./pkgs/uefi-firmware { inherit (self) l4tVersion; })
63-
edk2-jetson uefi-firmware;
64-
65-
inherit (prev.callPackages ./pkgs/optee {
66-
# Nvidia's recommended toolchain is gcc9:
67-
# https://nv-tegra.nvidia.com/r/gitweb?p=tegra/optee-src/nv-optee.git;a=blob;f=optee/atf_and_optee_README.txt;h=591edda3d4ec96997e054ebd21fc8326983d3464;hb=5ac2ab218ba9116f1df4a0bb5092b1f6d810e8f7#l33
68-
stdenv = prev.gcc9Stdenv;
69-
inherit (self) bspSrc gitRepos l4tVersion;
70-
}) buildTOS buildOpteeTaDevKit opteeClient;
62+
edk2NvidiaSrc = self.callPackage ./pkgs/uefi-firmware/edk2-nvidia-src.nix { };
63+
jetsonEdk2Uefi = self.callPackage ./pkgs/uefi-firmware/jetson-edk2-uefi.nix { };
64+
uefiFirmware = self.callPackage ./pkgs/uefi-firmware/default.nix { };
65+
66+
# Nvidia's recommended toolchain for optee is gcc9:
67+
# https://nv-tegra.nvidia.com/r/gitweb?p=tegra/optee-src/nv-optee.git;a=blob;f=optee/atf_and_optee_README.txt;h=591edda3d4ec96997e054ebd21fc8326983d3464;hb=5ac2ab218ba9116f1df4a0bb5092b1f6d810e8f7#l33
68+
opteeStdenv = prev.gcc9Stdenv;
69+
70+
opteeClient = self.callPackage ./pkgs/optee/client.nix { };
71+
72+
opteeTaDevKit = (self.callPackage ./pkgs/optee/os.nix { }).overrideAttrs (old: {
73+
pname = "optee-ta-dev-kit";
74+
makeFlags = (old.makeFlags or [ ]) ++ [ "ta_dev_kit" ];
75+
});
76+
77+
nvLuksSrv = self.callPackage ./pkgs/optee/nv-luks-srv.nix { };
78+
hwKeyAgent = self.callPackage ./pkgs/optee/hw-key-agent.nix { };
79+
80+
opteeOS = self.callPackage ./pkgs/optee/os.nix {
81+
earlyTaPaths = [
82+
"${self.nvLuksSrv}/${self.nvLuksSrv.uuid}.stripped.elf"
83+
"${self.hwKeyAgent}/${self.hwKeyAgent.uuid}.stripped.elf"
84+
];
85+
};
7186

7287
flash-tools = self.callPackage ./pkgs/flash-tools { };
7388

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{ gitRepos
2+
, l4tVersion
3+
, opteeStdenv
4+
, socType
5+
}:
6+
7+
opteeStdenv.mkDerivation {
8+
pname = "arm-trusted-firmware";
9+
version = l4tVersion;
10+
src = gitRepos."tegra/optee-src/atf";
11+
makeFlags = [
12+
"-C arm-trusted-firmware"
13+
"BUILD_BASE=$(PWD)/build"
14+
"CROSS_COMPILE=${opteeStdenv.cc.targetPrefix}"
15+
"DEBUG=0"
16+
"LOG_LEVEL=20"
17+
"PLAT=tegra"
18+
"SPD=opteed"
19+
"TARGET_SOC=${socType}"
20+
"V=0"
21+
# binutils 2.39 regression
22+
# `warning: /build/source/build/rk3399/release/bl31/bl31.elf has a LOAD segment with RWX permissions`
23+
# See also: https://developer.trustedfirmware.org/T996
24+
"LDFLAGS=-no-warn-rwx-segments"
25+
];
26+
27+
enableParallelBuilding = true;
28+
29+
installPhase = ''
30+
runHook preInstall
31+
32+
mkdir -p $out
33+
cp ./build/tegra/${socType}/release/bl31.bin $out/bl31.bin
34+
35+
runHook postInstall
36+
'';
37+
38+
meta.platforms = [ "aarch64-linux" ];
39+
}

pkgs/optee/client.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ opteeStdenv, fetchpatch, gitRepos, l4tVersion, pkg-config, libuuid }:
2+
3+
opteeStdenv.mkDerivation {
4+
pname = "optee_client";
5+
version = l4tVersion;
6+
src = gitRepos."tegra/optee-src/nv-optee";
7+
patches = [
8+
./0001-Don-t-prepend-foo-bar-baz-to-TEEC_LOAD_PATH.patch
9+
(fetchpatch {
10+
name = "tee-supplicant-Allow-for-TA-load-path-to-be-specified-at-runtime.patch";
11+
url = "https://github.com/OP-TEE/optee_client/commit/f3845d8bee3645eedfcc494be4db034c3c69e9ab.patch";
12+
stripLen = 1;
13+
extraPrefix = "optee/optee_client/";
14+
hash = "sha256-XjFpMbyXy74sqnc8l+EgTaPXqwwHcvni1Z68ShokTGc=";
15+
})
16+
];
17+
nativeBuildInputs = [ pkg-config ];
18+
buildInputs = [ libuuid ];
19+
enableParallelBuilding = true;
20+
makeFlags = [
21+
"-C optee/optee_client"
22+
"DESTDIR=$(out)"
23+
"SBINDIR=/sbin"
24+
"LIBDIR=/lib"
25+
"INCLUDEDIR=/include"
26+
];
27+
meta.platforms = [ "aarch64-linux" ];
28+
}

0 commit comments

Comments
 (0)