Skip to content

Commit

Permalink
treewide: remove crane
Browse files Browse the repository at this point in the history
  • Loading branch information
nikstur committed Feb 29, 2024
1 parent e651701 commit c52ab04
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 70 deletions.
68 changes: 22 additions & 46 deletions flake.lock

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

47 changes: 26 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
inputs.nixpkgs-lib.follows = "nixpkgs";
};

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 = {
Expand All @@ -42,6 +31,11 @@
};
};

gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

};

outputs = inputs@{ self, flake-parts, systems, ... }: flake-parts.lib.mkFlake { inherit inputs; } {
Expand Down Expand Up @@ -75,18 +69,12 @@

perSystem = { config, system, pkgs, lib, ... }:
let
rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./rust/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 = lib.optionalString (self ? rev) self.rev;

commonArgs = {
src = craneLib.cleanCargoSource ./rust/transformer;
transformer = pkgs.callPackage ./nix/packages/transformer.nix {
inherit GIT_COMMIT;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
transformer = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });

buildBom = pkgs.callPackage ./nix/build-bom.nix {
inherit transformer;
Expand All @@ -97,7 +85,11 @@
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
overlays = [
(_final: _prev: {
inherit (inputs.gitignore.lib) gitignoreSource;
})
];
};

lib = { inherit buildBom; };
Expand All @@ -109,8 +101,14 @@
};

checks = {
clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; });
rustfmt = craneLib.cargoFmt (commonArgs // { inherit cargoArtifacts; });
clippy = transformer.overrideAttrs (_: previousAttrs: {
nativeCheckInputs = (previousAttrs.nativeCheckInputs or [ ]) ++ [ pkgs.clippy ];
checkPhase = "cargo clippy";
});
rustfmt = transformer.overrideAttrs (_: previousAttrs: {
nativeCheckInputs = (previousAttrs.nativeCheckInputs or [ ]) ++ [ pkgs.rustfmt ];
checkPhase = "cargo fmt --check";
});
} // import ./nix/tests { inherit pkgs buildBom; };

pre-commit = {
Expand All @@ -131,8 +129,15 @@
${config.pre-commit.installationScript}
'';

packages = [
pkgs.clippy
pkgs.rustfmt
];

inputsFrom = [ transformer ];

RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

inherit GIT_COMMIT;
};

Expand Down
29 changes: 29 additions & 0 deletions nix/packages/transformer.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ lib
, rustPlatform
, gitignoreSource

, GIT_COMMIT
}:

rustPlatform.buildRustPackage {
pname = "bombon-transformer";
version = "0.1.0";

src = gitignoreSource ../../rust/transformer;

cargoLock = {
lockFile = ../../rust/transformer/Cargo.lock;
};

env = {
inherit GIT_COMMIT;
};

meta = with lib; {
homepage = "https://github.com/nikstur/bombon";
license = licenses.mit;
maintainers = with lib.maintainers; [ nikstur ];
mainProgram = "bombon-transformer";
};
}

3 changes: 0 additions & 3 deletions rust/transformer/rust-toolchain.toml

This file was deleted.

0 comments on commit c52ab04

Please sign in to comment.