Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchFromGitHub: re-fetch upon version changes #294068

Draft
wants to merge 3 commits into
base: staging
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
"mysecret"` becomes `services.aria2.rpcSecretFile = "/path/to/secret_file"`
where the file `secret_file` contains the string `mysecret`.

- `fetchFromGitHub`'s default `name` is now dependent to `rev`. This ensures that the result FOD is always re-fetced for each new version, and makes irrelevent hashes more discoverable.

This also means that the default `name` is no longer `"source"`. Packages must adhere to the [Nixpkgs specification about `sourceRoot`](https://nixos.org/manual/nixpkgs/unstable/#var-stdenv-sourceRoot) and specify `sourceRoot = "${src.name}/subdir"` instead of `sourceRoot = "source/subdir"`, or the build will fail.

- Invidious has changed its default database username from `kemal` to `invidious`. Setups involving an externally provisioned database (i.e. `services.invidious.database.createLocally == false`) should adjust their configuration accordingly. The old `kemal` user will not be removed automatically even when the database is provisioned automatically.(https://github.com/NixOS/nixpkgs/pull/265857)

- `inetutils` now has a lower priority to avoid shadowing the commonly used `util-linux`. If one wishes to restore the default priority, simply use `lib.setPrio 5 inetutils` or override with `meta.priority = 5`.
Expand Down
3 changes: 2 additions & 1 deletion pkgs/build-support/fetchgit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ lib.makeOverridable (
, # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes)
# needed for netrcPhase
netrcImpureEnvVars ? []
, passthru ? {}
, meta ? {}
, allowedRequisites ? null
}:
Expand Down Expand Up @@ -103,7 +104,7 @@ stdenvNoCC.mkDerivation {

inherit preferLocalBuild meta allowedRequisites;

passthru = {
passthru = passthru // {
gitRepoUrl = url;
};
}
Expand Down
17 changes: 14 additions & 3 deletions pkgs/build-support/fetchgithub/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
{ lib, fetchgit, fetchzip }:

lib.makeOverridable (
{ owner, repo, rev, name ? "source"
{ owner, repo, rev
, name ? null # Override with nullbto use the default value
, pname ? "source-${owner}-${repo}"
, fetchSubmodules ? false, leaveDotGit ? null
, deepClone ? false, private ? false, forceFetchGit ? false
, sparseCheckout ? []
, githubBase ? "github.com", varPrefix ? null
, passthru ? { }
, meta ? { }
, ... # For hash agility
}@args:

let
name = if args.name or null != null then args.name
else "${pname}-${rev}";

position = (if args.meta.description or null != null
then builtins.unsafeGetAttrPos "description" args.meta
else builtins.unsafeGetAttrPos "rev" args
);
baseUrl = "https://${githubBase}/${owner}/${repo}";
newPassthru = passthru // {
inherit rev owner repo;
};
newMeta = meta // {
homepage = meta.homepage or baseUrl;
} // lib.optionalAttrs (position != null) {
Expand Down Expand Up @@ -53,16 +61,19 @@ let
fetcherArgs = (if useFetchGit
then {
inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
passthru = newPassthru;
} // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
else {
url = "${baseUrl}/archive/${rev}.tar.gz";

passthru = {
passthru = newPassthru // {
inherit gitRepoUrl;
};
}
) // privateAttrs // passthruAttrs // { inherit name; };
in

fetcher fetcherArgs // { meta = newMeta; inherit rev owner repo; }
(fetcher fetcherArgs).overrideAttrs (finalAttrs: previousAttrs: {
meta = newMeta;
})
)
Loading