`up`: evaluate adding `nix` operation
Closed this issue · 1 comments
Adding the nix
operation would allow to support people wanting to use nix, while keeping the simplicity of omni
for sharing and adoption. This would also allow to get dependencies to build things like python
using asdf
for people using nix.
The following projects can be interesting to look at:
- https://github.com/direnv/direnv/blob/07254a69642f84a4300e50a11f378e5222013239/stdlib.sh#L1289-L1294
- https://github.com/nix-community/nix-direnv (using
gcroots
so that the versions don't get garbage-collected), see https://github.com/nix-community/nix-direnv/blob/39d162964ae6f493acd49622ed1fb995923f4ed3/direnvrc#L338-L486
Avoid garbage collection of nix files
To do so, we need to keep a profile and put it in the gcroots
so that it does not get garbage-collected.
e.g. with nix
available, call: (where $packages
are the list of packages, and $tmp_profile
is a temporary profile file)
nix --extra-experimental-features "nix-command flakes" print-dev-env --profile "$tmp_profile" --impure --expr "with import <nixpkgs> {}; mkShell { buildInputs = [ $packages ]; }"
Note 1: can use those alternatives instead of --expr
if using a nix file: "--file" "$nixfile"
or "--expr" "(import ${nixfile} {}).${attribute}"
if using an attribute.
Note 2: need to figure out if we need to make a copy of the files when using the nixfile or not (so that only omni up
will refresh dependencies)
Then: (where $tmp_profile
is the temporary profile file, $perm_profile
is the permanent storage of the profile)
nix --extra-experimental-features "nix-command flakes" build --out-link "$perm_profile" "$tmp_profile"
Then: (where $tmp_profile
is the temporary profile file)
rm -rf "$tmp_profile" "$tmp_profile"*
Note 3: nix-store --gc --print-roots
is useful to see the gcroots; nix-collect-garbage
is useful to trigger garbage collection
Load binaries
We can look directly into $profile
(e.g. with ocaml
and python
packages)
$ cat "$profile" | jq '.variables.pkgsHostTarget'
{
"type": "array",
"value": [
"/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12",
"/nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1"
]
}
That should be sufficient, but maybe not? i.e. what if we depend on gcc, openssl, what else do we need to load? how do we load libs or headers?
All of .variables
could be interesting to consider also, but maybe not necessary. Would we want to parse the new PATH
and deal with its contents?
$ cat "$profile" | jq '.variables'
{ "AR": { "type": "exported", "value": "ar" }, "AS": { "type": "exported", "value": "as" }, "BASH": { "type": "var", "value": "/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash" }, "BASHOPTS": { "type": "unknown" }, "BASHPID": { "type": "unknown" }, "CC": { "type": "exported", "value": "gcc" }, "CONFIG_SHELL": { "type": "exported", "value": "/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash" }, "CXX": { "type": "exported", "value": "g++" }, "DETERMINISTIC_BUILD": { "type": "exported", "value": "1" }, "HOME": { "type": "exported", "value": "/homeless-shelter" }, "HOSTTYPE": { "type": "var", "value": "aarch64" }, "HOST_PATH": { "type": "exported", "value": "/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/bin:/nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1/bin:/nix/store/21n0is5badfz9zkkb3anhz90z6d0f36j-coreutils-9.1/bin:/nix/store/dhmxfyy59c8774h6xw4k4z23ij9xv40v-findutils-4.9.0/bin:/nix/store/23qgs6b81f3lj1m9gajw06lv5yjmv0zi-diffutils-3.9/bin:/nix/store/4nzwcmww2rj2pz679awsha7pvhgapd1p-gnused-4.9/bin:/nix/store/d1m156z19fx8ddrkzcbaqg1wbqv9q803-gnugrep-3.7/bin:/nix/store/1288v3cj9lyqlznfzc2i9hkmy00b9lz9-gawk-5.2.1/bin:/nix/store/yp2kajdqw255vfgrw127z2qd4qwj5z3y-gnutar-1.35/bin:/nix/store/0565md25r4nbrwav7x5gzad8528j90nn-gzip-1.12/bin:/nix/store/hk9nmm22d7qzzdhkr99c1c082k8f4i15-bzip2-1.0.8-bin/bin:/nix/store/p1s07m7l161gk5zf47k83yhjh93ql4a0-gnumake-4.4.1/bin:/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin:/nix/store/lwj2wdb738d65gmjs5mka1mmfqc3vwdv-patch-2.7.6/bin:/nix/store/jhlsd31zljlmv0296j7wgy3ywfgwh99v-xz-5.4.3-bin/bin:/nix/store/lyzwifcqq86zdqfdrzpjp1kxd7i6j69v-file-5.44/bin" }, "IFS": { "type": "var", "value": " \t\n" }, "IN_NIX_SHELL": { "type": "exported", "value": "impure" }, "LD": { "type": "exported", "value": "ld" }, "LINENO": { "type": "var", "value": "76" }, "MACHTYPE": { "type": "var", "value": "aarch64-unknown-linux-gnu" }, "NIX_BINTOOLS": { "type": "exported", "value": "/nix/store/rbhi8kym2xzbfmybc6ifyrz7v2adlsq2-binutils-wrapper-2.40" }, "NIX_BINTOOLS_WRAPPER_TARGET_HOST_aarch64_unknown_linux_gnu": { "type": "exported", "value": "1" }, "NIX_BUILD_CORES": { "type": "exported", "value": "12" }, "NIX_BUILD_TOP": { "type": "exported", "value": "/tmp/nix-build-nix-shell-env.drv-0" }, "NIX_CC": { "type": "exported", "value": "/nix/store/p92r4nnm3bpylajfcvbrnha3s1zydlib-gcc-wrapper-12.2.0" }, "NIX_CC_WRAPPER_TARGET_HOST_aarch64_unknown_linux_gnu": { "type": "exported", "value": "1" }, "NIX_CFLAGS_COMPILE": { "type": "exported", "value": " -frandom-seed=1h6aks0wdp -isystem /nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/include -isystem /nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1/include -isystem /nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/include -isystem /nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1/include" }, "NIX_ENFORCE_NO_NATIVE": { "type": "exported", "value": "1" }, "NIX_ENFORCE_PURITY": { "type": "exported", "value": "1" }, "NIX_HARDENING_ENABLE": { "type": "exported", "value": "fortify stackprotector pic strictoverflow format relro bindnow" }, "NIX_LDFLAGS": { "type": "exported", "value": "-rpath /nix/store/1h6aks0wdpys9j1jnmhxvhyyyzmiis9q-nix-shell-env/lib -L/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/lib -L/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/lib" }, "NIX_LOG_FD": { "type": "exported", "value": "2" }, "NIX_NO_SELF_RPATH": { "type": "var", "value": "1" }, "NIX_STORE": { "type": "exported", "value": "/nix/store" }, "NM": { "type": "exported", "value": "nm" }, "OBJCOPY": { "type": "exported", "value": "objcopy" }, "OBJDUMP": { "type": "exported", "value": "objdump" }, "OLDPWD": { "type": "exported", "value": "" }, "OPTERR": { "type": "var", "value": "1" }, "OPTIND": { "type": "unknown" }, "OSTYPE": { "type": "var", "value": "linux-gnu" }, "PATH": { "type": "exported", "value": "/nix/store/98jw4fz029h7v92rcjn7s3iqwax8v204-patchelf-0.15.0/bin:/nix/store/p92r4nnm3bpylajfcvbrnha3s1zydlib-gcc-wrapper-12.2.0/bin:/nix/store/cwyyf6gykc8g2a5y38llkv6b8m4wm857-gcc-12.2.0/bin:/nix/store/10z816l4x13a6ksbz5pry8nsa4jpn5q6-glibc-2.37-8-bin/bin:/nix/store/21n0is5badfz9zkkb3anhz90z6d0f36j-coreutils-9.1/bin:/nix/store/rbhi8kym2xzbfmybc6ifyrz7v2adlsq2-binutils-wrapper-2.40/bin:/nix/store/pndi5gr1b9p591vmr7dvijymi8faclck-binutils-2.40/bin:/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/bin:/nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1/bin:/nix/store/21n0is5badfz9zkkb3anhz90z6d0f36j-coreutils-9.1/bin:/nix/store/dhmxfyy59c8774h6xw4k4z23ij9xv40v-findutils-4.9.0/bin:/nix/store/23qgs6b81f3lj1m9gajw06lv5yjmv0zi-diffutils-3.9/bin:/nix/store/4nzwcmww2rj2pz679awsha7pvhgapd1p-gnused-4.9/bin:/nix/store/d1m156z19fx8ddrkzcbaqg1wbqv9q803-gnugrep-3.7/bin:/nix/store/1288v3cj9lyqlznfzc2i9hkmy00b9lz9-gawk-5.2.1/bin:/nix/store/yp2kajdqw255vfgrw127z2qd4qwj5z3y-gnutar-1.35/bin:/nix/store/0565md25r4nbrwav7x5gzad8528j90nn-gzip-1.12/bin:/nix/store/hk9nmm22d7qzzdhkr99c1c082k8f4i15-bzip2-1.0.8-bin/bin:/nix/store/p1s07m7l161gk5zf47k83yhjh93ql4a0-gnumake-4.4.1/bin:/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin:/nix/store/lwj2wdb738d65gmjs5mka1mmfqc3vwdv-patch-2.7.6/bin:/nix/store/jhlsd31zljlmv0296j7wgy3ywfgwh99v-xz-5.4.3-bin/bin:/nix/store/lyzwifcqq86zdqfdrzpjp1kxd7i6j69v-file-5.44/bin" }, "PS4": { "type": "var", "value": "+ " }, "PYTHONHASHSEED": { "type": "exported", "value": "0" }, "PYTHONNOUSERSITE": { "type": "exported", "value": "1" }, "PYTHONPATH": { "type": "exported", "value": "/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12/lib/python3.10/site-packages" }, "RANLIB": { "type": "exported", "value": "ranlib" }, "READELF": { "type": "exported", "value": "readelf" }, "SHELL": { "type": "exported", "value": "/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash" }, "SHELLOPTS": { "type": "unknown" }, "SIZE": { "type": "exported", "value": "size" }, "SOURCE_DATE_EPOCH": { "type": "exported", "value": "315532800" }, "SRANDOM": { "type": "unknown" }, "STRINGS": { "type": "exported", "value": "strings" }, "STRIP": { "type": "exported", "value": "strip" }, "TEMP": { "type": "exported", "value": "/tmp/nix-build-nix-shell-env.drv-0" }, "TEMPDIR": { "type": "exported", "value": "/tmp/nix-build-nix-shell-env.drv-0" }, "TERM": { "type": "exported", "value": "xterm-256color" }, "TMP": { "type": "exported", "value": "/tmp/nix-build-nix-shell-env.drv-0" }, "TMPDIR": { "type": "exported", "value": "/tmp/nix-build-nix-shell-env.drv-0" }, "TZ": { "type": "exported", "value": "UTC" }, "XDG_DATA_DIRS": { "type": "exported", "value": "/nix/store/98jw4fz029h7v92rcjn7s3iqwax8v204-patchelf-0.15.0/share" }, "_PYTHON_HOST_PLATFORM": { "type": "exported", "value": "linux-aarch64" }, "_PYTHON_SYSCONFIGDATA_NAME": { "type": "exported", "value": "_sysconfigdata__linux_aarch64-linux-gnu" }, "__structuredAttrs": { "type": "exported", "value": "" }, "buildInputs": { "type": "exported", "value": "/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12 /nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1" }, "buildPhase": { "type": "exported", "value": "{ echo \"------------------------------------------------------------\";\n echo \" WARNING: the existence of this path is not guaranteed.\";\n echo \" It is an internal implementation detail for pkgs.mkShell.\";\n echo \"------------------------------------------------------------\";\n echo;\n # Record all build inputs as runtime dependencies\n export;\n} >> \"$out\"\n" }, "builder": { "type": "exported", "value": "/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash" }, "cmakeFlags": { "type": "exported", "value": "" }, "configureFlags": { "type": "exported", "value": "" }, "defaultBuildInputs": { "type": "var", "value": "" }, "defaultNativeBuildInputs": { "type": "var", "value": "/nix/store/98jw4fz029h7v92rcjn7s3iqwax8v204-patchelf-0.15.0 /nix/store/a1kpc6xdirr213h60rqgyy0bj7c82lhp-update-autotools-gnu-config-scripts-hook /nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh /nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh /nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh /nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh /nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh /nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh /nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh /nix/store/bxsly8a56yb8kyrq03s82a3vyc8fqrb3-multiple-outputs.sh /nix/store/nf1lkdrhapsx5lr6diyxyjr7pb7r20gr-patch-shebangs.sh /nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh /nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh /nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh /nix/store/a9ndjg0b1ivi0av9m93vfkrndp7fqbw1-strip.sh /nix/store/p92r4nnm3bpylajfcvbrnha3s1zydlib-gcc-wrapper-12.2.0" }, "depsBuildBuild": { "type": "exported", "value": "" }, "depsBuildBuildPropagated": { "type": "exported", "value": "" }, "depsBuildTarget": { "type": "exported", "value": "" }, "depsBuildTargetPropagated": { "type": "exported", "value": "" }, "depsHostHost": { "type": "exported", "value": "" }, "depsHostHostPropagated": { "type": "exported", "value": "" }, "depsTargetTarget": { "type": "exported", "value": "" }, "depsTargetTargetPropagated": { "type": "exported", "value": "" }, "doCheck": { "type": "exported", "value": "" }, "doInstallCheck": { "type": "exported", "value": "" }, "dontAddDisableDepTrack": { "type": "exported", "value": "1" }, "envBuildBuildHooks": { "type": "array", "value": [] }, "envBuildHostHooks": { "type": "array", "value": [] }, "envBuildTargetHooks": { "type": "array", "value": [] }, "envHostHostHooks": { "type": "array", "value": [ "ccWrapper_addCVars", "bintoolsWrapper_addLDVars", "addPythonPath", "sysconfigdataHook" ] }, "envHostTargetHooks": { "type": "array", "value": [ "ccWrapper_addCVars", "bintoolsWrapper_addLDVars", "addPythonPath", "sysconfigdataHook" ] }, "envTargetTargetHooks": { "type": "array", "value": [] }, "fixupOutputHooks": { "type": "array", "value": [ "if [ -z \"${dontPatchELF-}\" ]; then patchELF \"$prefix\"; fi", "if [[ -z \"${noAuditTmpdir-}\" && -e \"$prefix\" ]]; then auditTmpdir \"$prefix\"; fi", "if [ -z \"${dontGzipMan-}\" ]; then compressManPages \"$prefix\"; fi", "_moveLib64", "_moveSbin", "_moveSystemdUserUnits", "patchShebangsAuto", "_pruneLibtoolFiles", "_doStrip" ] }, "initialPath": { "type": "var", "value": "/nix/store/21n0is5badfz9zkkb3anhz90z6d0f36j-coreutils-9.1 /nix/store/dhmxfyy59c8774h6xw4k4z23ij9xv40v-findutils-4.9.0 /nix/store/23qgs6b81f3lj1m9gajw06lv5yjmv0zi-diffutils-3.9 /nix/store/4nzwcmww2rj2pz679awsha7pvhgapd1p-gnused-4.9 /nix/store/d1m156z19fx8ddrkzcbaqg1wbqv9q803-gnugrep-3.7 /nix/store/1288v3cj9lyqlznfzc2i9hkmy00b9lz9-gawk-5.2.1 /nix/store/yp2kajdqw255vfgrw127z2qd4qwj5z3y-gnutar-1.35 /nix/store/0565md25r4nbrwav7x5gzad8528j90nn-gzip-1.12 /nix/store/hk9nmm22d7qzzdhkr99c1c082k8f4i15-bzip2-1.0.8-bin /nix/store/p1s07m7l161gk5zf47k83yhjh93ql4a0-gnumake-4.4.1 /nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15 /nix/store/lwj2wdb738d65gmjs5mka1mmfqc3vwdv-patch-2.7.6 /nix/store/jhlsd31zljlmv0296j7wgy3ywfgwh99v-xz-5.4.3-bin /nix/store/lyzwifcqq86zdqfdrzpjp1kxd7i6j69v-file-5.44" }, "mesonFlags": { "type": "exported", "value": "" }, "name": { "type": "exported", "value": "nix-shell-env" }, "nativeBuildInputs": { "type": "exported", "value": "" }, "out": { "type": "exported", "value": "/nix/store/1h6aks0wdpys9j1jnmhxvhyyyzmiis9q-nix-shell-env" }, "outputBin": { "type": "var", "value": "out" }, "outputDev": { "type": "var", "value": "out" }, "outputDevdoc": { "type": "var", "value": "REMOVE" }, "outputDevman": { "type": "var", "value": "out" }, "outputDoc": { "type": "var", "value": "out" }, "outputInclude": { "type": "var", "value": "out" }, "outputInfo": { "type": "var", "value": "out" }, "outputLib": { "type": "var", "value": "out" }, "outputMan": { "type": "var", "value": "out" }, "outputs": { "type": "exported", "value": "out" }, "patches": { "type": "exported", "value": "" }, "phases": { "type": "exported", "value": "buildPhase" }, "pkg": { "type": "var", "value": "/nix/store/p92r4nnm3bpylajfcvbrnha3s1zydlib-gcc-wrapper-12.2.0" }, "pkgsBuildBuild": { "type": "array", "value": [] }, "pkgsBuildHost": { "type": "array", "value": [ "/nix/store/98jw4fz029h7v92rcjn7s3iqwax8v204-patchelf-0.15.0", "/nix/store/a1kpc6xdirr213h60rqgyy0bj7c82lhp-update-autotools-gnu-config-scripts-hook", "/nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh", "/nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh", "/nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh", "/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh", "/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh", "/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh", "/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh", "/nix/store/bxsly8a56yb8kyrq03s82a3vyc8fqrb3-multiple-outputs.sh", "/nix/store/nf1lkdrhapsx5lr6diyxyjr7pb7r20gr-patch-shebangs.sh", "/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh", "/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh", "/nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh", "/nix/store/a9ndjg0b1ivi0av9m93vfkrndp7fqbw1-strip.sh", "/nix/store/p92r4nnm3bpylajfcvbrnha3s1zydlib-gcc-wrapper-12.2.0", "/nix/store/rbhi8kym2xzbfmybc6ifyrz7v2adlsq2-binutils-wrapper-2.40" ] }, "pkgsBuildTarget": { "type": "array", "value": [] }, "pkgsHostHost": { "type": "array", "value": [] }, "pkgsHostTarget": { "type": "array", "value": [ "/nix/store/zidi1cplz5wy5qglpf1h8bc7mx34434m-python3-3.10.12", "/nix/store/qf8wrpp3x5rw60j7n8f7gmqa7pd39k24-ocaml-4.14.1" ] }, "pkgsTargetTarget": { "type": "array", "value": [] }, "postFixupHooks": { "type": "array", "value": [ "_makeSymlinksRelativeInAllOutputs", "_multioutPropagateDev" ] }, "postUnpackHooks": { "type": "array", "value": [ "_updateSourceDateEpochFromSourceRoot" ] }, "preConfigureHooks": { "type": "array", "value": [ "_multioutConfig" ] }, "preConfigurePhases": { "type": "var", "value": " updateAutotoolsGnuConfigScriptsPhase" }, "preFixupHooks": { "type": "array", "value": [ "_moveToShare", "_multioutDocs", "_multioutDevs" ] }, "preferLocalBuild": { "type": "exported", "value": "1" }, "prefix": { "type": "var", "value": "/nix/store/1h6aks0wdpys9j1jnmhxvhyyyzmiis9q-nix-shell-env" }, "propagatedBuildDepFiles": { "type": "array", "value": [ "propagated-build-build-deps", "propagated-native-build-inputs", "propagated-build-target-deps" ] }, "propagatedBuildInputs": { "type": "exported", "value": "" }, "propagatedHostDepFiles": { "type": "array", "value": [ "propagated-host-host-deps", "propagated-build-inputs" ] }, "propagatedNativeBuildInputs": { "type": "exported", "value": "" }, "propagatedTargetDepFiles": { "type": "array", "value": [ "propagated-target-target-deps" ] }, "shell": { "type": "exported", "value": "/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash" }, "shellHook": { "type": "exported", "value": "" }, "stdenv": { "type": "exported", "value": "/nix/store/mw4zb7nz2asmw883xr70zbb3a38agfjg-stdenv-linux" }, "strictDeps": { "type": "exported", "value": "" }, "system": { "type": "exported", "value": "aarch64-linux" }, "unpackCmdHooks": { "type": "array", "value": [ "_defaultUnpack" ] } }
Testing for python setup.
The following variables are useful:
path=$(cat "$tmp_profile" | \
nix-shell -p jq --run 'jq --raw-output ".variables.pkgsHostTarget.value | map(. + \"/bin\") | .[]"' | \
while read bindir; do if [[ -d "$bindir" ]]; then echo "$bindir"; fi; done | \
tr '\n' ':' | nix-shell -p gnused --run 'sed "s/:$//"')
cflags=$(cat "$tmp_profile" | nix-shell -p jq --run 'jq ".variables.NIX_CFLAGS_COMPILE_FOR_TARGET.value"')
ldflags=$(cat "$tmp_profile" | nix-shell -p jq --run 'jq ".variables.NIX_LDFLAGS_FOR_TARGET.value"')
pkgconfigpath=$(cat "$tmp_profile" | nix-shell -p jq --run 'jq ".variables.PKG_CONFIG_PATH_FOR_TARGET.value"')
echo "export PATH=$path"
echo "export CFLAGS=$cflags"
echo "export CPPFLAGS=\$CFLAGS"
echo "export LDFLAGS=$ldflags"
echo "export PKG_CONFIG_PATH=$pkgconfigpath"
With the following packages:
gawk gnused gcc gnumake pkg-config zlib bzip2 ncurses readline libffi openssl sqlite lzma