diff --git a/flake.nix b/flake.nix index 30024a4..9f74d54 100644 --- a/flake.nix +++ b/flake.nix @@ -53,7 +53,7 @@ ./nix/modules/lanzaboote.nix ]; - boot.lanzaboote.package = perSystem.config.packages.lanzatool; + boot.lanzaboote.package = perSystem.config.packages.tool; } ); @@ -107,15 +107,15 @@ }); }; - lanzabooteCrane = buildRustApp { + stubCrane = buildRustApp { src = craneLib.cleanCargoSource ./rust/stub; target = "x86_64-unknown-uefi"; doCheck = false; }; - lanzaboote = lanzabooteCrane.package; + stub = stubCrane.package; - lanzatoolCrane = buildRustApp { + toolCrane = buildRustApp { src = ./rust/tool; extraArgs = { TEST_SYSTEMD = pkgs.systemd; @@ -126,34 +126,36 @@ }; }; - lanzatool-unwrapped = lanzatoolCrane.package; + tool = toolCrane.package; + + wrappedTool = pkgs.runCommand "lzbt" + { + nativeBuildInputs = [ pkgs.makeWrapper ]; + } '' + mkdir -p $out/bin + + # Clean PATH to only contain what we need to do objcopy. Also + # tell lanzatool where to find our UEFI binaries. + makeWrapper ${tool}/bin/lzbt $out/bin/lzbt \ + --set PATH ${lib.makeBinPath [ pkgs.binutils-unwrapped pkgs.sbsigntool ]} \ + --set RUST_BACKTRACE full \ + --set LANZABOOTE_STUB ${stub}/bin/lanzaboote_stub.efi + ''; in { packages = { - inherit lanzaboote; - - lanzatool = pkgs.runCommand "lanzatool" - { - nativeBuildInputs = [ pkgs.makeWrapper ]; - } '' - mkdir -p $out/bin - - # Clean PATH to only contain what we need to do objcopy. Also - # tell lanzatool where to find our UEFI binaries. - makeWrapper ${lanzatool-unwrapped}/bin/lanzatool $out/bin/lanzatool \ - --set PATH ${lib.makeBinPath [ pkgs.binutils-unwrapped pkgs.sbsigntool ]} \ - --set RUST_BACKTRACE full \ - --set LANZABOOTE_STUB ${lanzaboote}/bin/lanzaboote.efi - ''; + inherit stub; + tool = wrappedTool; + lzbt = wrappedTool; }; overlayAttrs = { - inherit (config.packages) lanzatool; + inherit (config.packages) tool; }; checks = { - lanzatool-clippy = lanzatoolCrane.clippy; - lanzaboote-clippy = lanzabooteCrane.clippy; + toolClippy = toolCrane.clippy; + stubClippy = stubCrane.clippy; } // (import ./nix/tests/lanzaboote.nix { inherit pkgs testPkgs; lanzabooteModule = self.nixosModules.lanzaboote; @@ -193,8 +195,8 @@ ]; inputsFrom = [ - config.packages.lanzaboote - config.packages.lanzatool + config.packages.stub + config.packages.tool ]; TEST_SYSTEMD = pkgs.systemd; diff --git a/nix/modules/lanzaboote.nix b/nix/modules/lanzaboote.nix index 2f9105c..1ac03f2 100644 --- a/nix/modules/lanzaboote.nix +++ b/nix/modules/lanzaboote.nix @@ -39,8 +39,8 @@ in }; package = mkOption { type = types.package; - default = pkgs.lanzatool; - description = "Lanzatool package"; + default = pkgs.lzbt; + description = "Lanzaboote tool (lzbt) package"; }; }; @@ -58,7 +58,7 @@ in ${sbctlWithPki}/bin/sbctl enroll-keys --yes-this-might-brick-my-machine ''} - ${cfg.package}/bin/lanzatool install \ + ${cfg.package}/bin/lzbt install \ --public-key ${cfg.publicKeyFile} \ --private-key ${cfg.privateKeyFile} \ --configuration-limit ${toString configurationLimit} \ diff --git a/rust/stub/Cargo.lock b/rust/stub/Cargo.lock index 8d0a54c..015c4e3 100644 --- a/rust/stub/Cargo.lock +++ b/rust/stub/Cargo.lock @@ -86,7 +86,7 @@ dependencies = [ ] [[package]] -name = "lanzaboote" +name = "lanzaboote_stub" version = "0.1.0" dependencies = [ "ed25519-compact", diff --git a/rust/stub/Cargo.toml b/rust/stub/Cargo.toml index e3fb344..c0b96aa 100644 --- a/rust/stub/Cargo.toml +++ b/rust/stub/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "lanzaboote" +name = "lanzaboote_stub" version = "0.1.0" edition = "2021" publish = false diff --git a/rust/tool/Cargo.lock b/rust/tool/Cargo.lock index 4dd43d1..213b9f7 100644 --- a/rust/tool/Cargo.lock +++ b/rust/tool/Cargo.lock @@ -274,7 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] -name = "lanzatool" +name = "lanzaboote_tool" version = "0.1.0" dependencies = [ "anyhow", diff --git a/rust/tool/Cargo.toml b/rust/tool/Cargo.toml index a5a189e..864accf 100644 --- a/rust/tool/Cargo.toml +++ b/rust/tool/Cargo.toml @@ -1,8 +1,12 @@ [package] -name = "lanzatool" +name = "lanzaboote_tool" version = "0.1.0" edition = "2021" +[[bin]] +name = "lzbt" +path = "src/main.rs" + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/rust/tool/tests/common/mod.rs b/rust/tool/tests/common/mod.rs index 71a7cde..42ad44a 100644 --- a/rust/tool/tests/common/mod.rs +++ b/rust/tool/tests/common/mod.rs @@ -110,7 +110,7 @@ pub fn lanzaboote_install( let test_systemd = systemd_location_from_env()?; let test_systemd_stub = format!("{test_systemd}/lib/systemd/boot/efi/linuxx64.efi.stub"); - let mut cmd = Command::cargo_bin("lanzatool")?; + let mut cmd = Command::cargo_bin("lzbt")?; let output = cmd .env("LANZABOOTE_STUB", test_systemd_stub) .arg("install")