Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d6c7d6
fetchgit: move assertions down to argument values
ShamrockLee Nov 14, 2025
9fe4e65
fetchgit: default argument leaveDotGit to null
ShamrockLee Nov 15, 2025
d461ad8
fetchFromGitHub: pass leaveDotGit unconditionally using the null default
ShamrockLee Nov 15, 2025
5916868
fetchFromGitHub: elaborate the fetchSubmodules default choice
ShamrockLee Nov 16, 2025
6c5dc5d
fetchgit: default nonConeMode to null and manage its default internally
ShamrockLee Nov 16, 2025
ea5b3c6
fetchgit: nonConeMode: reference depending attributes from finalAttrs
ShamrockLee Dec 4, 2025
83b42e3
fetchgit: keep sparseCheckout a list and stringify as sparseCheckoutText
ShamrockLee Nov 16, 2025
dd26422
fetchgit: default sparseCheckout to null and handle the default inter…
ShamrockLee Nov 16, 2025
d1275c4
fetchgit: move sparseCheckout type check down to sparseCheckoutText
ShamrockLee Nov 16, 2025
8c85578
fetchgit: format expression after eliminating global assertions
ShamrockLee Nov 16, 2025
4c681c7
fetchFromGitHub: default sparseCheckout to null
ShamrockLee Nov 16, 2025
5c51547
fetchgit: sparseCheckout: reference depending attributes from finalAttrs
ShamrockLee Dec 4, 2025
239a6f8
fetchFromGitHub: explicitly support addditional fetchgit args
ShamrockLee Oct 28, 2025
746e443
fetchFromGitHub: converge arguments that determines useFetchGit
ShamrockLee Nov 16, 2025
7f9a1c8
lib.makeOverrdable: preserve constructor override and metadata attrib…
ShamrockLee Nov 12, 2025
185b80b
fetchFromGitProvider: init
ShamrockLee Nov 13, 2025
a514aaf
fetchFromGitHub: base on fetchFromGitProvider and lib.extendMkDerivation
ShamrockLee Dec 2, 2025
351c182
fetchFromGitHub: format expression after lib.extendMkDerivation recon…
ShamrockLee Nov 13, 2025
1a7e9b1
fetchurl: provide fetchurl.extendDrvArgs
ShamrockLee Dec 1, 2025
e08b2c3
fetchzip: provide fetchzip.expectDrvArgs
ShamrockLee Nov 15, 2025
1bafb30
mkDerivation: make allowedReference/allowedRequisites nullable when _…
ShamrockLee Nov 15, 2025
a04426d
fetchgit: provide fetchgit.expectDrvArgs
ShamrockLee Nov 15, 2025
c54b742
fetchFromGitProvider, fetchFromGitHub: use and provide expectDrvArgs
ShamrockLee Nov 17, 2025
d27d2a3
lib.fetchers.normalizeHash: move assertions down to outputHash and ou…
ShamrockLee Dec 3, 2025
e28bd42
fetchGitProvider: default enableUseFetchGitFinal true
ShamrockLee Nov 21, 2025
cc205a2
fetchGitProvider: reduce enableUseFetchGitFinal RAM consumption with …
ShamrockLee Dec 2, 2025
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
19 changes: 18 additions & 1 deletion lib/customisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,25 @@ rec {
let
# Creates a functor with the same arguments as f
mirrorArgs = mirrorFunctionArgs f;
# Recover overrider and additional attributes for f
# When f is a callable attribute set,
# it may contain its own `f.override` and additional attributes.
# This helper function recovers those attributes and decorate the overrider.
recoverMetadata =
if isAttrs f then
fDecorated:
# Preserve additional attributes for f
f
// fDecorated
# Decorate f.override if presented
// lib.optionalAttrs (f ? override) {
override = fdrv: makeOverridable (f.override fdrv);
}
else
id;
decorate = f': recoverMetadata (mirrorArgs f');
in
mirrorArgs (
decorate (
origArgs:
let
result = f origArgs;
Expand Down
37 changes: 22 additions & 15 deletions lib/fetchers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,31 @@ rec {
# All hashes passed in arguments (possibly 0 or >1) as a list of {name, value} pairs
let
hashesAsNVPairs = attrsToList (intersectAttrs hashSet args);
unspecifiedHash = hashesAsNVPairs == [ ];
multipleHash = tail hashesAsNVPairs != [ ];
in
if hashesAsNVPairs == [ ] then
throwIf required "fetcher called without `hash`" null
else if tail hashesAsNVPairs != [ ] then
throw "fetcher called with mutually-incompatible arguments: ${
concatMapStringsSep ", " (a: a.name) hashesAsNVPairs
}"
else
head hashesAsNVPairs;
{
errorMessage =
if unspecifiedHash && required then
"fetcher called without `hash`"
else if multipleHash then
"fetcher called with mutually-incompatible arguments: ${
concatMapStringsSep ", " (a: a.name) hashesAsNVPairs
}"
else
null;
inherit (head hashesAsNVPairs) name value;
inherit unspecifiedHash;
};
in
removeAttrs args hashNames
// (optionalAttrs (h != null) {
outputHashAlgo = if h.name == "hash" then null else h.name;
outputHash =
if h.value == "" then
fakeH.${h.name} or (throw "no “fake hash” defined for ${h.name}")
else
h.value;
// (optionalAttrs (required || !h.unspecifiedHash) {
outputHashAlgo = lib.throwIf (h.errorMessage != null) h.errorMessage (
if h.name == "hash" then null else h.name
);
outputHash = lib.throwIf (h.errorMessage != null) h.errorMessage (
if h.value == "" then fakeH.${h.name} or (throw "no “fake hash” defined for ${h.name}") else h.value
);
});

/**
Expand Down
79 changes: 79 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,85 @@ runTests {
};
};

testOverridePreserveFunctionMetadata =
let
toCallableAttrs = f: setFunctionArgs f (functionArgs f);
constructDefinition =
{
a ? 3,
}:
toCallableAttrs (
{
b ? 5,
}:
{
inherit a b;
}
)
// {
inherit a;
c = 7;
};
construct0 = makeOverridable constructDefinition { };
construct1 = makeOverridable construct0;
construct0p = construct0.override { a = 11; };
construct1p = construct1.override { a = 11; };
in
{
expr = {
construct-metadata = {
inherit (construct1) a c;
};
construct-overridden-metadata = {
v = construct0p.a;
inherit (construct1p) a c;
};
construct-overridden-result-overrider = {
result-overriders-exist = mapAttrs (_: f: (f { }) ? override) {
inherit construct1 construct1p;
};
result-overrider-functionality = {
overridden = {
inherit ((construct1p { }).override { b = 13; }) a b;
};
direct = {
inherit (construct1p { b = 13; }) a b;
};
v = {
inherit (construct0p { b = 13; }) a b;
};
};
};
};
expected = {
construct-metadata = {
inherit (construct0) a c;
};
construct-overridden-metadata = {
v = 11;
inherit (construct0p) a c;
};
construct-overridden-result-overrider = {
result-overriders-exist = {
construct1 = true;
construct1p = true;
};
result-overrider-functionality = {
overridden = {
inherit (construct0p { b = 13; }) a b;
};
direct = {
inherit (construct0p { b = 13; }) a b;
};
v = {
a = 11;
b = 13;
};
};
};
};
};

testCallPackageWithOverridePreservesArguments =
let
f =
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchgit/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" --name "$name"
${deepClone:+--deepClone} \
${fetchSubmodules:+--fetch-submodules} \
${fetchTags:+--fetch-tags} \
${sparseCheckout:+--sparse-checkout "$sparseCheckout"} \
${sparseCheckoutText:+--sparse-checkout "$sparseCheckoutText"} \
${nonConeMode:+--non-cone-mode} \
${branchName:+--branch-name "$branchName"} \
${rootDir:+--root-dir "$rootDir"}
Expand Down
Loading
Loading