Use nix-portable to allow using the devshell without installing DD-enabled nix globally#26
Use nix-portable to allow using the devshell without installing DD-enabled nix globally#26jaen wants to merge 1 commit intopdtpartners:feature/example-lixfrom
nix-portable to allow using the devshell without installing DD-enabled nix globally#26Conversation
…enabled nix globally
|
Thanks! I wanted to have a way to develop I've starting pulling out the |
|
Yeah,I've seen what sandstone does, but only after I've gotten this working. I can also see how it compares, as it's certainly simpler and doesn't have sandboxing overhead — when starting this I actually didn't realise that local stores pretend to be I appreciate flake-parts conceptually, but the only time I've tried to use them in anger I ended up not being able to figure out how to wrangle them xD I'm reasonably sure I was mishandling them though, so if you have had good experience with them then by all means do feel free to use them — any way to not put everything in
Right, which is why I suggested it could be an alternate shell instead — what I have done in some of my projects is something like this: source_env_if_exists ".envrc.user"
# Not using flake by default because we might have YUUUGE files
export FLAKE_SHELL=${FLAKE_SHELL:-".#default"}
export USE_FLAKES=${USE_FLAKES:-"false"}
if has nix; then
# Are flakes supported and enabled?
if nix show-config | grep experimental-features | grep -q flakes && [ "${USE_FLAKES}" == "true" ]; then
# Do we have nix-direnv
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
fi
use flake "${FLAKE_SHELL}"
else
use nix --argstr shellName "${FLAKE_SHELL##.#}"
fi
fiwhere you can use the |
|
@elpdt852 okay, so I've played around with how sandstone was doing it and it seems to work. So I have written a basic bash wrapper for that, but then I thought about how to sync paths back to the global store and wasn't sure about it — syncing the whole store seemed slow when I tried it, looking for result symlinks after build could work but it wouldn't be ideal (you could only sync back after build is finished and also handling So in the end I ended up writing as simple…ish wrapper around Anyway, I have made an alternate branch with the simple bash script and with the Rust tool I've written — 6ebf6d6. It defaults to the tool, but you can change the devhsell package to The question here is — do you think any of those two approaches would work. If so, which one would you prefer? Cleaning up the Rust tool, or the Bash script (maybe with some added code to sync the |
|
Hopefully it's unnecessary after NixOS/nix#13181 — I've had some issues trying my solution above again recently, so maybe it's better not to rely on that if upstream finally re-enabled dynamic derivations. |
|
It is good that it is working again upstream, but one may still want to not enable experimental features in their main store, so I think thinking about the chroot store for demos is still prudent. |
I wanted to try
nix-ninja, but I also didn't want to switchnixon my machine to some alpha release globally, so I have tried to figure out a way to have it work with a chroot store and what finally worked wasnix-portable(with a few fixes to have it work with new nixpkgs and additional features) — now I can runnix build .#examples-nixfrom the devshell and have it work out of the box. I tried to something more minimal by directly using bubblewrap, but I must've been missing something, as it was not enough.I'll leave it as a draft for now, because it probably should not be merged as-is, but I figured I can at least start a discussion on improving developer experience on this, until DD is widely available.
Things to consider:
nix, but maybe that's not desirable for some reason — I imagine there could be two shells and some way to select which one you wantdirenvto use,flake.nixinto smaller chunks, so it was a bit easier to get a handle on it. I can rebase it on top of themainbranch if you want, but I think it would be useful to split it even more, so it's more manageable (YMMV, but I usually useflake.nixfor inputs only, import someoutputs.nixfor output definition and all devshells, packages and so on go intonixsubdirectory, like the one I've added fornix-portable),