Shared environment for script blocks

flox.dev feels like a natural complement to Atuin Desktop since flox environments could provide consistently reproducible environments for shared runbooks. I’ve found that in order to use commands from a flox environment in a script block I have to prefix the command with an activation of the flox environment. For example, if I have a flox environment in my home directory that has jwt-cli installed then in order to use that in a script block I have to flox activate -d ~ -- jwt in the script block instead of just jwt. Is there any way to set up an reusable environment for script blocks so that all scripts in a runbook could run with flox already activated instead of needing to prefix each script block with an activation?

flox activate sets a bunch of FLOX_-prefixed environment variables so I think it might work to add environment variable blocks to the runbook that set all of those but that’s not very ergonomic.

1 Like

forgive my ignore but how does flox differ from https://devenv.sh/ or a nix shell?

but I agree that such systems feel like a very good integration candidate - maybe a .envrc can be used to integrate with the aforementioned tools?

flox is built on top of nix and provides a simplified approach to using nixpkgs to set up and share development environments. It acts more like a conventional package manager but creates a manifest file with version locked nixpkgs dependencies. I think it’s similar to building a flake that sets up nix shell will all the dependencies/tooling for a project but doesn’t require using nix directly.

maybe a .envrc can be used to integrate with the aforementioned tools?

Something like that, yeah. Running flox activate sets up all the necessary environment variables for the flox environment and you can also activate a flox environment with direnv: Flox | Auto Environment Activation With Direnv + Flox. This works well in Atuin Desktop for terminal blocks. However script blocks look like they only inherit the environment of Atuin Desktop itself, plus any env blocks set in the runbook.

I think the functionality I’m looking for would be a way to run a terminal/script block and capture the environment at the end of that into the runbook so that subsequent script blocks would run with those same environment variables.