Remove --upgrade
, it does nothing with flakes.
j340m3:
--option tarball-ttl 0
I’d also recommend you not use this, this will essentially disable your user’s flake cache, and will cause you to hit the rate-limit sooner.
Anyway, what you want is not possible with flake inputs currently.
There’s some speculative PRs to improve the situation. Though even then, all inputs must be located in the flake.nix
, you can’t split them up into multiple files.
NixOS:master
← DeterminateSystems:lazy-flake-commands
opened 09:45PM - 06 Feb 25 UTC
<!--
IMPORTANT
Nix is a non-trivial project, so for your contribution to b… e successful,
it really is important to follow the contributing guidelines:
https://github.com/NixOS/nix/blob/master/CONTRIBUTING.md
Even if you've contributed to open source before, take a moment to read it,
so you understand the process and the expectations.
- what information to include in commit messages
- proper attribution
- volunteering contributions effectively
- how to get help and our review process.
-->
## Motivation
These don't need to evaluate anything (except for the flake metadata in `flake.nix`) so we can make these commands operate on lazy trees (i.e. without having to copy the inputs to the store) without risk of any semantic change in the evaluator.
However, as a result, `nix flake metadata` now no longer prints the store path, which is a breaking change (but unavoidable if we want lazy trees). So calls like `nix flake metadata --json | jq .path` should be replaced by `nix flake prefetch --json | jq .storePath`.
Depends on #12421.
TODO: add release note.
## Context
---
Add :+1: to [pull requests you find important](https://github.com/NixOS/nix/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc).
The Nix maintainer team uses a [GitHub project board](https://github.com/orgs/NixOS/projects/19) to [schedule and track reviews](https://github.com/NixOS/nix/tree/master/maintainers#project-board-protocol).
NixOS:master
← edolstra:lazy-trees
opened 07:10PM - 12 May 22 UTC
# Features
* Flake inputs are now only copied to the Nix store if that's act… ually needed (fixing #3121). That is, an operation like `nix build nixpkgs#hello` no longer copies the `nixpkgs` flake to the Nix store. Only an expression like `src = ./.` or `nix.registry.nixpkgs.flake = nixpkgs;` will cause an entire flake to be copied.
* `fetchTree` can now apply patches to a tree, e.g. `fetchTree { ...; patches = [ ./foo.patch ./bar.patch ]; }` (#3920). Patches are applied in memory, so this doesn't require the entire tree to be materialized to disk.
* The `github` fetcher now fetches zip archives instead of tarballs, and does not unpack them to disk. Depending on the filesystem, this can save a lot of disk space. (E.g. on ext4 with a 4 KiB block size, an unpacked Nixpkgs tree takes 252 MiB, whereas the zip archive takes 43 MiB.
# Design
The evaluator no longer accesses the filesystem directly. Instead, it uses a virtual filesystem abstraction called `InputAccessor`, which has FS operations like `readFile()` . You can get the `InputAccessor` for an `Input` by calling `Input::lazyFetch()`, which unlike `Input::fetch()` does not (necessarily) copy the input to the Nix store.
The following `InputAccessor`s currently exist:
* `FSInputAccessor`: This directly accesses the host filesystem, optionally rooted at some prefix. This is used for both non-flake evaluation (e.g. `nix-build ./foo.nix`), for `path://` flakes, and for (dirty or clean) Git working directories (`git+file://`). It optionally takes a set of allowed paths, which is used by the Git input type to ensure that you can't access untracked files.
* `MemoryInputAccessor`: An in-memory filesystem, used to provide `<nix/fetchurl.nix>`.
* `ZipInputAccessor`: An accessor that reads directly from a zipfile, using libzip. Used by the `github` fetcher.
* `PatchingInputAccessor`: An adaptor that wraps another accessor whose `readFile()` applies a patch to the file returned by the underlying accessor.
Paths are represented inside the evaluator using the `SourcePath` type, which is a tuple of an `InputAccessor` and a path relative to the root of the input. So the `SourcePath` `{input->lazyFetch(), "/flake.nix"}` represents the file `flake.nix` inside some input.
# Incompatible changes
The `outPath` attribute returned by `fetchTree` et al. is no longer a store path but a path (i.e. a `SourcePath`). This can cause some breakage, e.g. in NixOS, setting
```
nix.registry.nixpkgs.flake = nixpkgs;
```
causes the error `A definition for option 'nix.registry.nixpkgs.to.path' is not of type 'string or signed integer or boolean or package'`. Instead you have to write:
```
nix.registry.nixpkgs.flake = "${nixpkgs}";
```
to force the argument to be a store path.
# To do
- [x] Fix many test failures.
- [x] Fix showing source code in error messages. Currently the error formatter doesn't know anything about `SourcePath`s.
- [x] Give a helpful message when trying to use untracked files in a git repo (#4507).
- [x] Fix the evaluation cache.
- [x] Fix flake locking.
- [x] Get rid of the `narHash` attribute in `flake.lock`? Computing it is expensive since it requires reading the entire source tree. However, we need it to be able to substitute flake inputs, but maybe we don't care about that.
- [x] What to do with `path://` inputs? They're only locked by `narHash`, so if we don't have `narHash`, we can't lock `path://` inputs.
- [x] Fix/improve subflake handling.
- [ ] Update release notes / docs.
# Context
- Closes #3121
- Closes #3920
- Closes #5973
1 Like