App-shell - simple, cleaner and lighter alternative to the nix-shell

nix-shell was originally designed to provide a debugging environment for Nix
derivations. It does a lot of magic and populates the environment with a lot
of unnecessary content (packages, shell environment variables and functions).

app-shell is much more simple, cleaner and lighter. It only fetches required
packages to the /nix/store and propagates them via relevant
environment variables.

For more information check out app-shell README file which contains some interesting usage examples.

This tool was born as a result of spike during my work on NGI project.

13 Likes

Hm, so this skips all hooks? That’d prevent things like sops-nix or even pkg-config based libraries working, right?

1 Like

pkg-config works. With latest version, libs are added on PKG_CONFIG_PATH and you can do following:

./app-shell.bash -v --apps pkg-config --libs curl

pkg-config --libs libcurl
-L/nix/store/kmq714baxkd5yzpnbp09b7dhnks6m74q-curl-8.12.1/lib -lcurl

In this case, the environment activation script is folowing:

#!/nix/store/9nw8b61s8lfdn8fkabxhbz0s775gjhbr-bash-5.2p37/bin/bash
export PS1="\[\033[1m\][app-shell]\[\033[m\]\040\w >\040"
export PATH=/nix/store/bbp56ai8w43xkfisar83h37imjdlcx6r-pkg-config-wrapper-0.29.2/bin:$PATH

export LIBRARY_PATH=/nix/store/kmq714baxkd5yzpnbp09b7dhnks6m74q-curl-8.12.1/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/nix/store/kmq714baxkd5yzpnbp09b7dhnks6m74q-curl-8.12.1/lib:$LD_LIBRARY_PATH
export CMAKE_LIBRARY_PATH=/nix/store/kmq714baxkd5yzpnbp09b7dhnks6m74q-curl-8.12.1/lib:$CMAKE_LIBRARY_PATH
export PKG_CONFIG_PATH=/nix/store/0rnns5hhxpvx08p0k3j6bhivj70y6wli-curl-8.12.1-dev/lib/pkgconfig:$PKG_CONFIG_PATH

/nix/store/m3hnxdlz6v6650ggqz29nsqbvzvdvnsy-bash-interactive-5.2p37/bin/bash --norc

You can use -v to understand more how things work.

2 Likes

I love this. This can serve as a worthy prototype for a future Nixpkgs CLI and already shows that more principled environment composition leveraging information from Nixpkgs would indeed work.

User input handling could be made more robust with the CLI wrapper implemented in a proper language, but the Nix-facing business logic is very promising!

3 Likes