.. | ||
flake.lock | ||
flake.nix | ||
README.md |
shell-environment
Warning
If you copy the flake.nix remember to
git add [-N|--intent-to-add] flake.nix
, otherwise it won't work
This example shows how to create a shell environment which includes a diverse set of tools:
terraform
wget
bat
nixpkgs-fmt
You can search for more packages in nix packages
Usage
The devShells
option is used by the following command:
nix develop
You can have as many shells as you want, in this flake.nix, you also have
another_env
which includes curl
. To open it:
nix develop .#another_env
Troubleshooting
I get bash instead of my shell
nix develop
was designed for Nixpkgs stdenv, which uses bash, so that you can troubleshoot a Nix build with it. If you use a different shell, you'll want to get just the variables instead.
There are 3 possible solutions:
First, using direnv to manage your dev environments. See direnv-guide. This is the recommended approach.
Second is a simple-unreliable hack, which is adding a shellHook
to devShells
devShells.default = pkgs.mkShell {
shellHook = ''
exec $SHELL
'';
};
You might get a lot different issues, use it at your own risk.
Lastly, there's nix print-dev-env
which returns the variables - in case you're feeling adventurous, because this is far from a complete solution. See nix print-dev-env --help
.