-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project: move to nixpkgs Rust infrastructure
This builds the stub and tool using `rustPlatform.buildRustPackage` which features a stable Rust compiler, recent enough to support UEFI targets. In the future, it will rely on properly defined targets for UEFI in nixpkgs.
- Loading branch information
1 parent
f641dcf
commit 5ddb719
Showing
6 changed files
with
152 additions
and
190 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ rustPlatform, clippy, rustfmt, stdenv, lib, runCommand, enableFmt ? false, enableLint ? false }: | ||
|
||
rustPlatform.buildRustPackage | ||
({ | ||
pname = "lanzastub"; | ||
version = "0.3.0"; | ||
src = runCommand "src" { } '' | ||
install -D ${../../rust/stub/Cargo.toml} $out/Cargo.toml | ||
install -D ${../../rust/stub/Cargo.lock} $out/Cargo.lock | ||
cp -r ${../../rust/stub/src} $out/src | ||
''; | ||
|
||
nativeBuildInputs = lib.optional enableLint clippy ++ lib.optional enableFmt rustfmt; | ||
|
||
cargoLock = { | ||
lockFile = ../../rust/stub/Cargo.lock; | ||
}; | ||
|
||
# Necessary because our `cc-wrapper` doesn't understand MSVC link options. | ||
RUSTFLAGS = "-Clinker=${stdenv.cc.bintools}/bin/${stdenv.cc.targetPrefix}ld.lld -Clinker-flavor=lld-link"; | ||
# Necessary because otherwise we will get (useless) hardening options in front of | ||
# -flavor link which will break the whole command-line processing for the ld.lld linker. | ||
hardeningDisable = [ "all" ]; | ||
|
||
meta = with lib; { | ||
description = "Lanzaboote UEFI stub for SecureBoot enablement on NixOS systems"; | ||
homepage = "https://github.com/nix-community/lanzaboote"; | ||
license = licenses.mit; | ||
platforms = [ "x86_64-windows" "aarch64-windows" "i686-windows" ]; | ||
}; | ||
} // lib.optionalAttrs enableLint { | ||
buildPhase = '' | ||
cargo clippy --all-targets --all-features -- -D warnings | ||
if grep -R 'dbg!' ./src; then | ||
echo "use of dbg macro found in code!" | ||
false | ||
fi | ||
''; | ||
|
||
installPhase = '' | ||
touch $out | ||
''; | ||
} // (lib.optionalAttrs enableFmt { | ||
buildPhase = '' | ||
echo "checking formatting..." | ||
cargo fmt --all -- --check | ||
''; | ||
|
||
installPhase = '' | ||
touch $out | ||
''; | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ stdenv | ||
, systemd | ||
, binutils-unwrapped | ||
, sbsigntool | ||
, rustPlatform | ||
, lib | ||
, runCommand | ||
, fetchurl | ||
, clippy | ||
, rustfmt | ||
, path | ||
, enableLint ? false | ||
, enableFmt ? false | ||
}: | ||
rustPlatform.buildRustPackage | ||
({ | ||
pname = "lanzatool"; | ||
version = "0.3.0"; | ||
src = runCommand "src" { } '' | ||
install -D ${../../rust/tool/Cargo.toml} $out/Cargo.toml | ||
install -D ${../../rust/tool/Cargo.lock} $out/Cargo.lock | ||
cp -r ${../../rust/tool/src} $out/src | ||
''; | ||
|
||
TEST_SYSTEMD = systemd; | ||
|
||
nativeBuildInputs = lib.optional enableLint clippy ++ lib.optional enableFmt rustfmt; | ||
|
||
cargoLock = { | ||
lockFile = ../../rust/tool/Cargo.lock; | ||
}; | ||
|
||
nativeCheckInputs = [ | ||
binutils-unwrapped | ||
sbsigntool | ||
]; | ||
|
||
meta = with lib; { | ||
description = "Lanzaboote UEFI tooling for SecureBoot enablement on NixOS systems"; | ||
homepage = "https://github.com/nix-community/lanzaboote"; | ||
license = licenses.mit; | ||
}; | ||
} // lib.optionalAttrs enableLint { | ||
doCheck = false; | ||
buildPhase = '' | ||
cargo clippy --all-targets --all-features -- -D warnings | ||
if grep -R 'dbg!' ./src; then | ||
echo "use of dbg macro found in code!" | ||
false | ||
fi | ||
''; | ||
|
||
installPhase = '' | ||
touch $out | ||
''; | ||
} // lib.optionalAttrs enableFmt { | ||
doCheck = false; | ||
|
||
buildPhase = '' | ||
echo "checking formatting..." | ||
cargo fmt --all -- --check | ||
''; | ||
|
||
installPhase = '' | ||
touch $out | ||
''; | ||
}) |
Oops, something went wrong.