59 Commits
Author SHA1 Message Date
HigherOrderLogic 3a1906969d fetchFromGitHub: allows overriding function name
Allow for better error message when used to fetch from other Git providers.
2026-06-07 12:25:18 +10:00
Philip TaronandGitHub 0c469218f3 build-support: remove assertMsg, throwIf, and throwIfNot usage (#524535) 2026-05-28 18:09:32 +00:00
Hans Joachim KliemeckandArnout Engelen 8478c2384b stdenv: Package URL (PURL) metadata fields 2026-05-26 21:47:54 +02:00
Eman Resu 0f655fd51a build-support/fetchgithub: remove assertMsg usage 2026-05-26 14:14:41 -04:00
Eman Resu 7e557e7ad1 fetchFromGitHub: only override fetchzip once
Funny bug - we were running a .override on fetchzip on every single call
to fetchFromGitHub.
2026-05-22 00:36:18 -04:00
Yueh-Shun Li 7cf93cdb96 fetchFromGitHub: use fetchgit when postCheckout not empty 2025-12-25 07:54:58 +08:00
Yueh-Shun Li 52858a24c6 tests.fetchFromGitHub: add simple-tag 2025-12-25 07:52:52 +08:00
Yueh-Shun Li 92f45c5d88 fetchFromGitHub: simplify useFetchGit and useFetchGitArgsWDPassing 2025-12-11 04:59:04 +08:00
Yueh-Shun Li cd58ed0ab6 fetchFromGitHub: converge arguments that determines useFetchGit 2025-12-09 22:44:07 +08:00
Yueh-Shun Li 8e4ed61317 fetchFromGitHub: explicitly support addditional fetchgit args 2025-12-09 22:44:07 +08:00
Yueh-Shun Li 4c681c7ce0 fetchFromGitHub: default sparseCheckout to null 2025-12-04 15:26:18 +08:00
Yueh-Shun Li 59168687f9 fetchFromGitHub: elaborate the fetchSubmodules default choice 2025-12-04 15:20:13 +08:00
Yueh-Shun Li d461ad81b2 fetchFromGitHub: pass leaveDotGit unconditionally using the null default 2025-12-04 15:20:12 +08:00
Yueh-Shun Li 8bb3bbbf44 fetchFromGitHub: pass githubBase to mkDerivation via derivationArgs
Reduce future test rebuilds when making githubBase overridable.
2025-11-03 21:31:06 +08:00
Yueh-Shun Li 4e996b3920 fetchFromGitHub: make name respect overridden arguments 2025-11-03 21:31:06 +08:00
Yueh-Shun Li aede4d203c fetchFromGitHub: pass rev uniformly 2025-11-03 21:31:05 +08:00
Yueh-Shun Li 3754cf57cf fetchFromGitHub: pass tag to mkDerivation uniformly 2025-11-03 21:31:05 +08:00
Yueh-Shun Li dd9af80094 fetchFromGitHub: pass owner and repo via derivationArgs 2025-11-03 21:31:05 +08:00
Yueh-Shun Li e0ba367c2b fetchFromGitHub: pass meta via fetcherArgs 2025-11-03 21:31:05 +08:00
Yueh-Shun Li 456dd7cece fetchFromGitHub: take and unshadow passthru 2025-10-28 01:47:34 +08:00
Yueh-Shun Li 745fc66702 fetchFromGitHub: prevent user overwriting url and private arguments 2025-10-28 01:47:32 +08:00
d068328 e47455f51d Revert "stdenv: pURL implementation (#421125)"
This reverts commit 5427115670, reversing
changes made to 88ee2ac331.
2025-10-18 20:41:01 +00:00
Arian van PuttenandGitHub 5427115670 stdenv: pURL implementation (#421125) 2025-10-17 09:30:32 +00:00
Hans Joachim Kliemeckandd068328 028af7c17d stdenv: pURL review suggestions - replace merge 2025-10-14 17:02:51 +00:00
Hans Joachim Kliemeckandd068328 bacccc39a9 stdenv: pURL - fix chaining case (github&submodules using fetchgit) 2025-10-14 14:53:13 +00:00
Hans Joachim KliemeckandGitHub 83b6d2e657 stdenv: pURL review suggestions - part 4 2025-10-10 15:13:18 +02:00
Hans Joachim Kliemeckandd068328 1f173d0172 stdenv: pURL review suggestions 2025-10-10 10:47:30 +00:00
Hans Joachim Kliemeckandd068328 0a69474ed3 stdenv: pURL github speed optimization 2025-10-03 21:19:09 +00:00
h0nIgandd068328 4e2614fc07 stdenv: pURL implementation 2025-10-03 21:19:09 +00:00
Michael Daniels 2b9641e5df tests.fetchFromGitHub: init
Copied from pkgs/build-support/fetchgit/tests.nix, see there for attribution.
2025-10-02 21:47:29 -04:00
Michael DanielsandPhilip Taron 42637c305f fetchFromGitHub: use fetchgit when the rootDir option is set
This argument was added to fetchgit in #427165,
and it's not supported by fetchzip.

Co-authored-by: Philip Taron <philip.taron@gmail.com>
2025-10-02 21:17:23 -04:00
Jan Malakhovski 7c8a4efb68 lib, treewide: introduce repoRevToName, use it in most fetch* functions
This patch adds `lib.repoRevToName` function that generalizes away most of the
code used for derivation name generation by `fetch*` functions (`fetchzip`,
`fetchFromGitHub`, etc, except those which are delayed until latter commits
for mass-rebuild reasons).

It's first argument controls how the resulting name will look (see below).

Since `lib` has no equivalent of Nixpkgs' `config`, this patch adds
`config.fetchedSourceNameDefault` option to Nixpkgs and then re-exposes
`lib.repoRevToName config.fetchedSourceNameDefault` expression as
`pkgs.repoRevToNameMaybe` which is then used in `fetch*` derivations.

The result is that different values of `config.fetchedSourceNameDefault` now
control how the `src` derivations produced by `fetch*` functions are to be
named, e.g.:

- `fetchedSourceNameDefault = "source"` (the default):

  ```
  $ nix-instantiate -A fuse.src
  /nix/store/<hash>-source.drv
  ```

- `fetchedSourceNameDefault = "versioned"`:

  ```
  $ nix-instantiate -A fuse.src
  /nix/store/<hash>-libfuse-2.9.9-source.drv
  ```

- `fetchedSourceNameDefault = "full"`:

  ```
  $ nix-instantiate -A fuse.src
  /nix/store/<hash>-libfuse-2.9.9-github-source.drv
  ```

See the documentation of `config.fetchedSourceNameDefault` for more info.
2025-05-31 10:01:21 +00:00
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Olivier LDff f19cf904b1 fetchFromGitHub: use of the API endpoint only when fetching tarball
https://github.com/NixOS/nixpkgs/pull/321484 introduced a bug when when
`forceFetchGit=true`.

This PR revert the change only for this case.

The previous PR made work cases like:

```bash
nix-build -E 'let pkgs = import ./nixpkgs {}; in pkgs.fetchFromGitHub {
owner = "<username>"; repo = "<repo>"; rev = "HEAD"; hash = "";
private=true; forceFetchGit=false; }'
```

You should see the download working and nix complaining about hash
mismatch.

Now if you take the case where `forceFetchGit=true`, this is a different
story:

```
nix-build -E 'let pkgs = import ./nixpkgs {}; in pkgs.fetchFromGitHub {
owner = "<username>"; repo = "<repo>"; rev = "HEAD"; hash = "";
private=true; forceFetchGit=true; }'
```

Logs look like:

```
Initialized empty Git repository in /nix/store/<hash>-source/.git/
fatal: could not read Username for 'https://github.com': No such device or address
fatal: could not read Username for 'https://github.com': No such device or address
fatal: could not read Username for 'https://github.com': No such device or address
fatal: could not read Username for 'https://github.com': No such device or address
Unable to checkout HEAD from https://github.com/<username>/<repo>.git.
```

I was using `forceFetchGit` for the exact reason the previous PR was
made, I will move to `forceFetchGit=false` now.

Still the previous PR was a broke usage of `fetchFromGitHub` force private repository when `forceFetchGit` is used.
2025-03-12 11:07:12 +01:00
42574f5205 fetchFromGitHub: refactor for scope clarity
Co-authored-by: Philip Taron <philip.taron@gmail.com>
2025-01-16 10:45:57 +00:00
Adam Dinwoodie 1a72fa0e19 fetchFromGitHub: use the API tarball endpoint
GitHub currently has two kinds of personal access token: "classic" and
"fine-grained".  Fine-grained personal access tokens, as the name
suggests, allow much more control over what the token can and cannot do,
and in particular allow users to specify which repositories the token
should provide access to.

Unfortunately, fine-grained tokens don't allow access to repository
archive tarballs for private repositories at (say)
https://github.com/me-and/private-demo/archive/HEAD.tar.gz.
Fortunately, the GitHub API endpoint does provide this access, and also
works with classic tokens and -- for public repositories -- no token at
all.

To allow folk to use fine-grained access tokens, use the GitHub API for
accessing private repos.  Keep using the existing interface for
non-private repos, as we can only assume an authenticated user for
private repos, and unauthenticated users have restrictive rate limits on
the API interface.

Fixes #321481
2025-01-05 21:46:19 +00:00
Peder Bergebakken Sundt 39ddc92155 fetchFromGitHub: passthru rev based on tag 2024-12-30 23:08:36 +01:00
Robert Schütz ce33e20a03 fetchFromGitHub: expose tag argument 2024-12-06 20:56:06 -08:00
Atemu e9a31f5146 fetchgit{,hub}: assert illegal tag + rev combinations
It's quite a bit more complex due to this but this was asked for during review
2024-12-05 16:29:11 +01:00
Atemu cb9f9a1e5a fetchgit{,hub}: add tag argument
It's become a common pattern to use `rev = "refs/tags/${version}"` rather than
just `rev = version` to ensure that the tag gets fetched rather than a branch
that has the same name. This has so far been done using boilerplate though, so
let's add a simple abstraction to fetch a tag instead.
2024-11-18 08:20:00 +01:00
sohalt b60d3f6270 fetchgithub: support fetchLFS 2024-09-04 19:01:22 +02:00
Weijia Wang a2fa54fa67 fetchFromGitHub: fix compatibility issue with nix-prefetch 2024-01-30 12:21:13 +01:00
Vladimír Čunát 141a1ec41d Merge #279934: fetchFromGitHub: drop unzip 2024-01-16 05:52:01 +01:00
Weijia Wang 71a024e1f6 fetchFromGitHub: drop unzip 2024-01-12 20:26:20 +01:00
Sergei Trofimovich 6104083817 build-support/fetchgithub: fix metadata eval for arguments without locations
Without the change metadata evaluation fails on package like
`zammad.src` where no fields are defined in `.nix `files:

    src = fetchFromGitHub (lib.importJSON ./source.json);

There evaluation fails as:

    $ nix-instantiate --strict --eval --expr 'with import ./. {}; zammad.src.meta'
    error:
           23|     # to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
           24|     position = "${position.file}:${toString position.line}";
             |     ^
           25|   };
       error: value is null while a set was expected

After the change evaluation succeeds as:

    $ nix-instantiate --strict --eval --expr 'with import ./. {}; zammad.src.meta'
    { homepage = "https://github.com/zammad/zammad"; }
2023-12-31 11:44:22 +00:00
Felix Buehler f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Nicolas Benes 52f3a1c42c fetchgit: require sparseCheckout be a list of strings
Passing a (multi-line) string was deprecated in #200082 in favour of
list of strings, but still supported (with warning). Now, enforce use of
list of strings.
2023-06-04 10:04:31 +02:00
piegames a205795c8a treewide: Make some fetchers overridable 2023-04-22 22:29:23 +02:00
Madoura 72f5af191f fetchGitHub: inherit owner and repo for use with rocmUpdateScript 2022-12-10 13:35:47 -06:00
Nicolas Benes c95d7d5a8c treewide: make sparseCheckout a list of strings 2022-11-15 19:46:12 +01:00