aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
AgeCommit message (Collapse)Author
2023-04-07Finish converting existing comments for internal API docs (#8146)John Ericson
* Finish converting existing comments for internal API docs 99% of this was just reformatting existing comments. Only two exceptions: - Expanded upon `BuildResult::status` compat note - Split up file-level `symbol-table.hh` doc comments to get per-definition docs Also fixed a few whitespace goofs, turning leading tabs to spaces and removing trailing spaces. Picking up from #8133 * Fix two things from comments * Use triple-backtick not indent for `dumpPath` * Convert GNU-style `\`..'` quotes to markdown style in API docs This will render correctly.
2023-04-06Backport SourcePath from the lazy-trees branchEelco Dolstra
This introduces the SourcePath type from lazy-trees as an abstraction for accessing files from inputs that may not be materialized in the real filesystem (e.g. Git repositories). Currently, however, it's just a wrapper around CanonPath, so it shouldn't change any behaviour. (On lazy-trees, SourcePath is a <InputAccessor, CanonPath> tuple.)
2023-03-31Ensure all headers have `#pragma once` and are in API docsJohn Ericson
`///@file` makes them show up in the internal API dos. A tiny few were missing `#pragma once`.
2023-03-30Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson
Also improve content-address.hh API docs.
2023-03-20Mark experimental features on settingsJohn Ericson
We hide them in various ways if the experimental feature isn't enabled. To do this, we had to move the experimental features list out of libnixstore, because the setting machinary itself depends on it. To do that, we made a new `ExperimentalFeatureSettings`.
2023-03-15respect allRefs=1 when using `nix flake prefetch`figsoda
2023-03-01Merge pull request #7854 from aameen-tulip/patch-1Valentin Gagarin
2023-02-28No inheritance for `TextInfo` and `FixedOutputInfo`John Ericson
2023-02-28Revert "Remove some designated initializers"John Ericson
This reverts commit ee9eb83a842eb97d0180fd9d349d30ff27fdb485.
2023-02-28Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson
2023-02-24Example uses gitlab.com thus clarify the commentAnatol Pomozov
2023-02-16Document `hasAllInfo`aameen-tulip
If this documentation is inaccurate in any way please do not hesitate to suggest corrections. My understanding of this function is strictly from reading the source code and some limited experience implementing fetchers.
2023-02-09Improve commentEelco Dolstra
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-02-09Fix activity messageEelco Dolstra
Co-authored-by: Josef Kemetmüller <josef.kemetmueller@gmail.com>
2023-02-07Fix activity messageEelco Dolstra
2023-02-07Speed up fetching submodulesEelco Dolstra
Previously we would completely refetch the submodules from the network, even though the repo might already have them. Now we copy the .git/modules directory from the repo as an optimisation. This speeds up evaluating builtins.fetchTree { type = "git"; url = "/path/to/blender"; submodules = true; } (where /path/to/blender already has the needed submodules) from 121s to 57s. This is still pretty inefficient and a hack, but a better solution is best done on the lazy-trees branch. This change also help in the case where the repo already has the submodules but the origin is unfetchable for whatever reason (e.g. there have been cases where Nix in a GitHub action doesn't have the right authentication set up).
2023-02-07Fix the origin URL used for fetching submodulesEelco Dolstra
We cannot use 'actualUrl', because for file:// repos that's not the original URL that the repo was fetched from. This is a problem since submodules may be relative to the original URL. Fixes e.g. nix eval --impure --json --expr 'builtins.fetchTree { type = "git"; url = "/path/to/blender"; submodules = true; }' where /path/to/blender is a clone of https://github.com/blender/blender.git (which has several relative submodules like '../blender-addons.git').
2023-02-07Add some progress indication when fetching submodulesEelco Dolstra
2023-02-01Remove some designated initializersJohn Ericson
With the switch to C++20, the rules became more strict, and we can no longer initialize base classes. Make them comments instead. (BTW https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2287r1.html this offers some new syntax for this use-case. Hopefully this will be adopted and we can eventually use it.)
2023-01-23Don't add `StorePathDescriptor` for nowJohn Ericson
We don't need it yet, we can add it back later.
2023-01-06Use named field initialization for referencesJohn Ericson
2023-01-06Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson
2022-12-12Allow to disable global flake-registry with ""Benoit de Chezelles
2022-12-07Trivial changes from the lazy-trees branchEelco Dolstra
2022-10-31Merge pull request #7039 from Mic92/libfetchers-variantThéophane Hufschmitt
libfetchers: avoid api.github.com ratelimit if no github token is set
2022-10-14Fix #7146Andrew Brooks
When fetching a non-local git repo by ref (and no rev), don't consider unrelated cached revs for the same repository.
2022-10-01libfetchers: avoid api.github.com ratelimit if no github token is setJörg Thalheim
If we don't have any github token, we won't be able to fetch private repos, but we are also more likely to run into API limits since we don't have a token. To mitigate this only ever use the github api if we actually have a token.
2022-08-17Don't pass --force to 'git add'Eelco Dolstra
Fixes #5810.
2022-06-26fetchGit: document `shallow` argumentGuillaume Girol
2022-06-23Fetch flake-registry.json from channels.nixos.orgEelco Dolstra
Using fastly is slightly faster, provides some resilience due to a high stale TTL, and allows some usage metrics.
2022-06-11fix sourcehut brach/tag resolving regressionGabriel Fontes
nixos/nix#6290 introduced a regex pattern to account for tags when resolving sourcehut refs. nixos/nix#4638 reafactored the code, accidentally treating the pattern as a regular string, causing all non-HEAD ref resolving to break. This fixes the regression and adds more test cases to avoid future breakage.
2022-06-10libfetchers/git: add missing `--git-dir` flagsNaïm Favier
2022-05-27Fix a segfault in the git fetcherThéophane Hufschmitt
The git fetcher code used to dereference the (potentially empty) `ref` input attribute. This was magically working, probably because the compiler somehow outsmarted us, but is now blowing up with newer nixpkgs versions. Fix that by not trying to access this field while we don't know for sure that it has been defined. Fix #6554
2022-05-25TypoEelco Dolstra
2022-05-25Merge remote-tracking branch 'origin/file-fetcher'Eelco Dolstra
2022-05-24libfetchers: drop `getGitDir` and hardcode `.git`Maximilian Bosch
As discussed[1] this is most likely not desirable. [1] https://github.com/NixOS/nix/pull/6440#issuecomment-1120876248
2022-05-19fetchTree: Allow fetching plain filesTony Olagbaiye
Add a new `file` fetcher type, which will fetch a plain file over http(s), or from the local file. Because plain `http(s)://` or `file://` urls can already correspond to `tarball` inputs (if the path ends-up with a know archive extension), the URL parsing logic is a bit convuluted in that: - {http,https,file}:// urls will be interpreted as either a tarball or a file input, depending on the extensions of the path part (so `https://foo.com/bar` will be a `file` input and `https://foo.com/bar.tar.gz` as a `tarball` input) - `file+{something}://` urls will be interpreted as `file` urls (with the `file+` part removed) - `tarball+{something}://` urls will be interpreted as `tarball` urls (with the `tarball+` part removed) Fix #3785 Co-Authored-By: Tony Olagbaiye <me@fron.io>
2022-05-12fix GitHub URL templateNorbert Melzer
2022-05-10Merge pull request #6497 from danielfullmer/ghe-fetcher-urlEelco Dolstra
Use correct URL for GitHub Enterprise
2022-05-06Use correct URL for GitHub EnterpriseDaniel Fullmer
For GitHub Enterprise, the API is accessed through a slightly different URL. See [1], where it says: > Use http(s)://[hostname]/api/v3 to access the API for GitHub > Enterprise Server. Also tested working on a GHE instance. [1] https://docs.github.com/en/enterprise-server@3.3/rest/guides/getting-started-with-the-rest-api
2022-05-04Fix the parsing of the sourcehut refs fileThéophane Hufschmitt
Since a26be9f3b89be2ee90c6358250b9889b37f95cf8, the same parser is used to parse the result of sourcehut’s `HEAD` endpoint (coming from [git dumb protocol]) and the output of `git ls-remote`. However, they are very slightly different (the former doesn’t specify the current reference since it’s implied to be `HEAD`). Unify both, and make the parser a bit more robust and understandable (by making it more typed and adding tests for it) [git dumb protocol]: https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols#_the_dumb_protocol
2022-05-02Style fixesEelco Dolstra
2022-05-02Merge pull request #6470 from Ma27/git-followupEelco Dolstra
libfetchers/git: fix every occasion of a permission error
2022-04-30libfetchers/git: fix every occasion of a permission errorMaximilian Bosch
I'm afraid I missed a few problematic `git(1)`-calls while implementing PR #6440, sorry for that! Upon investigating what went wrong, I realized that I only tested against the "cached"-case by accident because my git-checkout with my system's flake was apparently cached during my debugging. I managed to trigger the original issue again by running: $ git commit --allow-empty -m "tmp" $ sudo nixos-rebuild switch --flake .# -L --builders '' Since `repoDir` points to the checkout that's potentially owned by another user, I decided to add `--git-dir` to each call affecting `repoDir`. Since the `tmpDir` for the temporary submodule-checkout is created by Nix itself, it doesn't seem to be an issue. Sorry for that, it should be fine now.
2022-04-29Extract git reference parsing to a shared libraryKjetil Orbekk
These utility functions can be shared between the git and github fetchers.
2022-04-29Store cached head in cached git repoKjetil Orbekk
The previous head caching implementation stored two paths in the local cache; one for the cached git repo and another textfile containing the resolved HEAD ref. This commit instead stores the resolved HEAD by setting the HEAD ref in the local cache appropriately.
2022-04-29Refactor fetching of dirty workdirKjetil Orbekk
Extract the handling of a local dirty workdir to a helper function.
2022-04-29Resolve reference for remote repositoryKjetil Orbekk
Resolves the HEAD reference from the remote repository instead of assuming "master".
2022-04-24libfetchers/git: fix for nixos-rebuildMaximilian Bosch
The `--git-dir=` must be `.` in some cases (for cached repos that are "bare" repos in `~/.cache/nix/gitv3`). With this fix we can add `--git-dir` to each `git`-invokation needed for `nixos-rebuild`.
2022-04-23libfetchers/git: hardcode `--git-dir`Maximilian Bosch
To demonstrate the problem: * You need a `git` at 2.33.3 in your $PATH * An expression like this in a git repository: ``` nix { outputs = { self, nixpkgs }: { packages.foo.x86_64-linux = with nixpkgs.legacyPackages.x86_64-linux; runCommand "snens" { } '' echo ${(builtins.fetchGit ./.).lastModifiedDate} > $out ''; }; } ``` Now, when instantiating the package via `builtins.getFlake`, it fails on Nix 2.7 like this: $ nix-instantiate -E '(builtins.getFlake "'"$(pwd)"'").packages.foo.x86_64-linux' fatal: unsafe repository ('/nix/store/a7j3125km4h8l0p71q6ssfkxamfh5d61-source' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /nix/store/a7j3125km4h8l0p71q6ssfkxamfh5d61-source error: program 'git' failed with exit code 128 (use '--show-trace' to show detailed location information) This breaks e.g. `nixops`-deployments using flakes with similar expressions as shown above. The cause for this is that `git(1)` tries to find the highest `.git`-directory in the directory tree and if it finds a such a directory, but with another owning user (root vs. the user who evaluates the expression), it fails as above. This was changed recently to fix CVE-2022-24765[1]. By explicitly specifying `--git-dir`, Git assumes to be in the top-level directory and doesn't attempt to look for a `.git`-directory in the parent directories and thus the code-path leading to said error is never reached. [1] https://lore.kernel.org/git/xmqqv8veb5i6.fsf@gitster.g/