nix build --all: build all packages in a flake
Opened this issue Β· 17 comments
There's currently no way to build all packages in a flake, a quite common operation that was previously just nix-build
.
You can see here people struggling: https://www.reddit.com/r/NixOS/comments/vohopf/is_there_an_easy_way_to_build_all_the_packages_of/
A possible workaround is to add all packages as "checks" and then "nix flake check" will build all.
Related: #7157 (comment)
There is also a workaround using symlinkJoin
and defining an all
default package. You can find an example of this in this article in the section titled "The Flake"
just ran into the same issue.
what if we could just add the --all
feature to flakes which builds all packages as expected?
just ran into the same issue.
what if we could just add the--all
feature to flakes which builds all packages as expected?
That's what I assumed already existed, at least.
Or, when no default package is set, that "nix build" would build everything.
What should be the output of --all
? For instance, should it result in a bunch of result-{1,2,3,4,5}
symlinks?
What should be the output of
--all
? For instance, should it result in a bunch ofresult-{1,2,3,4,5}
symlinks?
Good question. I guess this would clutter your workspace on larger package sets.
Iβd like a folder in the nix store which holds a list of symlinks to every single package
So it'll basically implicitly create a new derivation using --all
?
linkFarm [
{ name = "packagea"; path = packages.${system}.packagea }
{ name = "packageb"; path = packages.${system}.packageb }
{ name = "packageb"; path = packages.${system}.packageb }
]
Resulting in a result
symlink:
result/packagea -> /nix/store/...-packagea/
result/packageb -> /nix/store/...-packageb/
result/packagec -> /nix/store/...-packagec/
I'm not sure I like the approach, as it is non-transparent if Nix is going to build derivations implicitly.
It could also be a convention or even a default to make packages.${system}.default
or packages.${system}.all
use the linkFarm
approach. If it was a convention, a helper function that creates a 'package set' derivation would be useful.
Then it would work without needing a --all
option.
I don't like it, shouldn't have to depend on nixpkgs
in my opinion. Moreover derivations can have multiple outputs (can't remember how nix build
manages it currently, not even sure it does).
What do you think is the better approach to solve the issue?
shouldn't have to depend on nixpkgs in my opinion
There could also be a builtin for creating a 'package set', but I would agree is it's not ideal.
Moreover derivations can have multiple outputs
Indeed, that's why I thought earlier that it would output result-{1,2,3,4,5}
.
Would it output result-{packagea,packageb,packagec}
instead?
I meant multiple outputs per single derivation, so something like result-{drvName}-{outputName}
.
This seems to be a duplicate of #3811, though I would vote to close the older issue, as there is more discussion in this thread here.
The gist of #3811 is that the behavior of nix build --all
is not intuitively well-defined, as a flake can have any number of outputs, of which only some are known.
For example, the nix repo itself has all these outputs:
There's a lot, click here to expand...
$ nix flake show
git+file:///Users/feuh/repos/nix
ββββchecks
β ββββaarch64-darwin
β β ββββbinaryTarball: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββinstallTests: derivation 'install-tests'
β β ββββnixpkgsLibTests: derivation 'nixpkgs-lib-tests'
β β ββββperlBindings: derivation 'nix-perl-2.21.0pre20240305_dirty'
β β ββββrl-next: derivation 'test-rl-next-release-notes'
β ββββaarch64-linux
β β ββββbinaryTarball omitted (use '--all-systems' to show)
β β ββββdockerImage omitted (use '--all-systems' to show)
β β ββββinstallTests omitted (use '--all-systems' to show)
β β ββββnixpkgsLibTests omitted (use '--all-systems' to show)
β β ββββperlBindings omitted (use '--all-systems' to show)
β β ββββrl-next omitted (use '--all-systems' to show)
β ββββi686-linux
β β ββββbinaryTarball omitted (use '--all-systems' to show)
β β ββββinstallTests omitted (use '--all-systems' to show)
β β ββββnixpkgsLibTests omitted (use '--all-systems' to show)
β β ββββperlBindings omitted (use '--all-systems' to show)
β β ββββrl-next omitted (use '--all-systems' to show)
β ββββx86_64-darwin
β β ββββbinaryTarball omitted (use '--all-systems' to show)
β β ββββinstallTests omitted (use '--all-systems' to show)
β β ββββnixpkgsLibTests omitted (use '--all-systems' to show)
β β ββββperlBindings omitted (use '--all-systems' to show)
β β ββββrl-next omitted (use '--all-systems' to show)
β ββββx86_64-linux
β ββββbinaryTarball omitted (use '--all-systems' to show)
β ββββdockerImage omitted (use '--all-systems' to show)
β ββββinstallTests omitted (use '--all-systems' to show)
β ββββnixpkgsLibTests omitted (use '--all-systems' to show)
β ββββperlBindings omitted (use '--all-systems' to show)
β ββββrl-next omitted (use '--all-systems' to show)
ββββdevShells
β ββββaarch64-darwin
β β ββββarmv6l-unknown-linux-gnueabihf: development environment 'nix-armv6l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β β ββββarmv7l-unknown-linux-gnueabihf: development environment 'nix-armv7l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β β ββββdefault: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββnative-ccacheStdenvPackages: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββnative-clangStdenvPackages: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββnative-gccStdenvPackages: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββnative-libcxxStdenvPackages: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββnative-stdenvPackages: development environment 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-freebsd13: development environment 'nix-x86_64-unknown-freebsd13-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-netbsd: development environment 'nix-x86_64-unknown-netbsd-2.21.0pre20240305_dirty'
β β ββββx86_64-w64-mingw32: development environment 'nix-x86_64-w64-mingw32-2.21.0pre20240305_dirty'
β ββββaarch64-linux
β β ββββarmv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββarmv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββdefault omitted (use '--all-systems' to show)
β β ββββnative-ccacheStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-clangStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-gccStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-libcxxStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-stdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-ccacheStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-clangStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-gccStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-libcxxStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-stdenvPackages omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-netbsd omitted (use '--all-systems' to show)
β β ββββx86_64-w64-mingw32 omitted (use '--all-systems' to show)
β ββββi686-linux
β β ββββarmv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββarmv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββdefault omitted (use '--all-systems' to show)
β β ββββnative-ccacheStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-clangStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-gccStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-libcxxStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-stdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-ccacheStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-clangStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-gccStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-libcxxStdenvPackages omitted (use '--all-systems' to show)
β β ββββstatic-stdenvPackages omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-netbsd omitted (use '--all-systems' to show)
β β ββββx86_64-w64-mingw32 omitted (use '--all-systems' to show)
β ββββx86_64-darwin
β β ββββarmv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββarmv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β β ββββdefault omitted (use '--all-systems' to show)
β β ββββnative-ccacheStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-clangStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-gccStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-libcxxStdenvPackages omitted (use '--all-systems' to show)
β β ββββnative-stdenvPackages omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β β ββββx86_64-unknown-netbsd omitted (use '--all-systems' to show)
β β ββββx86_64-w64-mingw32 omitted (use '--all-systems' to show)
β ββββx86_64-linux
β ββββarmv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββarmv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββdefault omitted (use '--all-systems' to show)
β ββββnative-ccacheStdenvPackages omitted (use '--all-systems' to show)
β ββββnative-clangStdenvPackages omitted (use '--all-systems' to show)
β ββββnative-gccStdenvPackages omitted (use '--all-systems' to show)
β ββββnative-libcxxStdenvPackages omitted (use '--all-systems' to show)
β ββββnative-stdenvPackages omitted (use '--all-systems' to show)
β ββββstatic-ccacheStdenvPackages omitted (use '--all-systems' to show)
β ββββstatic-clangStdenvPackages omitted (use '--all-systems' to show)
β ββββstatic-gccStdenvPackages omitted (use '--all-systems' to show)
β ββββstatic-libcxxStdenvPackages omitted (use '--all-systems' to show)
β ββββstatic-stdenvPackages omitted (use '--all-systems' to show)
β ββββx86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β ββββx86_64-unknown-netbsd omitted (use '--all-systems' to show)
β ββββx86_64-w64-mingw32 omitted (use '--all-systems' to show)
ββββhydraJobs
β ββββbinaryTarball
β β ββββaarch64-darwin: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β ββββbinaryTarballCross
β β ββββx86_64-linux
β β ββββarmv6l-unknown-linux-gnueabihf: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββarmv7l-unknown-linux-gnueabihf: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-freebsd13: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-netbsd: derivation 'nix-binary-tarball-2.21.0pre20240305_dirty'
β ββββbuild
β β ββββaarch64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β ββββbuildCross
β β ββββarmv6l-unknown-linux-gnueabihf
β β β ββββx86_64-linux: derivation 'nix-armv6l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β β ββββarmv7l-unknown-linux-gnueabihf
β β β ββββx86_64-linux: derivation 'nix-armv7l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-freebsd13
β β β ββββx86_64-linux: derivation 'nix-x86_64-unknown-freebsd13-2.21.0pre20240305_dirty'
β β ββββx86_64-unknown-netbsd
β β ββββx86_64-linux: derivation 'nix-x86_64-unknown-netbsd-2.21.0pre20240305_dirty'
β ββββbuildNoGc
β β ββββaarch64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β ββββbuildNoTests
β β ββββaarch64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β ββββbuildReadlineNoMarkdown
β β ββββaarch64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β ββββbuildStatic
β β ββββaarch64-linux: derivation 'nix-static-aarch64-unknown-linux-musl-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-static-x86_64-unknown-linux-musl-2.21.0pre20240305_dirty'
β ββββcoverage: derivation 'nix-coverage'
β ββββdockerImage
β β ββββaarch64-linux: derivation 'docker-image-tarball-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'docker-image-tarball-2.21.0pre20240305_dirty'
β ββββinstallTests
β β ββββaarch64-darwin: derivation 'install-tests'
β β ββββaarch64-linux: derivation 'install-tests'
β β ββββi686-linux: derivation 'install-tests'
β β ββββx86_64-darwin: derivation 'install-tests'
β β ββββx86_64-linux: derivation 'install-tests'
β ββββinstallerScript: derivation 'installer-script'
β ββββinstallerScriptForGHA: derivation 'installer-script'
β ββββinstallerTests
β β ββββfedora-36
β β β ββββx86_64-linux
β β β ββββinstall-default: derivation 'installer-test-fedora-36-install-default'
β β β ββββinstall-force-daemon: derivation 'installer-test-fedora-36-install-force-daemon'
β β β ββββinstall-force-no-daemon: derivation 'installer-test-fedora-36-install-force-no-daemon'
β β ββββrhel-7
β β β ββββx86_64-linux
β β β ββββinstall-default: derivation 'installer-test-rhel-7-install-default'
β β β ββββinstall-force-daemon: derivation 'installer-test-rhel-7-install-force-daemon'
β β β ββββinstall-force-no-daemon: derivation 'installer-test-rhel-7-install-force-no-daemon'
β β ββββrhel-8
β β β ββββx86_64-linux
β β β ββββinstall-default: derivation 'installer-test-rhel-8-install-default'
β β β ββββinstall-force-daemon: derivation 'installer-test-rhel-8-install-force-daemon'
β β β ββββinstall-force-no-daemon: derivation 'installer-test-rhel-8-install-force-no-daemon'
β β ββββrhel-9
β β β ββββx86_64-linux
β β β ββββinstall-default: derivation 'installer-test-rhel-9-install-default'
β β β ββββinstall-force-daemon: derivation 'installer-test-rhel-9-install-force-daemon'
β β β ββββinstall-force-no-daemon: derivation 'installer-test-rhel-9-install-force-no-daemon'
β β ββββubuntu-16-04
β β β ββββx86_64-linux
β β β ββββinstall-default: derivation 'installer-test-ubuntu-16-04-install-default'
β β β ββββinstall-force-daemon: derivation 'installer-test-ubuntu-16-04-install-force-daemon'
β β β ββββinstall-force-no-daemon: derivation 'installer-test-ubuntu-16-04-install-force-no-daemon'
β β ββββubuntu-22-04
β β ββββx86_64-linux
β β ββββinstall-default: derivation 'installer-test-ubuntu-22-04-install-default'
β β ββββinstall-force-daemon: derivation 'installer-test-ubuntu-22-04-install-force-daemon'
β β ββββinstall-force-no-daemon: derivation 'installer-test-ubuntu-22-04-install-force-no-daemon'
β ββββinternal-api-docs: derivation 'nix-2.21.0'
β ββββmetrics
β β ββββnixpkgs: derivation 'nixpkgs-metrics'
β ββββperlBindings
β β ββββaarch64-darwin: derivation 'nix-perl-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-perl-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-perl-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-perl-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-perl-2.21.0pre20240305_dirty'
β ββββshellInputs
β β ββββaarch64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββaarch64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββi686-linux: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-darwin: derivation 'nix-2.21.0pre20240305_dirty'
β β ββββx86_64-linux: derivation 'nix-2.21.0pre20240305_dirty'
β ββββtests
β ββββauthorization: derivation 'vm-test-run-authorization'
β ββββcontainers: derivation 'vm-test-run-containers'
β ββββevalNixpkgs: derivation 'eval-nixos'
β ββββfetch-git: derivation 'vm-test-run-fetch-git'
β ββββgithubFlakes: derivation 'vm-test-run-github-flakes'
β ββββnix-copy: derivation 'vm-test-run-nix-copy'
β ββββnix-copy-closure: derivation 'vm-test-run-nix-copy-closure'
β ββββnixpkgsLibTests
β β ββββaarch64-darwin: derivation 'nixpkgs-lib-tests'
β β ββββaarch64-linux: derivation 'nixpkgs-lib-tests'
β β ββββi686-linux: derivation 'nixpkgs-lib-tests'
β β ββββx86_64-darwin: derivation 'nixpkgs-lib-tests'
β β ββββx86_64-linux: derivation 'nixpkgs-lib-tests'
β ββββnssPreload: derivation 'vm-test-run-nss-preload'
β ββββremoteBuilds: derivation 'vm-test-run-remote-builds'
β ββββremoteBuildsSshNg: derivation 'vm-test-run-remote-builds-ssh-ng'
β ββββremoteBuildsSshNg_remote_2_13: derivation 'vm-test-run-remoteBuildsSshNg_remote_2_13'
β ββββremoteBuildsSshNg_remote_2_3: derivation 'vm-test-run-remoteBuildsSshNg_remote_2_3'
β ββββremoteBuilds_local_2_13: derivation 'vm-test-run-remoteBuilds_local_2_13'
β ββββremoteBuilds_local_2_3: derivation 'vm-test-run-remoteBuilds_local_2_3'
β ββββremoteBuilds_remote_2_13: derivation 'vm-test-run-remoteBuilds_remote_2_13'
β ββββremoteBuilds_remote_2_3: derivation 'vm-test-run-remoteBuilds_remote_2_3'
β ββββsetuid
β β ββββi686-linux: derivation 'vm-test-run-setuid'
β β ββββx86_64-linux: derivation 'vm-test-run-setuid'
β ββββsourcehutFlakes: derivation 'vm-test-run-sourcehut-flakes'
β ββββtarballFlakes: derivation 'vm-test-run-tarball-flakes'
ββββoverlays
β ββββdefault: Nixpkgs overlay
ββββpackages
ββββaarch64-darwin
β ββββchangelog-d-nix: package 'changelog-d-0.1-git-f30f696'
β ββββdefault: package 'nix-2.21.0pre20240305_dirty'
β ββββnix: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-armv6l-unknown-linux-gnueabihf: package 'nix-armv6l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β ββββnix-armv7l-unknown-linux-gnueabihf: package 'nix-armv7l-unknown-linux-gnueabihf-2.21.0pre20240305_dirty'
β ββββnix-ccacheStdenv: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-clangStdenv: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-gccStdenv: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-libcxxStdenv: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-stdenv: package 'nix-2.21.0pre20240305_dirty'
β ββββnix-x86_64-unknown-freebsd13: package 'nix-x86_64-unknown-freebsd13-2.21.0pre20240305_dirty'
β ββββnix-x86_64-unknown-netbsd: package 'nix-x86_64-unknown-netbsd-2.21.0pre20240305_dirty'
ββββaarch64-linux
β ββββchangelog-d-nix omitted (use '--all-systems' to show)
β ββββdefault omitted (use '--all-systems' to show)
β ββββdockerImage omitted (use '--all-systems' to show)
β ββββnix omitted (use '--all-systems' to show)
β ββββnix-armv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-armv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-ccacheStdenv omitted (use '--all-systems' to show)
β ββββnix-clangStdenv omitted (use '--all-systems' to show)
β ββββnix-gccStdenv omitted (use '--all-systems' to show)
β ββββnix-libcxxStdenv omitted (use '--all-systems' to show)
β ββββnix-static omitted (use '--all-systems' to show)
β ββββnix-stdenv omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-netbsd omitted (use '--all-systems' to show)
ββββi686-linux
β ββββchangelog-d-nix omitted (use '--all-systems' to show)
β ββββdefault omitted (use '--all-systems' to show)
β ββββnix omitted (use '--all-systems' to show)
β ββββnix-armv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-armv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-ccacheStdenv omitted (use '--all-systems' to show)
β ββββnix-clangStdenv omitted (use '--all-systems' to show)
β ββββnix-gccStdenv omitted (use '--all-systems' to show)
β ββββnix-libcxxStdenv omitted (use '--all-systems' to show)
β ββββnix-stdenv omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-netbsd omitted (use '--all-systems' to show)
ββββx86_64-darwin
β ββββchangelog-d-nix omitted (use '--all-systems' to show)
β ββββdefault omitted (use '--all-systems' to show)
β ββββnix omitted (use '--all-systems' to show)
β ββββnix-armv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-armv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
β ββββnix-ccacheStdenv omitted (use '--all-systems' to show)
β ββββnix-clangStdenv omitted (use '--all-systems' to show)
β ββββnix-gccStdenv omitted (use '--all-systems' to show)
β ββββnix-libcxxStdenv omitted (use '--all-systems' to show)
β ββββnix-stdenv omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
β ββββnix-x86_64-unknown-netbsd omitted (use '--all-systems' to show)
ββββx86_64-linux
ββββchangelog-d-nix omitted (use '--all-systems' to show)
ββββdefault omitted (use '--all-systems' to show)
ββββdockerImage omitted (use '--all-systems' to show)
ββββnix omitted (use '--all-systems' to show)
ββββnix-armv6l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
ββββnix-armv7l-unknown-linux-gnueabihf omitted (use '--all-systems' to show)
ββββnix-ccacheStdenv omitted (use '--all-systems' to show)
ββββnix-clangStdenv omitted (use '--all-systems' to show)
ββββnix-gccStdenv omitted (use '--all-systems' to show)
ββββnix-libcxxStdenv omitted (use '--all-systems' to show)
ββββnix-static omitted (use '--all-systems' to show)
ββββnix-stdenv omitted (use '--all-systems' to show)
ββββnix-x86_64-unknown-freebsd13 omitted (use '--all-systems' to show)
ββββnix-x86_64-unknown-netbsd omitted (use '--all-systems' to show)
As a summary, these are the categories:
- checks
- devShells
- hydraJobs
- overlays
- packages
Many of them are available for five platforms, but some aren't. What should be built when running nix build --all
? Would everyone have the same expectation?
As I understand the sentiment of this thread, the general expectation would be for it to build all packages for the current architecture. Potentially, adding the same --all-systems
flag that nix flake show
already has might be a reasonable addition, as well as allowing --all
to be passed multiple times with an optional value that allows building all devShells
or any other set of outputs.
$ nix build --all # Builds all packages
$ nix build --all packages # Same as above
$ nix build --all packages --all devShells # Build all packages and devShells
$ nix build --all devShells --all-systems # Build all devShells for all systems (requires remote builders)
$ nix build --all --system x86_64-linux --system aarch64-linux # Another flag for selecting specific systems
I think --all-systems
would be very niche, though. I guess I can see the use when doing release builds and you indeed have remote builders for all the systems.
A (neat but complex) alternative would be to add more syntax to flakerefs:
$ nix build '.#*' # * could be any other character, but has precedent
$ nix build '.#packages.aarch64-darwin.*' # Have to type out system tuple
$ nix build '.#packages.$system.*' # or add special case
$ nix build ".#packages.$(nix system).*" # or additional command and substitute in the shell
$ nix build .#{packages,devShells}.aarch64-darwin."*" # Shell expansion allows more freedom, but also counterintuitive
$ nix build ".#devShells.*.*" # The most niche usecase is the shortest
$ nix build .#packages.{x86_64,aarch64}-{linux,darwin}."*" # And you can do clever stuff like this
I'd say the latter approach feels very powerful and composable, but the first one is definitely much easier to discover, and probably covers most use-cases already. They don't have to be mutually exclusive, but more features isn't necessarily better.
Another way of solving this could be with nix code, if #5567 ever gets implemented, though that would be far from an intuitive alternative to --all
, more of an argument against implementing a syntax extension to flakerefs.
Proposal
I would suggest to start a first implementation with the following behavior:
$ nix build --all
error: --all requires the name of a package set.
The following package sets are available in the selected flake:
checks
packages
devShells
$ nix build --all packages
For starters, the outputs would be numbered results, that is in line with the current behavior of nix build
when multiple derivations are built.
This is obviously a limited and minimally viable solution, but it avoids ambiguity and is relatively easy to implement, which means the feature can be added and maintained with limited effort. It is also easy to extend in the future without breaking backwards compatibility.
In case it helps, I've made this shell function to build and push all flake inputs and outputs for myself:
cashout() {
set -x
nix flake archive --json |
jq -r '.path,(.inputs|to_entries[].value.path)' |
gopass env "env/$1/cachix_auth_token" cachix push "$1"
for target in $(
nix flake show --json --all-systems | jq '
["checks", "packages", "devShells"] as $tops |
$tops[] as $top |
.[$top] |
to_entries[] |
.key as $arch |
.value |
keys[] |
"\($top).\($arch).\(.)"
' | tr -d '"'
); do
nix build --json ".#$target" "${@:2}" |
jq -r '.[].outputs | to_entries[].value' |
gopass env "env/$1/cachix_auth_token" cachix push "$1"
done
}
what about recurseIntoAttrs ?
I'm embarrassed to say I don't fully understand how recurseIntoAttrs would be used in this case. Any example would be helpful.
This is an issue with the new nix commands. Thats also why this issue is open in the nix repository and not nixpkgs.
recurseIntoAttrs
acts as hand-maintained guide for some tools in nix, where to recurse for automatically discovering packages/derivations. I am not long enough into nix but i think recurseIntoAttrs
was invented because it is impossble to use nix itself to recursively evaluate nixpkgs and find all potentially deeply nested packages. So this function evolved into a convention and adds little hints to the expression tree, where to stop/continue with the recursion.
Now this convention was respected by nix itself:
Line 386 in e943ee3
But the problem is that the new command nix build
doesn't respect it as before via nix-build
.
(Reference to the new build command:
Line 116 in e943ee3
I've added this to devenv: https://devenv.sh/blog/2024/09/11/devenv-11-nested-nix-outputs-using-the-module-system/