Creating C development environment with buildFHSUserEnv

I’m occasionally doing C development in Linux and other similar repositories on NixOS. For that, it is handy to keep a FHS environment around that looks like a “normal” Linux. I’m currently using the expression below in my system path and enter it with legacy-env on demand.

I’ve noticed that the compiler in this environment is sometimes acting strangely. For example, when doing make menuconfig in buildroot, I get:

% make menuconfig
...
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: menubox.c:(.text+0x1324): undefined reference to `delwin'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: menubox.c:(.text+0x1330): undefined reference to `delwin'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: menubox.c:(.text+0x134b): undefined reference to `delwin'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: /home/julian/src/own/buildroot-2021.08.1/output/build/buildroot-config/lxdialog/menubox.o:menubox.c:(.text+0x1357): more undefined references to `delwin' follow
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile.br:28: mconf] Error 1

I’m wondering what other people do to be able to compile these kinds of software without Nix on their NixOS machines.

The alternative is to keep a Ubuntu VM around, but that has been pretty unwieldy.

For reference, this is my FHS definition:

(pkgs.buildFHSUserEnv {
      name = "legacy-env";
      targetPkgs = pkgs: with pkgs; [
        gcc binutils
        gnumake coreutils patch zlib zlib.dev curl git m4 bison flex iasl
        ncurses.dev
        elfutils.dev
        openssl openssl.dev
        cpio pahole gawk perl bc nettools rsync
        gmp gmp.dev
        libmpc
        mpfr mpfr.dev
        zstd python3Minimal
      ];
    })
2 Likes