Skip to content

Commit

Permalink
Merge pull request #2 from ipetkov/cleanup
Browse files Browse the repository at this point in the history
Misc cleanup and updates
  • Loading branch information
ipetkov authored Jan 31, 2022
2 parents 492076c + 07f9676 commit 36c1236
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 29 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.2.0] - 2022-01-30

### Added
* Support for alternative cargo registries

### Changed
* `urlForCargoPackage` now takes configured registries into account when
downloading crate sources
* **Breaking**: `vendorCargoDeps` now vendors each unique registry as a subdirectory within
the derivation's output. A `config.toml` file is also placed at the output
root which contains the necessary configurations to point cargo at the
vendored sources.
* `configureCargoVendoredDepsHook` is now aware of the updated `vendorCargoDeps`
output format, and will use the `config.toml` file it generates if it is
present. Otherwise it will fall back to the previous behavior (which is treat
the entire directory as only vendoring crates.io).
* Source vendoring now uses `runCommandLocal` (instead of `runCommand`) to
reduce network pressure in trying to fetch results which can quickly be built
locally
* Searching for `Cargo.toml` or `.cargo/config.toml` files is now done more
efficiently

## 0.1.0 - 2022-01-22
- First release

[0.2.0]: https://github.com/ipetkov/crane/compare/v0.1.0...v0.2.0
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ the ability to enforce a strict build order. However, we can easily change our
mind, which would be much more difficult if we had written everything as one
giant derivation.

## Compatibility Policy

Breaking changes can land on the `master` branch at any time, so it is
recommended you use a versioning strategy when consuming this library (for
example, using something like flakes or [niv]).

Tagged releases will be cut periodically and changes will be documented in the
[CHANGELOG]. Release versions will follow [Semantic Versioning].

The test suite is run against the latest stable nixpkgs release, as well as
`nixpkgs-unstable`. Any breakage on those channels is considered a bug and
should be reported as such.

## FAQs

### I want to use a custom version of nixpkgs or another specific system
Expand Down Expand Up @@ -312,5 +325,8 @@ for inclusion by you, shall be licensed as MIT, without any additional terms or
conditions.

[API docs]: ./docs/API.md
[CHANGELOG]: ./CHANGELOG.md
[custom-toolchain]: ./examples/custom-toolchain/flake.nix
[MIT license]: ./LICENSE
[niv]: https://github.com/nmattia/niv
[Semantic Versioning]: http://semver.org/spec/v2.0.0.html
4 changes: 2 additions & 2 deletions checks/cleanCargoTomlTests/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ cleanCargoToml
, linkFarmFromDrvs
, runCommand
, runCommandLocal
, writeTOML
}:

Expand All @@ -13,7 +13,7 @@ let
cleanedToml = writeTOML "cleaned.toml" cleaned;
expected = path + /expected.toml;
in
runCommand "compare-${name}" { } ''
runCommandLocal "compare-${name}" { } ''
diff ${expected} ${cleanedToml}
touch $out
'';
Expand Down
4 changes: 2 additions & 2 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
CARGO_TARGET_DIR = "some/nested/custom-cargo-dir";
});
in
pkgs.runCommand "smoke-simple" { } ''
pkgs.runCommandLocal "smoke-simple" { } ''
# does it run?
${simple}/bin/simple
touch $out
Expand All @@ -68,7 +68,7 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
cargoArtifacts = null;
};

manyLibsInstalledAsExpected = pkgs.runCommand "manyLibsInstalledAsExpected" { } ''
manyLibsInstalledAsExpected = pkgs.runCommandLocal "manyLibsInstalledAsExpected" { } ''
cat >expected <<EOF
liball_types.a
liball_types.so
Expand Down
4 changes: 2 additions & 2 deletions checks/features/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, compilesFresh
, lib
, linkFarmFromDrvs
, runCommand
, runCommandLocal
}:

let
Expand All @@ -21,7 +21,7 @@ let
pname = "${pname}CompilesFresh";
})

(runCommand "${pname}Run" { } ''
(runCommandLocal "${pname}Run" { } ''
[[ "hello${runResult}" == "$(${crate}/bin/features)" ]]
touch $out
'')
Expand Down
4 changes: 2 additions & 2 deletions checks/features/features/Cargo.lock

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

4 changes: 2 additions & 2 deletions checks/mkDummySrcTests/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ linkFarmFromDrvs
, mkDummySrc
, runCommand
, runCommandLocal
}:

let
Expand All @@ -10,7 +10,7 @@ let
src = path + /input;
};
in
runCommand "compare-${name}" { } ''
runCommandLocal "compare-${name}" { } ''
diff -r ${path + /expected} ${dummySrc}
touch $out
'';
Expand Down
4 changes: 2 additions & 2 deletions checks/nixpkgs-fmt.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{ lib
, nixpkgs-fmt
, runCommand
, runCommandLocal
}:

let
cleaned = lib.cleanSource ./..;
nixOnly = lib.sourceFilesBySuffices cleaned [ ".nix" ];
in
runCommand "nixpkgs-fmt"
runCommandLocal "nixpkgs-fmt"
{
nativeBuildInputs = [ nixpkgs-fmt ];
} ''
Expand Down
4 changes: 2 additions & 2 deletions checks/smoke.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{ runCommand
{ runCommandLocal
}:

bins: drv:
let
testList = map (b: "${drv}/bin/${b}") bins;
tests = builtins.concatStringsSep "\n" testList;
in
runCommand "smoke-${drv.name}" { } ''
runCommandLocal "smoke-${drv.name}" { } ''
# does it run?
${tests}
touch $out
Expand Down
12 changes: 6 additions & 6 deletions examples/alt-registry/Cargo.lock

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

2 changes: 1 addition & 1 deletion examples/quick-start-simple/Cargo.lock

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

2 changes: 1 addition & 1 deletion examples/quick-start/Cargo.lock

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

6 changes: 3 additions & 3 deletions flake.lock

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

4 changes: 2 additions & 2 deletions lib/downloadCargoPackage.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ fetchurl
, urlForCargoPackage
, runCommand
, runCommandLocal
}:

{ name
Expand All @@ -16,7 +16,7 @@ let
url = urlForCargoPackage args;
};
in
runCommand "cargo-package-${name}-${version}" { } ''
runCommandLocal "cargo-package-${name}-${version}" { } ''
mkdir -p $out
tar -xzf ${tarball} -C $out --strip-components=1
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
Expand Down
4 changes: 2 additions & 2 deletions lib/mkDummySrc.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ cleanCargoToml
, findCargoFiles
, lib
, runCommand
, runCommandLocal
, writeText
, writeTOML
}:
Expand Down Expand Up @@ -99,7 +99,7 @@ let
then "cp ${cargoLock} $out/Cargo.lock"
else "echo could not find Cargo.lock at src root";
in
runCommand "dummy-src" { } ''
runCommandLocal "dummy-src" { } ''
mkdir -p $out
${copyCargoLock}
${copyAllCargoConfigs}
Expand Down

0 comments on commit 36c1236

Please sign in to comment.