diff --git a/flake.lock b/flake.lock index 5c89721..18bd6c2 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1707075082, - "narHash": "sha256-PUplk5F5jlIyofxqn/xEDN9pbjrd0tnkd0pDsZ52db0=", + "lastModified": 1707461758, + "narHash": "sha256-VaqINICYEtVKF0X+chdNtXcNp6poZr385v6AG7j0ybM=", "owner": "ipetkov", "repo": "crane", - "rev": "7d5b46c17d857ee9ddb2e8d88185729a3e5637b6", + "rev": "505976eaeac289fe41d074bee37006ac094636bb", "type": "github" }, "original": { @@ -21,26 +21,23 @@ } }, "flake-compat": { - "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", + "lastModified": 1688025799, + "narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=", + "owner": "nix-community", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c", "type": "github" }, "original": { - "owner": "edolstra", + "owner": "nix-community", "repo": "flake-compat", "type": "github" } }, "flake-parts": { "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { "lastModified": 1706830856, @@ -51,9 +48,8 @@ "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" + "id": "flake-parts", + "type": "indirect" } }, "flake-utils": { @@ -97,11 +93,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1706913249, - "narHash": "sha256-x3M7iV++CsvRXI1fpyFPduGELUckZEhSv0XWnUopAG8=", + "lastModified": 1707268954, + "narHash": "sha256-2en1kvde3cJVc3ZnTy8QeD2oKcseLFjYPLKhIGDanQ0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e92b6015881907e698782c77641aa49298330223", + "rev": "f8e2ebd66d097614d51a56a755450d4ae1632df1", "type": "github" }, "original": { @@ -111,6 +107,24 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1704874635, @@ -142,11 +156,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1706424699, - "narHash": "sha256-Q3RBuOpZNH2eFA1e+IHgZLAOqDD9SKhJ/sszrL8bQD4=", + "lastModified": 1707297608, + "narHash": "sha256-ADjo/5VySGlvtCW3qR+vdFF4xM9kJFlRDqcC9ZGI8EA=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7c54e08a689b53c8a1e5d70169f2ec9e2a68ffaf", + "rev": "0db2e67ee49910adfa13010e7f012149660af7f0", "type": "github" }, "original": { @@ -163,7 +177,8 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "pre-commit-hooks-nix": "pre-commit-hooks-nix", - "rust-overlay": "rust-overlay" + "rust-overlay": "rust-overlay", + "systems": "systems_2" } }, "rust-overlay": { @@ -176,11 +191,11 @@ ] }, "locked": { - "lastModified": 1707012820, - "narHash": "sha256-4cxIaHUx6/DSEVHJfK0gx4DZkJ5xHugan27KfuVPnj0=", + "lastModified": 1707444620, + "narHash": "sha256-P8kRkiJLFttN+hbAOlm11wPxUrQZqKle+QtVCqFiGXY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b83b8c3ef16d15a4ae3843d74f32dfc86caed60f", + "rev": "78503e9199010a4df714f29a4f9c00eb2ccae071", "type": "github" }, "original": { @@ -203,6 +218,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4b9ccb9..b2c5085 100644 --- a/flake.nix +++ b/flake.nix @@ -2,32 +2,19 @@ description = "Nix CycloneDX Software Bills of Materials (SBOMs)"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - + flake-compat.url = "github:nix-community/flake-compat"; + systems.url = "github:nix-systems/default"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; - crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; - pre-commit-hooks-nix = { url = "github:cachix/pre-commit-hooks.nix"; inputs = { @@ -36,110 +23,100 @@ flake-compat.follows = "flake-compat"; }; }; - }; - outputs = inputs@{ self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } (_: - let - # This is effectively just boilerplate to allow us to keep the `lib` - # output. - libOutputModule = { lib, ... }: flake-parts.lib.mkTransposedPerSystemModule { - name = "lib"; - option = lib.mkOption { - type = lib.types.lazyAttrsOf lib.types.anything; - default = { }; + outputs = inputs@{ self, flake-parts, systems, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + systems = import systems; + + imports = + let + # This is effectively just boilerplate to allow us to keep the `lib` + # output. + libOutputModule = { lib, ... }: flake-parts.lib.mkTransposedPerSystemModule { + name = "lib"; + option = lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.anything; + default = { }; + }; + file = ""; }; - file = ""; - }; - in - { - - imports = [ + in + [ inputs.pre-commit-hooks-nix.flakeModule libOutputModule ]; - flake = { - templates.default = { - path = builtins.filterSource (path: type: baseNameOf path == "flake.nix") - ./examples/flakes; - description = "Build a Bom for GNU hello"; - }; + flake = { + templates.default = { + path = builtins.filterSource (path: type: baseNameOf path == "flake.nix") + ./examples/flakes; + description = "Build a Bom for GNU hello"; }; + }; - systems = [ - "x86_64-linux" - "aarch64-linux" - - "x86_64-darwin" - "aarch64-darwin" - ]; - - perSystem = { config, system, ... }: - let - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; - - rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./transformer/rust-toolchain.toml; - craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolChain; + perSystem = { config, system, pkgs, lib, ... }: + let + rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./transformer/rust-toolchain.toml; + craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolChain; - # Include the Git commit hash as the version of bombon in generated Boms - GIT_COMMIT = pkgs.lib.optionalString (self ? rev) self.rev; + # Include the Git commit hash as the version of bombon in generated Boms + GIT_COMMIT = lib.optionalString (self ? rev) self.rev; - commonArgs = { - src = craneLib.cleanCargoSource ./transformer; - inherit GIT_COMMIT; - }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - transformer = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); + commonArgs = { + src = craneLib.cleanCargoSource ./transformer; + inherit GIT_COMMIT; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + transformer = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); - buildBom = pkgs.callPackage ./build-bom.nix { - inherit transformer; - buildtimeDependencies = pkgs.callPackage ./buildtime-dependencies.nix { }; - runtimeDependencies = pkgs.callPackage ./runtime-dependencies.nix { }; - }; - in - { + buildBom = pkgs.callPackage ./build-bom.nix { + inherit transformer; + buildtimeDependencies = pkgs.callPackage ./buildtime-dependencies.nix { }; + runtimeDependencies = pkgs.callPackage ./runtime-dependencies.nix { }; + }; + in + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; - lib = { inherit buildBom; }; + lib = { inherit buildBom; }; - packages = { - # This is mostly here for development - inherit transformer; - default = transformer; - }; - - checks = { - clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; }); - rustfmt = craneLib.cargoFmt (commonArgs // { inherit cargoArtifacts; }); - } // import ./tests { inherit pkgs buildBom; }; + packages = { + # This is mostly here for development + inherit transformer; + default = transformer; + }; - pre-commit = { - check.enable = true; + checks = { + clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; }); + rustfmt = craneLib.cargoFmt (commonArgs // { inherit cargoArtifacts; }); + } // import ./tests { inherit pkgs buildBom; }; - settings = { - hooks = { - nixpkgs-fmt.enable = true; - typos.enable = true; - }; + pre-commit = { + check.enable = true; - settings.statix.ignore = [ "sources.nix" ]; + settings = { + hooks = { + nixpkgs-fmt.enable = true; + typos.enable = true; }; + settings.statix.ignore = [ "sources.nix" ]; }; + }; - devShells.default = pkgs.mkShell { - shellHook = '' - ${config.pre-commit.installationScript} - ''; - - inputsFrom = [ transformer ]; + devShells.default = pkgs.mkShell { + shellHook = '' + ${config.pre-commit.installationScript} + ''; - inherit GIT_COMMIT; - }; + inputsFrom = [ transformer ]; + inherit GIT_COMMIT; }; - }); + + }; + }; }