Skip to content

Commit

Permalink
flake: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Feb 18, 2024
1 parent 301f287 commit bd5b563
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 109 deletions.
69 changes: 49 additions & 20 deletions flake.lock

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

163 changes: 74 additions & 89 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@

flake-utils.url = "github:numtide/flake-utils";

flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";

flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
systems.url = "github:nix-systems/default";

rust-overlay = {
url = "github:oxalica/rust-overlay";
Expand All @@ -39,107 +33,98 @@

};

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;

# Include the Git commit hash as the version of bombon in generated Boms
GIT_COMMIT = pkgs.lib.optionalString (self ? rev) self.rev;
perSystem = { config, system, pkgs, lib, ... }:
let
rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./transformer/rust-toolchain.toml;
craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolChain;

commonArgs = {
src = craneLib.cleanCargoSource ./transformer;
inherit GIT_COMMIT;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
transformer = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
# Include the Git commit hash as the version of bombon in generated Boms
GIT_COMMIT = lib.optionalString (self ? rev) self.rev;

buildBom = pkgs.callPackage ./build-bom.nix {
inherit transformer;
buildtimeDependencies = pkgs.callPackage ./buildtime-dependencies.nix { };
runtimeDependencies = pkgs.callPackage ./runtime-dependencies.nix { };
};
in
{
commonArgs = {
src = craneLib.cleanCargoSource ./transformer;
inherit GIT_COMMIT;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
transformer = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });

lib = { inherit buildBom; };
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) ];
};

packages = {
# This is mostly here for development
inherit transformer;
default = transformer;
};
lib = { inherit buildBom; };

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;
};
});

};
};
}

0 comments on commit bd5b563

Please sign in to comment.