The configuration.nix file starts with
{
pkgs
, testing ? false
, ...
}
How to specify the parameter - e.g. testing=true
- in the (shell) execution of nixos-rebuild ?
The configuration.nix file starts with
{
pkgs
, testing ? false
, ...
}
How to specify the parameter - e.g. testing=true
- in the (shell) execution of nixos-rebuild ?
You are searching for --arg testing true
nixos-rebuild
does not understand --arg
nor --argstr
:
$ nixos-rebuild build --arg foo true /run/current-system/sw/bin/nixos-rebuild: unknown option `--arg'
I do not think this is currently possible.¹ Even if nixos-rebuild
supported --arg
flag, the modules are likely too deep for Nix to pass them the arguments.
In theory, you could abuse NIX_PATH
for passing stringly-typed arguments but that is super ugly and will not work in pure mode.
If you have just a single argument, I would go with creating a configuration-testing.nix
file containing something like the following:
{
imports = [
./configuration.nix
];
_module.args = {
testing = true;
}
}
And then invoke nixos-rebuild
with -I nixos-config=path/to/configuration-testing.nix.nix
argument.