lix/src
Qyriad 6881476232 libfetchers: fallback to memory SQLite if fs IO fails
nix::fetchers::CacheImpl uses $XDG_CACHE_HOME, or its default based on
$HOME, to store its SQLite database. If the current process can't write
to that directory for whatever reason, though, any eval-time fetching
would fail just initializing the cache.

With this change, IO errors initializing the fetcher cache are logged
but ignored, and nix::fetchers::CacheImpl falls back to an in-memory¹
database instead.

Notably, this will fix any uses eval fetching while Lix itself is being
run in a derivation builder (such as during tests), as the derivation
builder does not set $XDG_CACHE_HOME, and sets $HOME to the non-existent
directory /homeless-shelter.

Before:

$ env -u XDG_CACHE_HOME HOME=/homeless-shelter nix -Lv eval --impure -E 'fetchTarball "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"'
error:
       … while calling the 'fetchTarball' builtin
         at «string»:1:1:
            1| fetchTarball "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"
             | ^

       error: creating directory '/homeless-shelter': Permission denied

After:

$ env -u XDG_CACHE_HOME HOME=/homeless-shelter nix -Lv eval --impure -E 'fetchTarball "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"'
warning: ignoring error initializing Lix fetcher cache: error: creating directory '/homeless-shelter': Permission denied
"/nix/store/s9lxdnn0awp37n560bg4fgr497ah4hvw-source"

¹: https://www.sqlite.org/inmemorydb.html

Change-Id: I15c38c9baaf215fc6e192b8a4c70b9692a69bc22
2024-05-21 09:30:25 -06:00
..
build-remote Remove HintFmt::operator% 2024-03-26 15:40:05 -07:00
libcmd print type and value in "flake attr is not a derivation" errors 2024-05-21 05:55:13 -06:00
libexpr Merge "primops: change to std::function, allowing the passing of user data" into main 2024-05-17 21:37:41 +00:00
libfetchers libfetchers: fallback to memory SQLite if fs IO fails 2024-05-21 09:30:25 -06:00
libmain libutil: remove the interrupt-blocking code 2024-05-13 09:03:53 +02:00
libstore Merge "libutil: Create chmodPath function" into main 2024-05-20 15:13:53 +00:00
libutil Merge "libutil: Create chmodPath function" into main 2024-05-20 15:13:53 +00:00
nix nix cat/dump-path/key: stop progress bar before writeFull 2024-05-18 17:51:16 +00:00
nix-build Move shell_words into its own file 2024-03-26 16:44:04 -07:00
nix-channel Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
nix-collect-garbage util.hh: split out signals stuff 2024-03-11 00:52:09 -07:00
nix-copy-closure Merge pull request #9277 from keszybz/file-permissions 2024-03-04 05:26:17 +01:00
nix-env refactor some nix-env and profile code to libcmd 2024-04-29 01:19:21 +00:00
nix-instantiate Unify and refactor value printing 2024-03-09 03:50:06 +01:00
nix-store libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00
resolve-system-dependencies remove the autoconf+Make buildsystem 2024-05-07 17:04:30 -06:00
meson.build meson: implement functional tests 2024-03-27 18:37:50 -06:00