Commit Graph
22 Commits
Author SHA1 Message Date
Yueh-Shun LiandGitHub 58366ffe0c Revert "fetchurl, fetchgitlab: fix curlOpts extension" 2025-12-15 01:03:34 +08:00
Nicolas Benes 3db11767a9 fetchurl, fetchgitlab: fix curlOpts extension
PR #464475 enables __structuredAttrs and makes curlOpts a bash array.
Consequently, it must be extended as such to be effective.

See also https://github.com/NixOS/nixpkgs/pull/464475#issuecomment-3649765507
2025-12-13 22:47:01 +01:00
Nicolas Benes 2b5981c5c7 fetchgitlab: pass private tokens/passwords
Allow the fetcher to authenticate with user name and password.
Note: as of now, GitLab ignores the user name (it must be set, but the
value does not matter) but this may change in the future:
https://gitlab.com/gitlab-org/gitlab/-/issues/212953

Credentials can be passed to the nix-daemon, for example, via a
read-protected `EnvironmentFile`:

```console
$ ls -l /to/secrets.txt
-rw------- 1 root root 100 Nov  1 10:42 /to/secrets.txt
```

In /to/secrets.txt:

```
 # for `fetchFromGitLab { private=true; ... }`
NIX_GITLAB_PRIVATE_USERNAME=whatever
NIX_GITLAB_PRIVATE_PASSWORD=glpat-the-access-token
 # for `fetchFromGitLab { private=true; varPrefix="EXAMPLE"; ... }`
NIX_EXAMPLE_GITLAB_PRIVATE_USERNAME=whatever
NIX_EXAMPLE_GITLAB_PRIVATE_PASSWORD=glpat-another-access-token
```

In /etc/nixos/configuration.nix:

```nix
{ config, pkgs, ... }:
{
  systemd.services.nix-daemon.serviceConfig.EnvironmentFile =
    "/to/secrets.txt";
}
```

GitLab supports HTTP Basic Authentication (credentials in `.netrc` file)
only if accessed via Git. Access via the GitLab API requires a custom
header (e.g. `PRIVATE-TOKEN`) instead. See:

* https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#project-access-tokens
* https://docs.gitlab.com/ee/api/rest/authentication.html#personalprojectgroup-access-tokens
2025-10-11 19:48:32 +02: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
Peder Bergebakken Sundt f7eba55589 fetchFromGitLab: passthru rev based on tag 2024-12-30 23:09:49 +01:00
wxt 4616db6469 fetchgitlab: add tag argument 2024-12-24 19:24:54 +08:00
wxt ef0cdab248 fetchgitlab: nixfmt 2024-12-24 19:23:54 +08:00
Peder Bergebakken SundtandGitHub adc2612d49 Merge pull request #268304 from panicgh/fetchgitlab-sparse-forcegit
fetchgitlab: add sparseCheckout and forceFetchGit args
2023-12-17 03:34:52 +01:00
Colin 3a55403cf4 fetchFromGitLab: passthru owner and repo
this makes the output more consistent with `fetchFromGitHub`.
2023-11-27 10:10:17 +00:00
Nicolas Benes cf00f9c2ea fetchgitlab: add option to force fetchgit 2023-11-18 13:14:08 +01:00
Nicolas Benes a838881cda fetchgitlab: add option for sparse checkout 2023-11-18 13:14:08 +01:00
Nicolas Benes 9375cf2008 fetchgitlab: make args more similar to fetchgithub 2023-11-18 13:14:08 +01:00
piegames a205795c8a treewide: Make some fetchers overridable 2023-04-22 22:29:23 +02:00
Artturin 19d2bb4863 fetchFromGitLab: don't passthruAttrs fetchGit specific attrs to fetchUrl
if `fetchSubmodules = false` to 'fetchFromGitLab' then theres the
following error

error: anonymous function at /nix/store/9m8drnpifyl5qsx93g6ll2xw6wkps03z-source/pkgs/build-support/fetchurl/default.nix:41:1 called with unexpected argument 'fetchSubmodules'

       at /nix/store/9m8drnpifyl5qsx93g6ll2xw6wkps03z-source/pkgs/build-support/fetchzip/default.nix:36:1:

           35|
           36| fetchurl ((
             | ^
           37|   if (pname != "" && version != "") then
2022-10-29 19:12:07 +03:00
Jan Tojnar 7aae279ad9 unstableGitUpdater: fix updating fetchzip-based sources
a67950f20b added `url` attribute
from `fetchurl` and therefore also from `fetchzip`.
We previously relied on `url` from fetchgit-based fetchers
to find the repo URL but now it will just return tarballs
in the case of `fetchFrom{GitHub,GitLab}`.

Let’s add an attribute to `fetch{git,FromGitHub,FromGitLab}`
to expose a repo URL consistently.
2022-05-24 19:12:12 +02:00
Igor Sharonov 80a1a44c70 fetchgitlab: fix unexpected argument 2021-11-18 21:53:46 +03:00
Mike Purvis 04b8e12ec7 fetchFromGitLab: Allow overriding protocol 2021-09-20 16:08:16 +00:00
Sandro Jäckel 94848bd430 fetchgitlab: add deepClone, fetchSubmodules, leaveDotGit arguments 2021-07-22 13:09:14 +02:00
Tethys Svensson 43cd431b44 fetchgitlab: Escape a few more characters in the revision 2020-09-13 12:34:08 +02:00
Florian Klink 9b7a4694a0 fetchgitlab: escape rev to support "+" in it 2020-05-24 22:24:50 +02:00
Alyssa Ross ee49b45a7b fetchFromGitLab: improve readability 2019-12-09 01:33:16 +00:00
Matthew Bauer d16e0f8dc3 all-packages: move fetch* to pkgs/build-support/ 2019-01-26 22:47:54 -05:00