Skip to content

Commit

Permalink
Merge pull request #34 from nix-community/configuration-limit
Browse files Browse the repository at this point in the history
Lanzatool: respect configuration limit
  • Loading branch information
nikstur authored Jan 1, 2023
2 parents e439cf4 + d3a96b1 commit f431622
Show file tree
Hide file tree
Showing 14 changed files with 778 additions and 44 deletions.
17 changes: 13 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
{ src
, target ? null
, doCheck ? true
, extraArgs ? { }
}:
let
cleanedSrc = craneLib.cleanCargoSource src;
commonArgs = {
src = cleanedSrc;
inherit src;
CARGO_BUILD_TARGET = target;
inherit doCheck;
};
} // extraArgs;

cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
Expand All @@ -73,7 +73,7 @@
};

lanzabooteCrane = buildRustApp {
src = ./rust/lanzaboote;
src = craneLib.cleanCargoSource ./rust/lanzaboote;
target = "x86_64-unknown-uefi";
doCheck = false;
};
Expand All @@ -82,6 +82,13 @@

lanzatoolCrane = buildRustApp {
src = ./rust/lanzatool;
extraArgs = {
TEST_SYSTEMD = pkgs.systemd;
checkInputs = with pkgs; [
binutils-unwrapped
sbsigntool
];
};
};

lanzatool-unwrapped = lanzatoolCrane.package;
Expand Down Expand Up @@ -134,6 +141,8 @@
lanzaboote
lanzatool
];

TEST_SYSTEMD = pkgs.systemd;
};

checks.x86_64-linux = {
Expand Down
14 changes: 14 additions & 0 deletions nix/modules/lanzaboote.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ let
sbctlWithPki = pkgs.sbctl.override {
databasePath = "/tmp/pki";
};

configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit;
in
{
options.boot.lanzaboote = {
enable = mkEnableOption "Enable the LANZABOOTE";
enrollKeys = mkEnableOption "Automatic enrollment of the keys using sbctl";
configurationLimit = mkOption {
default = null;
example = 120;
type = types.nullOr types.int;
description = lib.mdDoc ''
Maximum number of latest generations in the boot menu.
Useful to prevent boot partition running out of disk space.
`null` means no limit i.e. all generations
that were not garbage collected yet.
'';
};
pkiBundle = mkOption {
type = types.nullOr types.path;
description = "PKI bundle containg db, PK, KEK";
Expand Down Expand Up @@ -49,6 +62,7 @@ in
${cfg.package}/bin/lanzatool install \
--public-key ${cfg.publicKeyFile} \
--private-key ${cfg.privateKeyFile} \
--configuration-limit ${toString configurationLimit} \
${config.boot.loader.efi.efiSysMountPoint} \
/nix/var/nix/profiles/system-*-link
'';
Expand Down
183 changes: 183 additions & 0 deletions rust/lanzatool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rust/lanzatool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ tempfile = "3.3.0"
blake3 = "1.3.3"
# TODO: wait for a upstream release and pin it.
bootspec = { git = "https://github.com/DeterminateSystems/bootspec" }
walkdir = "2.3.2"

[dev-dependencies]
assert_cmd = "2.0.7"
rand = "0.8.5"
Loading

0 comments on commit f431622

Please sign in to comment.