mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
44 lines
1023 B
Nix
44 lines
1023 B
Nix
{ buildPackage
|
|
, cleanCargoSource
|
|
, lib
|
|
, vendorCargoDeps
|
|
, runCommand
|
|
}:
|
|
|
|
let
|
|
src = cleanCargoSource ../simple-git-workspace-inheritance;
|
|
|
|
isCraneTestRepo = lib.any (p: lib.hasPrefix "git+https://github.com/ipetkov/crane-test-repo.git#" p.source);
|
|
bin = buildPackage {
|
|
inherit src;
|
|
cargoVendorDir = vendorCargoDeps {
|
|
inherit src;
|
|
overrideVendorGitCheckout = ps: drv:
|
|
if isCraneTestRepo ps then
|
|
drv.overrideAttrs
|
|
(_old: {
|
|
patches = [
|
|
./0001-patch-test-repo.patch
|
|
];
|
|
})
|
|
else
|
|
drv;
|
|
|
|
overrideVendorCargoPackage = p: drv:
|
|
if p.name == "byteorder" then
|
|
drv.overrideAttrs
|
|
(_old: {
|
|
patches = [
|
|
./0002-patch-byteorder.patch
|
|
];
|
|
})
|
|
else
|
|
drv;
|
|
};
|
|
};
|
|
in
|
|
runCommand "runPatchedBin" { } ''
|
|
diff <(echo -e 'greetings, crane!\n') <(${bin}/bin/simple-git-workspace-inheritance)
|
|
touch $out
|
|
''
|