| 8 Dec 2025 |
Sergei Zimmerman (xokdvium) | FML. That is fixed on 2.32. Basically it doesn't do pct-decoding as it should:
commit 196c21c5a0e2f9b3149689ea36789cf0478d893a
Author: Farid Zakaria <farid.m.zakaria@gmail.com>
Date: Wed Jul 16 21:09:59 2025 -0700
Add helpful messages when file:// used as tarball
When `file://` is used accidentally in a flake as the source it is
expected to be a tarball by default.
Add some friendlier error messages to either inform the user this is not
in fact a tarball or if it's a git directory, let them know they can use
`git+file`.
fixes #12935
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc
index b0822cc33..59316eabd 100644
--- a/src/libfetchers/tarball.cc
+++ b/src/libfetchers/tarball.cc
@@ -111,6 +111,25 @@ static DownloadTarballResult downloadTarball_(
const Headers & headers,
const std::string & displayPrefix)
{
+
+ // Some friendly error messages for common mistakes.
+ // Namely lets catch when the url is a local file path, but
+ // it is not in fact a tarball.
+ if (url.rfind("file://", 0) == 0) {
+ // Remove "file://" prefix to get the local file path
+ std::string localPath = url.substr(7);
+ if (!std::filesystem::exists(localPath)) {
+ throw Error("tarball '%s' does not exist.", localPath);
+ }
+ if (std::filesystem::is_directory(localPath)) {
+ if (std::filesystem::exists(localPath + "/.git")) {
+ throw Error(
+ "tarball '%s' is a git repository, not a tarball. Please use `git+file` as the scheme.", localPath);
+ }
+ throw Error("tarball '%s' is a directory, not a file.", localPath);
+ }
+ }
+
Cache::Key cacheKey{"tarball", {{"url", url}}};
auto cached = settings.getCache()->lookupExpired(cacheKey);
| 12:38:19 |
Sergei Zimmerman (xokdvium) | Specifically this:
std::string localPath = url.substr(7);
+ if (!std::filesystem::exists(localPath)) {
+ throw Error("tarball '%s' does not exist.", localPath);
+ }
| 12:38:59 |
Sergei Zimmerman (xokdvium) | Basically it will fail shamefully when encountering a symbol that gets pct-encoded in the file:// URL and barf early even though the later fetching code does the decoding correctly and since NIX_BUILD_TOP is in a dir that has + in it... | 12:41:56 |
dramforever | oooh this is why it only fails if no sandbox | 12:43:24 |
Sergei Zimmerman (xokdvium) | Yup... | 12:43:39 |
dramforever | oh | 12:46:04 |
dramforever | duh | 12:46:07 |
dramforever | i was trying to --no-sandbox and i don't think that does anything... | 12:46:20 |
dramforever | probably for the better | 12:46:34 |
dramforever | this is fixed but it's so un-cherry-pick-able | 13:02:48 |
dramforever | there's like a whole new url parsing infrastructure thing added on | 13:03:08 |
Sergei Zimmerman (xokdvium) | Yeah, I know. Probably just doing a percentDecode on the localPath would be enough | 13:03:42 |
dramforever | update on that is i just realized i can repro this locally on linux if i just do sandbox = false | 16:43:58 |
dramforever | so i'm running a build with this patch https://github.com/NixOS/nix/pull/14734 | 16:44:11 |
dramforever | hopefully that would fix it | 16:44:30 |
Mic92 | John Ericson: looks like there is some issue now when using the current stable nix against a new nix daemon?
clan-env % nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', searching up
error:
… while checking derivation '/nix/store/v8qnm8aabm0fp0v2xf3cavsgwqfgc2bk-clan-env.drv'
error: derivation has incorrect deferred output, should be '/nix/store/jq6nq5bvdv23xdjajsaj2ay6vni5bkki-clan-env'
clan-env % real-which nix
/nix/store/ah8kqqslr7jig18fd4hzmdk2bhbqs8a7-nix-2.31.2/bin/nix
clan-env % /nix/store/7ykgjirdiwxkdwyh3hypd27ifx7aws29-nix-2.33.0pre20251208_5b5d4cb/bin/nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', [joerg@eve clan-cli]$
| 16:50:58 |
dramforever | nevermind | 17:01:56 |
dramforever | the tests just fail on linux without sandbox... | 17:02:15 |
dramforever | what the heck | 17:02:20 |
John Ericson | In reply to @joerg:thalheim.io
John Ericson: looks like there is some issue now when using the current stable nix against a new nix daemon?
clan-env % nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', searching up
error:
… while checking derivation '/nix/store/v8qnm8aabm0fp0v2xf3cavsgwqfgc2bk-clan-env.drv'
error: derivation has incorrect deferred output, should be '/nix/store/jq6nq5bvdv23xdjajsaj2ay6vni5bkki-clan-env'
clan-env % real-which nix
/nix/store/ah8kqqslr7jig18fd4hzmdk2bhbqs8a7-nix-2.31.2/bin/nix
clan-env % /nix/store/7ykgjirdiwxkdwyh3hypd27ifx7aws29-nix-2.33.0pre20251208_5b5d4cb/bin/nix develop
path '/home/joerg/git/clan-core/pkgs/clan-cli' does not contain a 'flake.nix', [joerg@eve clan-cli]$
Woah! | 17:02:25 |
John Ericson | Are you doing CA derivations? | 17:02:31 |
Sergei Zimmerman (xokdvium) | In reply to @dramforever:matrix.org the tests just fail on linux without sandbox... Let me guess, `/homeless-shelter’ exists? | 17:04:27 |
dramforever | i don't think so | 17:05:11 |
dramforever | i can try to mess with sandbox-build-dir though | 17:08:35 |
dramforever | maybe it's some cgroup and auto-allocate-uids stuff? | 17:18:34 |
Mic92 | no. | 17:29:44 |
Mic92 | no to what? | 17:37:20 |
Mic92 | Probably should be merged before the release: https://github.com/NixOS/nix/pull/14739 | 20:16:00 |
Mic92 | https://github.com/NixOS/nix/pull/14743 and now this one as well | 22:27:09 |
| 9 Dec 2025 |
Eelco | Release notes PR, please add anything relevant that's missing: https://github.com/NixOS/nix/pull/14752 | 15:57:43 |