thiagokokada/nix-alien

error somewhere in nix code when trying to run nix-alien

AleXoundOS opened this issue · 4 comments

Just tried to run nix-alien and got an error:

$ nix run github:thiagokokada/nix-alien -- fa
error:
       … while calling the 'derivationStrict' builtin

         at //builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'fa-fhs'
         whose name attribute is located at /nix/var/nix/profiles/per-user/root/channels/nixos/pkgs/stdenv/generic/make-derivation.nix:270:7

       … while evaluating attribute 'buildCommand' of derivation 'fa-fhs'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/pkgs/build-support/trivial-builders.nix:81:14:

           80|       enableParallelBuilding = true;
           81|       inherit buildCommand name;
             |              ^
           82|       passAsFile = [ "buildCommand" ]

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'lib' missing

       at /home/alex/.cache/nix-alien/dc2b7cd4-70c2-566b-9a99-933ef423d364/fhs-env/default.nix:9:5:

            8|   targetPkgs = p: with p; [
            9|     libgcc.lib
             |     ^
           10|   ];
Traceback (most recent call last):
  File "/nix/store/y7qmzf0vdz39fkqx5zvvap1hlb4qli6d-nix-alien-0.1.0+git20231015113305/bin/.nix-alien-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/y7qmzf0vdz39fkqx5zvvap1hlb4qli6d-nix-alien-0.1.0+git20231015113305/lib/python3.10/site-packages/nix_alien/fhs_env.py", line 85, in main
    return _impl.main(
  File "/nix/store/y7qmzf0vdz39fkqx5zvvap1hlb4qli6d-nix-alien-0.1.0+git20231015113305/lib/python3.10/site-packages/nix_alien/_impl.py", line 237, in main
    create_fn(
  File "/nix/store/y7qmzf0vdz39fkqx5zvvap1hlb4qli6d-nix-alien-0.1.0+git20231015113305/lib/python3.10/site-packages/nix_alien/fhs_env.py", line 35, in create_fhs_env
    return _impl.create(
  File "/nix/store/y7qmzf0vdz39fkqx5zvvap1hlb4qli6d-nix-alien-0.1.0+git20231015113305/lib/python3.10/site-packages/nix_alien/_impl.py", line 63, in create
    subprocess.run(
  File "/nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['nix-build', '--no-out-link', PosixPath('/home/alex/.cache/nix-alien/dc2b7cd4-70c2-566b-9a99-933ef423d364/fhs-env/default.nix')]' returned non-zero exit status 1.
$ ldd fa
     linux-vdso.so.1 (0x00007ffe223e3000)
     libstdc++.so.6 => not found
     libm.so.6 => /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libm.so.6 (0x00007ff7179a1000)
     librt.so.1 => /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/librt.so.1 (0x00007ff71799c000)
     libpthread.so.0 => /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libpthread.so.0 (0x00007ff717997000)
     libgcc_s.so.1 => /nix/store/jd99cyc0251p0i5y69w8mqjcai8mcq7h-xgcc-12.2.0-libgcc/lib/libgcc_s.so.1 (0x00007ff717976000)
     libc.so.6 => /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib/libc.so.6 (0x00007ff71778e000)
     /lib64/ld-linux-x86-64.so.2 => /nix/store/46m4xx889wlhsdj72j38fnlyyvvvvbyb-glibc-2.37-8/lib64/ld-linux-x86-64.so.2 (0x00007ff717a83000)
$ nix --version
nix (Nix) 2.15.2
$ nixos-version
23.05.20231011.bd1cde4 (Stoat)
$ nix flake metadata github:thiagokokada/nix-alien
Resolved URL:  github:thiagokokada/nix-alien
Locked URL:    github:thiagokokada/nix-alien/2d723f26c57213892a1f9641e11b2a09766e8479
Description:   nix-alien
Path:          /nix/store/5pspbmnph0b4gk8m6jbbq9yj5gycr6l8-source
Revision:      2d723f26c57213892a1f9641e11b2a09766e8479
Last modified: 2023-10-15 15:33:05
Inputs:
├───flake-compat: github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33
├───flake-utils: github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384
│   └───systems: github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e
├───nix-index-database: github:Mic92/nix-index-database/29977d0796c058bbcfb2df5b18eb5badf1711007
│   └───nixpkgs follows input 'nixpkgs'
└───nixpkgs: github:NixOS/nixpkgs/01441e14af5e29c9d27ace398e6dd0b293e25a54

It looks like the nixpkgs in your system does not match with the nixpkgs in the nix-alien (especially the nixpkgs database in nix-index-database is targeting the unstable while you're using stable). nix-alien in general will work better for unstable users since this is what nix-index-database targets.

You can manually edit /home/alex/.cache/nix-alien/dc2b7cd4-70c2-566b-9a99-933ef423d364/fhs-env/default.nix file to try to fix the issue manually.

your system does not match with the nixpkgs in the nix-alien

There is no such requirement in the documentation. (There are no requirements.)
It's not obvious for a new user.

You can manually edit /home/alex/.cache/nix-alien/dc2b7cd4-70c2-566b-9a99-933ef423d364/fhs-env/default.nix file to try to fix the issue manually.

Will such edits be required in the future? Or starting from NixOS-23.11 nix-alien will keep compatibility further?

your system does not match with the nixpkgs in the nix-alien

There is no such requirement in the documentation. (There are no requirements.) It's not obvious for a new user.

Yes, it isn't obvious sadly, but generally this works fine because it is not really likely that nixpkgs will mismatch that much that this causes problems.

You can manually edit /home/alex/.cache/nix-alien/dc2b7cd4-70c2-566b-9a99-933ef423d364/fhs-env/default.nix file to try to fix the issue manually.

Will such edits be required in the future? Or starting from NixOS-23.11 nix-alien will keep compatibility further?

There is no guarantee that this is not going to happen in the future, but I can say that this is unlikely to happen once 23.11 is released (unless there are other breaking changes in nixpkgs).

One thing that I have in mind is to make nix-alien aware of the current nixpkgs state, e.g.: pin the current nixpkgs version before generating the files.

This will need some changes in how we generate the files though, and I don't have time right now. But will look at this issue in the future again.