flake: reformat to fit nixpkgs-fmt style

This commit is contained in:
Julian Stecklina 2023-01-08 14:42:30 +01:00
parent 74182c199a
commit 4f14ca0197
1 changed files with 115 additions and 109 deletions

224
flake.nix
View File

@ -54,7 +54,8 @@
]; ];
boot.lanzaboote.package = perSystem.config.packages.lanzatool; boot.lanzaboote.package = perSystem.config.packages.lanzatool;
}); }
);
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
@ -63,37 +64,38 @@
# "aarch64-linux" # "aarch64-linux"
]; ];
perSystem = { config, system, pkgs, ... }: let perSystem = { config, system, pkgs, ... }:
pkgs = import nixpkgs { let
system = system; pkgs = import nixpkgs {
overlays = [ system = system;
rust-overlay.overlays.default overlays = [
]; rust-overlay.overlays.default
}; ];
};
testPkgs = import nixpkgs-test { system = "x86_64-linux"; }; testPkgs = import nixpkgs-test { system = "x86_64-linux"; };
inherit (pkgs) lib; inherit (pkgs) lib;
rust-nightly = pkgs.rust-bin.fromRustupToolchainFile ./rust/lanzaboote/rust-toolchain.toml; rust-nightly = pkgs.rust-bin.fromRustupToolchainFile ./rust/lanzaboote/rust-toolchain.toml;
craneLib = crane.lib.x86_64-linux.overrideToolchain rust-nightly; craneLib = crane.lib.x86_64-linux.overrideToolchain rust-nightly;
# Build attributes for a Rust application. # Build attributes for a Rust application.
buildRustApp = buildRustApp =
{ src { src
, target ? null , target ? null
, doCheck ? true , doCheck ? true
, extraArgs ? { } , extraArgs ? { }
}: }:
let let
commonArgs = { commonArgs = {
inherit src; inherit src;
CARGO_BUILD_TARGET = target; CARGO_BUILD_TARGET = target;
inherit doCheck; inherit doCheck;
} // extraArgs; } // extraArgs;
cargoArtifacts = craneLib.buildDepsOnly commonArgs; cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in in
{ {
package = craneLib.buildPackage (commonArgs // { package = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts; inherit cargoArtifacts;
@ -105,94 +107,98 @@
}); });
}; };
lanzabooteCrane = buildRustApp { lanzabooteCrane = buildRustApp {
src = craneLib.cleanCargoSource ./rust/lanzaboote; src = craneLib.cleanCargoSource ./rust/lanzaboote;
target = "x86_64-unknown-uefi"; target = "x86_64-unknown-uefi";
doCheck = false; doCheck = false;
};
lanzaboote = lanzabooteCrane.package;
lanzatoolCrane = buildRustApp {
src = ./rust/lanzatool;
extraArgs = {
TEST_SYSTEMD = pkgs.systemd;
checkInputs = with pkgs; [
binutils-unwrapped
sbsigntool
];
}; };
};
lanzatool-unwrapped = lanzatoolCrane.package; lanzaboote = lanzabooteCrane.package;
in {
packages = {
inherit lanzaboote;
lanzatool = pkgs.runCommand "lanzatool" { lanzatoolCrane = buildRustApp {
nativeBuildInputs = [ pkgs.makeWrapper ]; src = ./rust/lanzatool;
} '' extraArgs = {
mkdir -p $out/bin TEST_SYSTEMD = pkgs.systemd;
checkInputs = with pkgs; [
# Clean PATH to only contain what we need to do objcopy. Also binutils-unwrapped
# tell lanzatool where to find our UEFI binaries. sbsigntool
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
'';
};
overlayAttrs = {
inherit (config.packages) lanzatool;
};
checks = {
lanzatool-clippy = lanzatoolCrane.clippy;
lanzaboote-clippy = lanzabooteCrane.clippy;
} // (import ./nix/tests/lanzaboote.nix {
inherit pkgs testPkgs;
lanzabooteModule = self.nixosModules.lanzaboote;
});
pre-commit = {
check.enable = true;
settings.hooks = {
nixpkgs-fmt.enable = true;
};
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
'';
packages = let
uefi-run = pkgs.callPackage ./nix/packages/uefi-run.nix {
inherit craneLib;
}; };
in [ };
uefi-run
pkgs.openssl
(pkgs.sbctl.override {
databasePath = "pki";
})
pkgs.sbsigntool
pkgs.efitools
pkgs.python39Packages.ovmfvartool
pkgs.qemu
pkgs.nixpkgs-fmt
pkgs.statix
];
inputsFrom = [ lanzatool-unwrapped = lanzatoolCrane.package;
config.packages.lanzaboote in
config.packages.lanzatool {
]; packages = {
inherit lanzaboote;
TEST_SYSTEMD = pkgs.systemd; 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
'';
};
overlayAttrs = {
inherit (config.packages) lanzatool;
};
checks = {
lanzatool-clippy = lanzatoolCrane.clippy;
lanzaboote-clippy = lanzabooteCrane.clippy;
} // (import ./nix/tests/lanzaboote.nix {
inherit pkgs testPkgs;
lanzabooteModule = self.nixosModules.lanzaboote;
});
pre-commit = {
check.enable = true;
settings.hooks = {
nixpkgs-fmt.enable = true;
};
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
'';
packages =
let
uefi-run = pkgs.callPackage ./nix/packages/uefi-run.nix {
inherit craneLib;
};
in
[
uefi-run
pkgs.openssl
(pkgs.sbctl.override {
databasePath = "pki";
})
pkgs.sbsigntool
pkgs.efitools
pkgs.python39Packages.ovmfvartool
pkgs.qemu
pkgs.nixpkgs-fmt
pkgs.statix
];
inputsFrom = [
config.packages.lanzaboote
config.packages.lanzatool
];
TEST_SYSTEMD = pkgs.systemd;
};
}; };
};
}); });
} }