FFFF nix and ci improvements by figsoda · Pull Request #677 · nix-community/nix-init · GitHub
[go: up one dir, main page]

Skip to content
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
21 changes: 7 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
nurl,
get-nix-license,
license-store-cache,
enableClippy ? false,
}:

rustPlatform.buildRustPackage rec {
pname = "nix-init";
inherit ((lib.importTOML ./Cargo.toml).workspace.package) version;

src = ./.;
src = lib.sourceByRegex ./. [
"(license-store-cache|src)(/.*)?"
"build.rs"
''Cargo\.(toml|lock)''
];

cargoLock = {
lockFile = ./Cargo.lock;
Expand All @@ -43,10 +46,8 @@ rustPlatform.buildRustPackage rec {

buildNoDefaultFeatures = true;

checkFlags = [
# requires internet access
"--skip=lang::rust::tests"
];
# lang::rust::tests needs additional cargo dependencies
doCheck = false;

postPatch = ''
mkdir -p data
Expand Down Expand Up @@ -79,11 +80,3 @@ rustPlatform.buildRustPackage rec {
maintainers = with lib.maintainers; [ figsoda ];
};
}
// lib.optionalAttrs enableClippy {
buildPhase = ''
cargo clippy --all-targets --all-features -- -D warnings
'';
installPhase = ''
touch $out
'';
}
46 changes: 45 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,51 @@
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
otherChecks = {
clippy = config.packages.nix-init.override { enableClippy = true; };
clippy = config.packages.nix-init.overrideAttrs (old: {
pname = "nix-init-clippy";

nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.clippy ];

buildPhase = ''
runHook preBuild
cargo clippy --target ${pkgs.stdenv.targetPlatform.rust.rustcTarget} \
--offline --no-default-features -- -D warnings
runHook postBuild
'';

installPhase = ''
touch $out
'';
});

tests = config.packages.nix-init.overrideAttrs {
pname = "nix-init-tests";

cargoDeps =
let
fixtures = ./src/lang/rust/fixtures;
in
pkgs.symlinkJoin {
name = "cargo-vendor-dir";
paths = lib.pipe fixtures [
builtins.readDir
lib.attrNames
(lib.filter (lib.hasSuffix "-lock.toml"))
(map (lib.path.append fixtures))
(lib.concat [ ./Cargo.lock ])
(map (lockFile: pkgs.rustPlatform.importCargoLock { inherit lockFile; }))
];
};

dontCargoBuild = true;

doCheck = true;
cargoCheckType = "debug";

installPhase = ''
touch $out
'';
};
};
in
packages // devShells // otherChecks;
Expand Down
11 changes: 10 additions & 1 deletion license-store-cache/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
rustPlatform,
spdx-license-list-data,
}:

rustPlatform.buildRustPackage {
pname = "license-store-cache";
inherit ((lib.importTOML ../Cargo.toml).workspace.package) version;

src = ../.;
src = lib.sourceByRegex ../. [
"(license-store-cache)(/.*)?"
''Cargo\.(toml|lock)''
];

cargoLock = {
lockFile = ../Cargo.lock;
Expand All @@ -17,6 +21,11 @@ rustPlatform.buildRustPackage {

cargoBuildFlags = [ "-p=license-store-cache" ];

postPatch = ''
mkdir src
touch src/main.rs
'';

postInstall = ''
cache=$(mktemp)
$out/bin/license-store-cache $cache ${spdx-license-list-data.json}/json/details
Expand Down
0