Merge pull request #52 from nix-community/pre-commit
Switch to flake-parts
This commit is contained in:
commit
16d40d702d
55
flake.lock
55
flake.lock
|
@ -14,11 +14,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1670900067,
|
"lastModified": 1673056065,
|
||||||
"narHash": "sha256-VXVa+KBfukhmWizaiGiHRVX/fuk66P8dgSFfkVN4/MY=",
|
"narHash": "sha256-a68tMDTDqdAauxq377ALl4Uwm6oh9MeoY2WbTYRWZoo=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "59b31b41a589c0a65e4a1f86b0e5eac68081468b",
|
"rev": "0144134311767fcee80213321f079a8ffa0b9cc1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -59,6 +59,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673047662,
|
||||||
|
"narHash": "sha256-dXYxH/0Ea5oQSkGAWWNy7HzmFutguycDGn2dt6lTYRQ=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "aa1f6ca773b6e740037ebfb35f7010e0c3960638",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1667395993,
|
||||||
|
@ -76,11 +94,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671755972,
|
"lastModified": 1673039641,
|
||||||
"narHash": "sha256-X977apvpqBqqRf2XBNorfunZmQNn3cQYGEnQE4L90Fo=",
|
"narHash": "sha256-Bc9FVhyLxp2mX2SXr0N4Fj4St7o4yaYEXpd12etSNBY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e8ee153b1717dca9c6aa38d5cf198329480d5b41",
|
"rev": "d9f73e41fd3c8e85b266bdb91cb7535600010798",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -90,6 +108,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1672350804,
|
||||||
|
"narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs-test": {
|
"nixpkgs-test": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671812130,
|
"lastModified": 1671812130,
|
||||||
|
@ -110,6 +146,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"flake-compat": "flake-compat_2",
|
"flake-compat": "flake-compat_2",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-test": "nixpkgs-test",
|
"nixpkgs-test": "nixpkgs-test",
|
||||||
|
@ -126,11 +163,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671243596,
|
"lastModified": 1673058265,
|
||||||
"narHash": "sha256-vQ1q6uwx2gKsHbQVhkq17nT8HwUmRbIG8cJVFafNb5s=",
|
"narHash": "sha256-FFigGHIO9BQeIIKjH5dcpB+ey5CSgfy47wHPGeOhCps=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "905db21103d646ddc1eb81920e05180e6e2b6734",
|
"rev": "802ff3314663ec7114f29a6e8b200dfc892023f8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
87
flake.nix
87
flake.nix
|
@ -5,6 +5,12 @@
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
||||||
nixpkgs-test.url = "github:RaitoBezarius/nixpkgs/simplified-qemu-boot-disks";
|
nixpkgs-test.url = "github:RaitoBezarius/nixpkgs/simplified-qemu-boot-disks";
|
||||||
|
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
|
# We only have this input to pass it to other dependencies and
|
||||||
|
# avoid having mulitple versions in our dependencies.
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
crane = {
|
crane = {
|
||||||
url = "github:ipetkov/crane";
|
url = "github:ipetkov/crane";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
@ -22,13 +28,35 @@
|
||||||
url = "github:edolstra/flake-compat";
|
url = "github:edolstra/flake-compat";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nixpkgs-test, crane, rust-overlay, ... }:
|
outputs = inputs@{ self, nixpkgs, nixpkgs-test, crane, rust-overlay, flake-parts, ... }:
|
||||||
let
|
flake-parts.lib.mkFlake { inherit inputs; } ({ moduleWithSystem, ... }: {
|
||||||
|
imports = [
|
||||||
|
# Derive the output overlay automatically from all packages that we define.
|
||||||
|
inputs.flake-parts.flakeModules.easyOverlay
|
||||||
|
];
|
||||||
|
|
||||||
|
flake.nixosModules.lanzaboote = moduleWithSystem (
|
||||||
|
perSystem@{ config }:
|
||||||
|
{ ... }: {
|
||||||
|
imports = [
|
||||||
|
./nix/modules/lanzaboote.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.lanzaboote.package = perSystem.config.packages.lanzatool;
|
||||||
|
});
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
|
||||||
|
# Not actively tested, but may work:
|
||||||
|
# "aarch64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem = { config, system, pkgs, ... }: let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
system = "x86_64-linux";
|
system = system;
|
||||||
overlays = [
|
overlays = [
|
||||||
rust-overlay.overlays.default
|
rust-overlay.overlays.default
|
||||||
];
|
];
|
||||||
|
@ -41,10 +69,6 @@
|
||||||
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;
|
||||||
|
|
||||||
uefi-run = pkgs.callPackage ./nix/packages/uefi-run.nix {
|
|
||||||
inherit craneLib;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Build attributes for a Rust application.
|
# Build attributes for a Rust application.
|
||||||
buildRustApp =
|
buildRustApp =
|
||||||
{ src
|
{ src
|
||||||
|
@ -92,9 +116,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
lanzatool-unwrapped = lanzatoolCrane.package;
|
lanzatool-unwrapped = lanzatoolCrane.package;
|
||||||
|
in {
|
||||||
|
packages = {
|
||||||
|
inherit lanzaboote;
|
||||||
|
|
||||||
lanzatool = pkgs.runCommand "lanzatool"
|
lanzatool = pkgs.runCommand "lanzatool" {
|
||||||
{
|
|
||||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
@ -106,24 +132,26 @@
|
||||||
--set RUST_BACKTRACE full \
|
--set RUST_BACKTRACE full \
|
||||||
--set LANZABOOTE_STUB ${lanzaboote}/bin/lanzaboote.efi
|
--set LANZABOOTE_STUB ${lanzaboote}/bin/lanzaboote.efi
|
||||||
'';
|
'';
|
||||||
in
|
|
||||||
{
|
|
||||||
overlays.default = final: prev: {
|
|
||||||
inherit lanzatool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules.lanzaboote = { pkgs, lib, ... }: {
|
overlayAttrs = {
|
||||||
imports = [ ./nix/modules/lanzaboote.nix ];
|
inherit (config.packages) lanzatool;
|
||||||
boot.lanzaboote.package = lib.mkDefault self.packages.${pkgs.system}.lanzatool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.x86_64-linux = {
|
checks = {
|
||||||
inherit lanzaboote lanzatool;
|
lanzatool-clippy = lanzatoolCrane.clippy;
|
||||||
default = lanzatool;
|
lanzaboote-clippy = lanzabooteCrane.clippy;
|
||||||
};
|
} // (import ./nix/tests/lanzaboote.nix {
|
||||||
|
inherit pkgs testPkgs;
|
||||||
|
lanzabooteModule = self.nixosModules.lanzaboote;
|
||||||
|
});
|
||||||
|
|
||||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = [
|
packages = let
|
||||||
|
uefi-run = pkgs.callPackage ./nix/packages/uefi-run.nix {
|
||||||
|
inherit craneLib;
|
||||||
|
};
|
||||||
|
in [
|
||||||
uefi-run
|
uefi-run
|
||||||
pkgs.openssl
|
pkgs.openssl
|
||||||
(pkgs.sbctl.override {
|
(pkgs.sbctl.override {
|
||||||
|
@ -138,19 +166,12 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
inputsFrom = [
|
inputsFrom = [
|
||||||
lanzaboote
|
config.packages.lanzaboote
|
||||||
lanzatool
|
config.packages.lanzatool
|
||||||
];
|
];
|
||||||
|
|
||||||
TEST_SYSTEMD = pkgs.systemd;
|
TEST_SYSTEMD = pkgs.systemd;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks.x86_64-linux = {
|
|
||||||
lanzatool-clippy = lanzatoolCrane.clippy;
|
|
||||||
lanzaboote-clippy = lanzabooteCrane.clippy;
|
|
||||||
} // (import ./nix/tests/lanzaboote.nix {
|
|
||||||
inherit pkgs testPkgs;
|
|
||||||
lanzabooteModule = self.nixosModules.lanzaboote;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue