Skip to content

Commit

Permalink
flake: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol authored and nikstur committed Feb 18, 2024
1 parent 301f287 commit 27fd291
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 90 deletions.
19 changes: 11 additions & 8 deletions flake.lock

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

160 changes: 78 additions & 82 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

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

flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};

flake-compat = {
url = "github:edolstra/flake-compat";
Expand Down Expand Up @@ -39,107 +44,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 27fd291

Please sign in to comment.