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
```
Since the migration to meson precompiled-headers.h isn't actually used
anymore and is just confusing. Meson can't handle shared pch across
subprojects [1] and without that there's no performances benefit of PCH
at all. Also rolling our own support for that isn't trivial. See [2] for
an example of how that would look like.
[1]: https://github.com/mesonbuild/meson/issues/4350
[2]: 22bc8b6473/plugins/meson.build
Clang doesn't like the double indent that is needed for the `if...else`
that is CPP'd away. Adding braces is fine in the `if...else...` case,
and fine as a naked block in the CPP'd away case, and properly-indented
both ways.
These tests have been collected from nixpkgs f870c6ccc8951fc48aeb293cf3e98ade6ac42668
usage of builtins.match for x86_64-linux eval system. At most 2 matching and
non-matching cases are included for each encountered regex. This should
hopefully add more confidence when possibly trying to switch the regex implementation
in the future.
This is the utility changes from #9968, which were easier to rebase
first.
I (@Ericson2314) didn't write this code; I just rebased it.
Co-Authored-By: Artemis Tosini <me@artem.ist>
Co-Authored-By: Audrey Dutcher <audrey@rhelmot.io>
Allows to copy the archive to a remote host and not get
error: cannot add path '/nix/store/01x2k4nlxcpyd85nnr0b9gm89rm8ff4x-source' because it lacks a signature by a trusted key
Before we got something like this but only inside the VM test:
vm-test-run-functional-tests-on-nixos_user> machine # fetchGit.sh: line 286: unexpected EOF while looking for matching `)'
We now try to do not too much in a single line, so that the bash parser does not get confused.
This also seems more readable and better quoted.