1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00
Commit graph

186 commits

Author SHA1 Message Date
Eelco Dolstra
59c7dac867 Git fetcher: Do not consider a null revision (i.e. workdir) to be locked 2025-06-17 10:55:23 +02:00
Jörg Thalheim
0479db934c fetchGit: don't compute revCount on shallow repository
This can never work and leads to a crash bug.
2025-05-26 09:56:44 +02:00
Eelco Dolstra
efcb9e36a9 Remove global fetcher cache
The cache is now part of fetchers::Settings.
2025-05-17 19:54:32 +02:00
Jörg Thalheim
5b59be914d Replace symlink_exists with pathExists
As it turns out the orignal implementation of symlink_exists cannot be
used in Nix because it did now std::filesystem::filesystem_error.
The new implementation fixes that but is now actually the same as
pathExists except for the path type.
2025-05-01 14:22:35 +02:00
Jörg Thalheim
b3bbbd2e71 fix armv7/i686 build 2025-04-17 13:56:11 +02:00
John Ericson
652a628d1c Fix windows build 2025-04-02 15:17:26 -04:00
mergify[bot]
70dcd738ef
Merge pull request #12870 from DeterminateSystems/improve-git-error
Git fetcher: Improve error message for untracked files
2025-04-02 15:39:35 +00:00
Eelco Dolstra
f15681df26 Make Git error messages more consistent 2025-04-02 12:58:53 +02:00
Eelco Dolstra
277c29a64b Tweak error message 2025-04-02 12:58:11 +02:00
Graham Christensen
62e2304891 Improve and fix the error message when a file is not tracked by Git 2025-04-02 12:58:06 +02:00
John Ericson
cc24766fa6 Expose the nix component in header include paths
For example, instead of doing

    #include "nix/store-config.hh"
    #include "nix/derived-path.hh"

Now do

    #include "nix/store/config.hh"
    #include "nix/store/derived-path.hh"

This was originally planned in the issue, and also recent requested by
Eelco.

Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.

Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!

Progress on #7876
2025-04-01 11:40:42 -04:00
John Ericson
f3e1c47f47 Separate headers from source files
The short answer for why we need to do this is so we can consistently do
`#include "nix/..."`. Without this change, there are ways to still make
that work, but they are hacky, and they have downsides such as making it
harder to make sure headers from the wrong Nix library (e..g.
`libnixexpr` headers in `libnixutil`) aren't being used.

The C API alraedy used `nix_api_*`, so its headers are *not* put in
subdirectories accordingly.

Progress on #7876

We resisted doing this for a while because it would be annoying to not
have the header source file pairs close by / easy to change file
path/name from one to the other. But I am ameliorating that with
symlinks in the next commit.
2025-03-31 12:20:25 -04:00
Jörg Thalheim
e9f1761597 libfetchers/git: fix caching head when using shallow clones
the old code was using the wrong cache directory, which lead to a
warning on every nix flake update

Update src/libfetchers/git.cc
2025-03-12 22:32:05 +01:00
Jörg Thalheim
559a2d1bc7 libfetchers/git: fix double quoting in error message 2025-03-07 04:00:22 +01:00
Robert Hensing
30694b5d8a refactor: RAII logger suspension 2025-03-04 19:48:22 +01:00
Eelco Dolstra
d7f2c1b7f4 Remove mounted-source-accessor.hh 2025-02-19 10:44:46 +01:00
Eelco Dolstra
1cb9a354fb Merge remote-tracking branch 'origin/master' into lfs 2025-02-10 14:46:01 +01:00
John Ericson
a562d0b6ce
Merge pull request #12386 from DeterminateSystems/git-fixes
Git fetcher: Don't create refs when fetching by revision
2025-02-05 15:18:58 -05:00
Leandro Reina
134530a534 Merge remote-tracking branch 'upstream/master' into lfs 2025-02-03 19:07:20 +01:00
Eelco Dolstra
c8b22643ba readHead(): Make sure we're returning the HEAD ref line
If we previously fetched by revision, the output of "git ls-remote"
won't start with the expected line like

  ref: refs/heads/master HEAD

but will be something like

  5c4410e3b9891c05ab40d723de78c6f0be45ad30        refs/heads/5c4410e3b9891c05ab40d723de78c6f0be45ad30

This then causes Nix to treat that revision as a refname, which then
leads to warnings like

  warning: could not update cached head '5c4410e3b9891c05ab40d723de78c6f0be45ad30' for 'file:///tmp/repo'
2025-01-30 19:03:34 +01:00
Eelco Dolstra
ee9fa0d360 Git fetcher: Don't use refspec <rev>:<rev>
This causes Git to create a local ref named refs/head/<rev>, e.g.

  $ git -C ~/.cache/nix/gitv3/11irpim06vj4h6c0w8yls6kx4hvl0qd0gr1fvk47n76g6wf1s1vk ls-remote --symref .
  5c4410e3b9891c05ab40d723de78c6f0be45ad30        refs/heads/5c4410e3b9891c05ab40d723de78c6f0be45ad30
  7f6bde8a20de4cccc2256f088bc5af9dbe38881d        refs/heads/7f6bde8a20de4cccc2256f088bc5af9dbe38881d

which confuses readHead(), leading to errors like

  fatal: Refusing to point HEAD outside of refs/
  warning: could not update cached head 'd275d93aa0bb8a004939b2f1e87f559f989453be' for 'file:///tmp/repo'
2025-01-30 19:03:34 +01:00
Eelco Dolstra
9f72d5bce9 Git fetcher: Don't pass URL query parameters for file:// URLs
Git interprets them as part of the file name, so passing parameters
like 'rev' breaks. Only relevant for testing (when _NIX_FORCE_HTTP is
set) and local bare repos.
2025-01-30 19:03:34 +01:00
Eelco Dolstra
3032512425 GitExportIgnoreSourceAccessor: Don't show «unknown»
In general we should set the path display prefix on the inner
accessor, so we now pass the display prefix to getAccessor().
2025-01-30 12:41:02 +01:00
Eelco Dolstra
102d90ebf0 Fix duplicate setPathDisplay()
Fixes messages like 'copying /tmp/repo/tmp/repo to the store'. The
PosixSourceAccessor already sets the prefix. Setting the prefix twice
shouldn't be a problem, but GitRepoImpl::getAccessor() returns a
wrapped accessor so it's not actually idempotent.
2025-01-30 11:27:24 +01:00
Leandro Reina
40a3007b7c Merge remote-tracking branch 'upstream/master' into lfs 2025-01-21 14:16:42 +01:00
Eelco Dolstra
a78f55ef97 GitInputScheme: Fix mingw build
Mingw apparently is less smart about coercing std::filesystem::path into strings.
2025-01-20 15:39:14 +01:00
Eelco Dolstra
f5548c17ed getSourcePath(): Return std::filesystem::path 2025-01-17 13:21:53 +01:00
Eelco Dolstra
9003343b53 Git fetcher: Replace RepoInfo::url by a std::variant
Previously the 'url' field was either a path or a URL, depending on
'isLocal'. This replaces both fields by a std::variant, which is more
type-safe.
2025-01-17 13:21:53 +01:00
Eelco Dolstra
3197c19a31 Add link to tracking issue 2025-01-17 12:34:38 +01:00
Eelco Dolstra
12e14956e2 Warn against the use of relative 'git+file:' flake inputs 2025-01-16 17:23:31 +01:00
Leandro Reina
b08b7bee4e Merge remote-tracking branch 'upstream/master' into lfs 2025-01-10 18:33:03 +01:00
Bryan Lai
96bd9bad2f fetchers/git: make path absolute for local repo 2025-01-10 11:37:29 +08:00
Eelco Dolstra
4077aa43a8 ParsedURL: Remove base field 2025-01-07 14:52:00 +01:00
Leandro Reina
7756b2286d Merge remote-tracking branch 'upstream/master' into lfs 2024-12-18 18:18:45 +01:00
Eelco Dolstra
33852ead6b Optimisation 2024-12-17 12:56:14 +01:00
Eelco Dolstra
7ba933e989 Cache calls to GitRepo::getWorkdirInfo()
A command like `nix flake metadata` was causing about 4 calls to
getWorkdirInfo(), which is slow for large repos (even when they're not
dirty).
2024-12-17 12:56:14 +01:00
Eelco Dolstra
d044a05197 Don't fingerprint dirty repos with submodules for now
Fixes nixpkgsLibTests.
2024-12-17 12:56:14 +01:00
Eelco Dolstra
331bf3e261 Git fetcher: Calculate a fingerprint for dirty workdirs
This restores evaluation caching for dirty Git workdirs.
2024-12-17 12:56:14 +01:00
Brian Camacho
169d62a382 Merge branch 'master' into lfs 2024-12-02 15:06:28 -05:00
Leandro Reina
38fb40204f Fix lfs toURL missing argument 2024-11-25 21:01:47 +01:00
Leandro Reina
d201b2872e Pass lfs flag to submodules 2024-11-25 21:01:16 +01:00
Sergei Zimmerman
756758d968 chore: get rid of dead code and unused variables where appropriate
Looks like some cruft has been left over from previous refactorings.
This removes dead variables, which should not have side effects in their
constructors. In cases where the variable initialization has a purpose
[[maybe_unused]] is inserted to silence compiler warnings.
2024-11-22 18:05:53 +03:00
Brian Camacho
f67b63fa3a remove debug prints 2024-11-18 01:21:14 -05:00
Brian Camacho
9a6388dce6 logs around getFingerprint 2024-11-12 02:17:06 -05:00
Brian Camacho
741a54df8f tweak url parsing; add test case 2024-11-07 23:29:39 -05:00
Brian Camacho
99705c6932 Merge remote-tracking branch 'origin/master' into lfs 2024-11-06 15:18:21 -05:00
Brian Camacho
f4962fe59b working smudge for GitSourceAccessor 2024-11-01 03:37:48 -04:00
Eelco Dolstra
15e5684884 experimental-features.hh: Don't include json-utils.hh
This caused nlohmann/json.hpp to leak into a lot of compilation units,
which is slow (when not using precompiled headers).

Cuts build time from 46m24s to 42m5s (real time with -j24: 2m42s to
2m24s).
2024-10-04 15:59:35 +02:00
Eelco Dolstra
1c2508f176
Merge pull request #11466 from DeterminateSystems/git-mtime-warning
Git fetcher: Don't update mtime of ref file if fetching by rev
2024-09-11 17:34:46 +02:00
Noam Yorav-Raphael
38bfbb297c
Use envvars NIX_CACHE_HOME, NIX_CONFIG_HOME, NIX_DATA_HOME, NIX_STATE_HOME if defined (#11351) 2024-09-11 10:36:46 +00:00