@@ -84,7 +84,7 @@ To install Nix from any commit, go to [the corresponding installer_test action](
84
84
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
85
85
` ` `
86
86
87
- # ## How can I run NixOS tests?
87
+ # ## How do I run NixOS tests?
88
88
89
89
With the following inputs :
90
90
@@ -96,7 +96,7 @@ With the following inputs:
96
96
97
97
[Note that there's no hardware acceleration on GitHub Actions.](https://github.com/actions/virtual-environments/issues/183#issuecomment-610723516).
98
98
99
- # ## How can I install packages via nix-env from the specified `nix_path`?
99
+ # ## How do I install packages via nix-env from the specified `nix_path`?
100
100
101
101
```
102
102
nix-env -i mypackage -f '<nixpkgs >'
@@ -126,3 +126,23 @@ install-nix-action's own `extra_nix_config` input:
126
126
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
127
127
substituters = https://hydra.iohk.io https://cache.nixos.org/
128
128
` ` `
129
+
130
+ ### How do I pass environment variables to commands run with ` nix develop` or `nix shell`?
131
+
132
+ Nix runs commands in a restricted environment by default, called `pure mode`.
133
+ In pure mode, environment variables are not passed through to improve the reproducibility of the shell.
134
+
135
+ You can use the `--keep / -k` flag to keep certain environment variables :
136
+
137
+ ` ` ` yaml
138
+ - name: Run a command with nix develop
139
+ run: nix develop --ignore-environment --keep MY_ENV_VAR --command echo $MY_ENV_VAR
140
+ env:
141
+ MY_ENV_VAR: "hello world"
142
+ ` ` `
143
+
144
+ Or you can disable pure mode entirely with the `--impure` flag :
145
+
146
+ ` ` `
147
+ nix develop --impure
148
+ ` ` `
0 commit comments