-
-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathflake.nix
More file actions
84 lines (71 loc) · 2.36 KB
/
Copy pathflake.nix
File metadata and controls
84 lines (71 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
description = "Copy/paste detector — fast Rust-based CLI for code duplication detection";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, fenix, crane, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./rust/rust-toolchain.toml;
sha256 = "sha256-SBKjxhC6zHTu0SyJwxLlQHItzMzYZ71VCWQC2hOzpRY=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = pkgs.lib.cleanSourceWith {
src = ./rust;
filter = path: type:
(craneLib.filterCargoSources path type) ||
(pkgs.lib.hasSuffix ".html" path && pkgs.lib.hasInfix "/templates/" path);
};
commonArgs = {
inherit src;
pname = "jscpd";
version = (craneLib.crateNameFromCargoToml { cargoToml = ./rust/crates/cpd/Cargo.toml; }).version;
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.apple-sdk
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
jscpd = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = false;
meta = {
description = "Copy/paste detector for programming source code";
homepage = "https://jscpd.dev";
license = pkgs.lib.licenses.mit;
mainProgram = "jscpd";
};
});
in
{
packages = {
inherit jscpd;
default = jscpd;
};
checks = {
jscpd-tests = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
cargoExtraArgs = "--lib -p cpd-core -p cpd-tokenizer -p cpd-reporter";
});
};
devShells.default = craneLib.devShell (commonArgs // {
packages = with pkgs; [
cargo-nextest
cargo-deny
pkg-config
];
});
}
);
}