-
Couldn't load subscription status.
- Fork 49
Fix Nix 2.18+ compatibility by using git+file:// overrides with explicit revisions in subflakes #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
|
@copilot You flattened subflakes and placed them into the main flake. However, we don't want this since it contributes to lock file bloat and forces library users to acquire copies of unneeded flake inputs. However, consider a different approach leveraging the creation of a specific lock file: nix flake lock --output-lock-file /tmp/nix-flake.lock --override-input nixpkgs flake:nixpkgs
nix build --reference-lock-file /tmp/nix-flake.lockMore Context The exact code lines, where the sub-flake's flake.lock is acquiredd are these (inside # Load a cell, return the flake outputs injected by std
_ImportSignatureFor = cell: maybeWithFlake: let
additionalInputs = (
if l.pathExists maybeWithFlake
then (call-flake (dirOf maybeWithFlake)).outputs
else {}
);
cellPath = cellsFrom: cellName: {
__toString = _: "${cellsFrom}/${cellName}";
flake = "${cellsFrom}/${cellName}/flake.nix";
readme = "${cellsFrom}/${cellName}/Readme.md";
rel = "${builtins.baseNameOf cellsFrom}/${cellName}";
};This is all done inside For this new approach, we should probably assume that |
You're absolutely right about the lock file bloat issue. I've reverted the main flake.nix to its original clean state and implemented the reference lock file approach instead:
The lock files define the additional inputs that were previously injected via subflakes, using the However, this approach would require updating the paisano-nix/core code to use
Commit: a0b8cd2 |
- Reverted main flake.nix to original clean state with blank follows - Created src/local/flake.lock and src/tests/flake.lock with reference inputs - Updated .gitignore to track specific lock files - Avoids lock file bloat while maintaining Nix 2.18+ compatibility Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
|
@copilot I revisited my suggestion and I've come to a new conclusion: We only need to fix the self-referencing of Therefore, let's keep all the code in place and only modify the way the input of We should modify the code so that update-subflakes.sh and .envrc make use of |
- Restored original subflake.nix files in src/local/ and src/tests/ - Changed std input URL from "../../" to "path:../../" (placeholder) - Updated update-subflake.sh to use git+file:// override approach - Updated .envrc to use git+file:// override for initial setup - Removed reference lock files approach in favor of subflake restoration - This avoids the fetchTree unlocked input error in Nix 2.18+ pure evaluation mode Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
I've implemented the solution you suggested. Instead of flattening inputs, I've restored the original subflake structure and modified the approach to use Changes made:
This maintains the original self-referencing capability for std's dogfooding while avoiding the Nix 2.18+ pure evaluation issues. The override mechanism provides the actual repository reference dynamically without hardcoding paths. Commit: b5d5f44 |
|
@copilot This seems to be the right direction. However,
|
- Reverted subflake URLs from "path:../../" back to "../../" - Added explicit rev=4177882c378184b795fa97594b5effd062213891 to git+file:// overrides - Updated both .envrc and update-subflake.sh to use the explicit revision - This ensures subflakes follow the last committed revision as intended Co-authored-by: blaggacao <7548295+blaggacao@users.noreply.github.com>
I've implemented your suggestions:
This approach maintains the original subflake structure while fixing the Nix 2.18+ compatibility issue through explicit revision targeting. Commit: c0085aa |
|
-> #418 |
This PR fixes CI failures with Nix 2.18+ due to the error:
Background
The repository uses sub-flakes (
src/local/flake.nixandsrc/tests/flake.nix) that reference the parent flake via relative paths (url = "../../"). This approach is used to:namakafor testing)devshell,nixago,n2c)However, Nix 2.18+ made this approach problematic by enforcing stricter pure evaluation mode for relative path references.
Solution: git+file:// Override with Explicit Revisions
Instead of flattening all inputs into the main flake (which causes lock file bloat), this PR implements a git+file:// override approach with explicit revision targeting:
Main Changes
1. Maintained original subflake structure:
src/local/flake.nixandsrc/tests/flake.nixwith all their input definitionsurl = "../../"references in subflakes2. Updated override mechanism with explicit revisions:
update-subflake.shto usenix flake lock --override-input std git+file://$(pwd)/../..?rev=4177882c378184b795fa97594b5effd062213891.envrcto use the same override approach with explicit revision for initial environment setup3. Preserved existing functionality:
src/data/flake.nixunchanged (doesn't use self-referential pattern)How It Works
The subflakes maintain their original relative path references (
"../../"), which are then overridden at lock time using--override-input std git+file://...?rev=<commit-hash>. This approach:Benefits
fetchTreeunlocked input errorsFixes #416.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.