Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake: minor changes #69

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

drupol marked this conversation as resolved.
Show resolved Hide resolved
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;
};
});

};
};
}
Loading