Describe the bug
Nix fails to build nix on nixpkgs master.
Steps To Reproduce
Steps to reproduce the behavior:
- on unstable channel
- nix-channel --update
- This works:
nix-build -E 'with import <nixpkgs> {}; nix'
- This fails:
nix-build -E 'with import <nixpkgs> {}; let unused = {whatever.extensions =[];}; in nix' --show-trace
- Assertion failure:
error: assertion '(final).hasSharedLibraries' failed
at /nix/store/v63vjk8lz2fsj52qkfgbbw1mbgplcdmc-nixpkgs/nixpkgs/lib/systems/default.nix:89:25:
88| extensions = rec {
89| sharedLibrary = assert final.hasSharedLibraries;
| ^
90| /**/ if final.isDarwin then ".dylib"
Expected behavior
Both invocations should succeed as they are isomorphic, i.e. 4. has an unused let binding that causes nix to fail.
Additional context
Looks like this PR may have introduced the assert that causes the problem #238154 , commit
After some investigation a colleague pointed out that the issue may have to do with the instability of attrset comparison due to laziness in nix, comparison happens here
|
pkgsBuildTarget = |
|
if args.stdenv.targetPlatform == args.stdenv.hostPlatform |
|
then pkgsBuildHost |
|
else assert args.stdenv.hostPlatform == args.stdenv.buildPlatform; thisStage; |
and looks like invocation in 4. somehow cause a different evaluation order of attrset attribute comparison:
- if isStatic is compared first we don't see the assert
- If extensions compares first we stumble on the assert and fail.
nix-repl> pkgs.stdenv.hostPlatform.extensions
{ executable = ""; library = ".so"; sharedLibrary = ".so"; staticLibrary = ".a"; }
nix-repl> pkgsStatic.stdenv.hostPlatform.extensions
{ executable = ""; library = ".a"; sharedLibrary = «error: error: assertion '(final).hasSharedLibraries' failed
at /nix/store/v63vjk8lz2fsj52qkfgbbw1mbgplcdmc-nixpkgs/nixpkgs/lib/systems/default.nix:89:25:
88| extensions = rec {
89| sharedLibrary = assert final.hasSharedLibraries;
| ^
90| /**/ if final.isDarwin then ".dylib"»; staticLibrary = ".a"; }
Notify maintainers
@amjoseph-nixpkgs who added the assert that fails
@edolstra @lovesegfault @Artturin nix package maintainers
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.1.25-1rodete1-amd64`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.16.1`
- channels(root): `"nixpkgs"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
Describe the bug
Nix fails to build
nixon nixpkgs master.Steps To Reproduce
Steps to reproduce the behavior:
nix-build -E 'with import <nixpkgs> {}; nix'nix-build -E 'with import <nixpkgs> {}; let unused = {whatever.extensions =[];}; in nix' --show-traceExpected behavior
Both invocations should succeed as they are isomorphic, i.e.
4.has an unused let binding that causesnixto fail.Additional context
Looks like this PR may have introduced the assert that causes the problem #238154 , commit
After some investigation a colleague pointed out that the issue may have to do with the instability of attrset comparison due to laziness in nix, comparison happens here
nixpkgs/pkgs/stdenv/booter.nix
Lines 105 to 108 in 5136088
and looks like invocation in
4.somehow cause a different evaluation order of attrset attribute comparison:Notify maintainers
@amjoseph-nixpkgs who added the assert that fails
@edolstra @lovesegfault @Artturin nix package maintainers
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"and paste the result.