floobits@pixel-druid:~$ nix-env -iA nixpkgs.hello+ nix-env -iA nixpkgs.helloinstalling 'hello-2.10'these paths will be fetched (0.04 MiB download, 0.20 MiB unpacked):  /nix/store/w9yy7v61ipb5rx6i35zq1mvc2iqfmps1-hello-2.10copying path '/nix/store/w9yy7v61ipb5rx6i35zq1mvc2iqfmps1-hello-2.10' from 'https://cache.nixos.org'...error: unable to fork: Cannot allocate memoryfloobits@pixel-druid:~$ gdb --args nix-env -iA nixpkgs.hello+ gdb --args nix-env -iA nixpkgs.helloGNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1Copyright (C) 2016 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.  Type "show copying"and "show warranty" for details.This GDB was configured as "x86_64-linux-gnu".Type "show configuration" for configuration details.For bug reporting instructions, please see:.Find the GDB manual and other documentation resources online at:.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from nix-env...(no debugging symbols found)...done.(gdb) runStarting program: /nix/store/d6axkgf0jq41jb537fnsg44080c4rd52-user-environment/bin/nix-env -iA nixpkgs.hellowarning: File "/nix/store/danv012gh0aakh8xnk2b35vahklz72mk-gcc-9.2.0-lib/lib/libstdc++.so.6.0.27-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".To enable execution of this file add        add-auto-load-safe-path /nix/store/danv012gh0aakh8xnk2b35vahklz72mk-gcc-9.2.0-lib/lib/libstdc++.so.6.0.27-gdb.pyline to your configuration file "/home/floobits/.gdbinit".To completely disable this security protection add        set auto-load safe-path /line to your configuration file "/home/floobits/.gdbinit".For more information about this security protection see the"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:        info "(gdb)Auto-loading safe path"warning: File "/nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.^[[A[New LWP 21466]GC Warning: Failed to expand heap by 128045056 bytesinstalling 'hello-2.10'building '/nix/store/k3kz3cwyqdwi5bmwcbl1fzv2b2wkqrl6-user-environment.drv'...created 43 symlinks in user environment[LWP 21466 exited][Inferior 1 (process 21462) exited normally](gdb) run

§ All nix subcommands are just symlinks

floobits@pixel-druid:~/idfk/nix-master$ ls -al /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/bin/total 1784dr-xr-xr-x 2 floobits bollu    4096 Jan  1  1970 .dr-xr-xr-x 9 floobits bollu    4096 Jan  1  1970 ..-r-xr-xr-x 1 floobits bollu 1816768 Jan  1  1970 nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-build -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-channel -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-collect-garbage -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-copy-closure -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-daemon -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-env -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-hash -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-instantiate -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-prefetch-url -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-shell -> nixlrwxrwxrwx 1 floobits bollu       3 Jan  1  1970 nix-store -> nix

It seems the way this works is that the nix tool figures out from what symlink it's being invoked to decide what to do. God, that's ugly? brilliant? I don't even know.

§ How does writeFile work?