aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
AgeCommit message (Collapse)Author
2020-07-28Merge legacy `fetchGit`-builtin with the generic `fetchTree`-functionMaximilian Bosch
The original idea was to implement a git-fetcher in Nix's core that supports content hashes[1]. In #3549[2] it has been suggested to actually use `fetchTree` for this since it's a fairly generic wrapper over the new fetcher-API[3] and already supports content-hashes. This patch implements a new git-fetcher based on `fetchTree` by incorporating the following changes: * Removed the original `fetchGit`-implementation and replaced it with an alias on the `fetchTree` implementation. * Ensured that the `git`-fetcher from `libfetchers` always computes a content-hash and returns an "empty" revision on dirty trees (the latter one is needed to retain backwards-compatibility). * The hash-mismatch error in the fetcher-API exits with code 102 as it usually happens whenever a hash-mismatch is detected by Nix. * Removed the `flakes`-feature-flag: I didn't see a reason why this API is so tightly coupled to the flakes-API and at least `fetchGit` should remain usable without any feature-flags. * It's only possible to specify a `narHash` for a `git`-tree if either a `ref` or a `rev` is given[4]. * It's now possible to specify an URL without a protocol. If it's missing, `file://` is automatically added as it was the case in the original `fetchGit`-implementation. [1] https://github.com/NixOS/nix/pull/3216 [2] https://github.com/NixOS/nix/pull/3549#issuecomment-625194383 [3] https://github.com/NixOS/nix/pull/3459 [4] https://github.com/NixOS/nix/pull/3216#issuecomment-553956703
2020-07-16Merge remote-tracking branch 'upstream/master' into hash-always-has-typeJohn Ericson
2020-07-13Fix gitlab-fetcher to obtain tags and branchesMaximilian Bosch
Until now, the `gitlab`-fetcher determined the source's rev by checking the latest commit of the given `ref` using the `/repository/branches`-API. This breaks however when trying to fetch a gitlab-repo by its tag: ``` $ nix repl nix-repl> builtins.fetchTree gitlab:Ma27/nvim.nix/0.2.0 error: --- Error ------------------------------------------------------------------------------------- nix unable to download 'https://gitlab.com/api/v4/projects/Ma27%2Fnvim.nix/repository/branches/0.2.0': HTTP error 404 ('') ``` When using the `/commits?ref_name`-endpoint[1] you can pass any kind of valid ref to the `gitlab`-fetcher. Please note that this fetches the only first 20 commits on a ref, unfortunately there's currently no endpoint which only retrieves the latest commit of any kind of `ref`. [1] https://docs.gitlab.com/ee/api/commits.html#list-repository-commits
2020-07-06Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-07-03Merge branch 'master' of github.com:NixOS/nix into hash-always-has-typeJohn Ericson
2020-07-03Shut up a clang warningEelco Dolstra
2020-07-01Add --inputs-from to use flake inputs as registry entriesEelco Dolstra
This allows you to refer to an input from another flake. For example, $ nix run --inputs-from /path/to/hydra nixpkgs#hello runs 'hello' from the 'nixpkgs' inputs of the 'hydra' flake. Fixes #3769.
2020-07-01Support building flakes from a shallow Git repoEelco Dolstra
Fixes #3756.
2020-06-26Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-23Merge remote-tracking branch 'upstream/master' into hash-always-has-typeJohn Ericson
2020-06-19WIP: Make Hash always store a valid hash typeJohn Ericson
2020-06-19More designated initializersJohn Ericson
2020-06-19Merge remote-tracking branch 'me/no-stringly-typed-derivation-output' into ↵John Ericson
validPathInfo-ca-proper-datatype
2020-06-18Merge branch 'validPathInfo-temp' into validPathInfo-ca-proper-datatypeJohn Ericson
2020-06-18Revert the `enum struct` changeJohn Ericson
Not a regular git revert as there have been many merges and things.
2020-06-18Merge branch 'enum-class' into no-hash-type-unknownJohn Ericson
2020-06-18Merge remote-tracking branch 'upstream/master' into enum-classJohn Ericson
2020-06-18github: Respect default branchEelco Dolstra
2020-06-17Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-16StorePath: Rewrite in C++Eelco Dolstra
On nix-env -qa -f '<nixpkgs>', this reduces maximum RSS by 20970 KiB and runtime by 0.8%. This is mostly because we're not parsing the hash part as a hash anymore (just validating that it consists of base-32 characters). Also, replace storePathToHash() by StorePath::hashPart().
2020-06-12Use `std::string_view` in a few more placesJohn Ericson
2020-06-12Merge pull request #3674 from matthewbauer/allow-empty-hash2Eelco Dolstra
Allow empty hash in derivations
2020-06-12Add newHashAllowEmpty helper functionMatthew Bauer
This replaces the copy&paste with a helper function in hash.hh.
2020-06-09Support empty hash in fetchersMatthew Bauer
fetchTarball, fetchTree, and fetchGit all have *optional* hash attrs. This means that we need to be careful with what we allow to avoid accidentally making these defaults. When ‘hash = ""’ we assume the empty hash is wanted.
2020-06-09Fix applyOverride() for githubEelco Dolstra
2020-06-04getDefaultUrl() -> value_or()Eelco Dolstra
2020-06-04add support for selfhosted gitlab/githubFinn Behrens
2020-06-03No C++ designated initializers yet with Clang 7John Ericson
2020-06-03Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-03libutils/hash: remove default encodingzimbatm
This will make it easier to reason about the hash encoding and switch to SRI everywhere where possible.
2020-06-02Merge remote-tracking branch 'upstream/master' into no-hash-type-unknownJohn Ericson
2020-06-02Merge remote-tracking branch 'upstream/master' into ↵John Ericson
validPathInfo-ca-proper-datatype
2020-06-02Merge pull request #3639 from obsidiansystems/do-fixme-store-removesEelco Dolstra
Remove `addToStore` variant as requested by `FIXME`
2020-06-02WIPJohn Ericson
2020-06-01use Tree ctorMatthew Kenigsberg
2020-06-01Tree ctorsMatthew Kenigsberg
2020-05-30Ensure we restrict refspec interpretation while fetchingNikola Knezevic
As `git fetch` may chose to interpret refspec to it's liking, ensure that we only pass refs that begin with `refs/` as is, otherwise, prepend them with `refs/heads`. Otherwise, branches named `heads/foo` (I know it's bad, but it's allowed), would be fetched as `foo`, instead of `heads/foo`.
2020-05-30Improve ref validity checking in fetchGitNikola Knezevic
The previous regex was too strict and did not match what git was allowing. It could lead to `fetchGit` not accepting valid branch names, even though they exist in a repository (for example, branch names containing `/`, which are pretty standard, like `release/1.0` branches). The new regex defines what a branch name should **NOT** contain. It takes the definitions from `refs.c` in https://github.com/git/git and `git help check-ref-format` pages. This change also introduces a test for ref name validity checking, which compares the result from Nix with the result of `git check-ref-format --branch`.
2020-05-30Move substitution into Input::fetch()Eelco Dolstra
Closes #3520.
2020-05-30Check revCount / lastModified input attributes if specifiedEelco Dolstra
2020-05-30Remove TreeInfoEelco Dolstra
The attributes previously stored in TreeInfo (narHash, revCount, lastModified) are now stored in Input. This makes it less arbitrary what attributes are stored where. As a result, the lock file format has changed. An entry like "info": { "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github" }, is now stored as "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github", "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, The 'Input' class is now a dumb set of attributes. All the fetcher implementations subclass InputScheme, not Input. This simplifies the API. Also, fix substitution of flake inputs. This was broken since lazy flake fetching started using fetchTree internally.
2020-05-29Remove addToStore variant as requested by `FIXME`John Ericson
The idea is it's always more flexible to consumer a `Source` than a plain string, and it might even reduce memory consumption. I also looked at `addToStoreFromDump` with its `// FIXME: remove?`, but the worked needed for that is far more up for interpretation, so I punted for now.
2020-05-29Factor out GitHub / GitLab commonalityEelco Dolstra
2020-05-28add gitlab libfetcherFinn Behrens
2020-05-28Fixing the result of mergeCarlo Nucera
2020-05-26Change remaining bools with FileIngestionMethodCarlo Nucera
2020-05-13Update src/libfetchers/git.ccEelco Dolstra
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2020-05-10SimplifyEelco Dolstra
2020-04-27Improve path:// handlingEelco Dolstra
In particular, doing 'nix build /path/to/dir' now works if /path/to/dir is not a Git tree (it only has to contain a flake.nix file). Also, 'nix flake init' no longer requires a Git tree (but it will do a 'git add flake.nix' if it's a Git tree)
2020-04-22Path fetcher: Fix store path nameEelco Dolstra
(cherry picked from commit c7af247beacd418e6f2c4d33dffc35299101cd12)