Merge pull request #2 from ipetkov/cleanup

Misc cleanup and updates
This commit is contained in:
Ivan Petkov 2022-01-31 00:33:22 +00:00 committed by GitHub
commit 36c1236333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 77 additions and 29 deletions

32
CHANGELOG.md Normal file
View File

@ -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

View File

@ -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
@ -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

View File

@ -1,6 +1,6 @@
{ cleanCargoToml
, linkFarmFromDrvs
, runCommand
, runCommandLocal
, writeTOML
}:
@ -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
'';

View File

@ -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
@ -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

View File

@ -2,7 +2,7 @@
, compilesFresh
, lib
, linkFarmFromDrvs
, runCommand
, runCommandLocal
}:
let
@ -21,7 +21,7 @@ let
pname = "${pname}CompilesFresh";
})
(runCommand "${pname}Run" { } ''
(runCommandLocal "${pname}Run" { } ''
[[ "hello${runResult}" == "$(${crate}/bin/features)" ]]
touch $out
'')

View File

@ -18,6 +18,6 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.112"
version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"

View File

@ -1,6 +1,6 @@
{ linkFarmFromDrvs
, mkDummySrc
, runCommand
, runCommandLocal
}:
let
@ -10,7 +10,7 @@ let
src = path + /input;
};
in
runCommand "compare-${name}" { } ''
runCommandLocal "compare-${name}" { } ''
diff -r ${path + /expected} ${dummySrc}
touch $out
'';

View File

@ -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 ];
} ''

View File

@ -1,4 +1,4 @@
{ runCommand
{ runCommandLocal
}:
bins: drv:
@ -6,7 +6,7 @@ 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

View File

@ -417,9 +417,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.114"
version = "0.2.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0005d08a8f7b65fb8073cb697aa0b12b631ed251ce73d862ce50eeb52ce3b50"
checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
[[package]]
name = "log"
@ -715,9 +715,9 @@ dependencies = [
[[package]]
name = "security-framework"
version = "2.5.0"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce"
checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac"
dependencies = [
"bitflags",
"core-foundation",
@ -728,9 +728,9 @@ dependencies = [
[[package]]
name = "security-framework-sys"
version = "2.5.0"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7"
checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c"
dependencies = [
"core-foundation-sys",
"libc",

View File

@ -3,5 +3,5 @@
version = 3
[[package]]
name = "hello-world"
name = "quick-start-simple"
version = "0.1.0"

View File

@ -3,5 +3,5 @@
version = 3
[[package]]
name = "hello-world"
name = "quick-start"
version = "0.1.0"

View File

@ -33,11 +33,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1642762012,
"narHash": "sha256-hJqPNDyooFxhGOd4mRleWl9kj1EACziLctrjneW0pbU=",
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "787ced6423cbfd130471aaf0a5e66ca3fd3e6af0",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {

View File

@ -1,6 +1,6 @@
{ fetchurl
, urlForCargoPackage
, runCommand
, runCommandLocal
}:
{ name
@ -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

View File

@ -1,7 +1,7 @@
{ cleanCargoToml
, findCargoFiles
, lib
, runCommand
, runCommandLocal
, writeText
, writeTOML
}:
@ -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}