mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
This is useful for frameworks (such as flake-parts) to avoid unnecessary evaluation. See discussion here: https://github.com/hercules-ci/flake-parts/issues/288#issuecomment-2912459614 While digging into this, I discovered that `nix fmt` already handles `null` formatters identically to undefined formatters. I added a couple of tests to demonstrate this behavior. `nix flake show` needs some reworking to avoid crashing with a "error: expected a derivation" when it encounters a `null` formatter or package. My changes here avoid the crash, but has some cosmetic issues, which is why I've labeled this PR as a draft. Cosmetic issues =============== With the following `flake.nix`: ```nix { outputs = _: { packages.x86_64-linux.default = null; }; } ``` `nix flake show` shows a weird empty system: ``` $ nix flake show path:/tmp/tmp.uL0iGuNwXB?lastModified=1748472558&narHash=sha256-tC%2BhdXAyoeFvWHNllJbois8X%2B7wpZ6CJzEzbcaGQxtM%3D └───packages └───x86_64-linux ``` Similarly, `nix flake show --json` includes an empty object: ``` $ nix flake show --json { "packages": { "x86_64-linux": { "default": null } } } ``` `nix build` crashes: ``` $ nix build .#default error: expected flake output attribute 'packages.x86_64-linux.default' to be a derivation or path but found null: null ``` |
||
---|---|---|
.. | ||
functional | ||
installer | ||
nixos | ||
repl-completion.nix |