nix-book/source/recipes/devshell/env-var/main.adoc0
Amy de Buitléir 5835a15a40 temp
2025-09-16 13:38:20 +01:00

34 lines
576 B
Text

= Set an environment variable
////
$ mkdir tempwork
$ cd tempwork
$ cp ../flake.nix flake.nix
$ git add flake.nix
$ nix develop
$ git add flake.lock
$ git commit -a -m temp
////
Set the value of the environment variable FOO to “bar”.
[source,nix,linenums]
.flake.nix
....
$# cat flake.nix
....
Here's a demonstration using the shell.
....
$ echo "FOO=${FOO}"
$# start-shell nix develop <<EOL
$# echo '$ echo "FOO=\${FOO}"'
$# env | grep FOO | grep -v shellHook
$# EOL
....
////
Good adoc0 scripts clean up after themselves.
$ cd .. ; rm -rf tempwork # clean up
////