Consider the excerpt from my /etc/nixos/configuration.nix
below. It defines a custom variable inside my nix expression, and uses it inside a bash script. Running nixos-rebuild build
results in an error, because custom.variable
is not an available option.
{ config, pkgs, ... }: {
custom.variable = "my value";
systemd.services."my-service" = {
script = ''
MY_VARIABLE="${custom.variable}"
'';
};
}
Is there a way to declare custom variables like this? I am aware that I could use e.g. a let-in
expression, however I want my custom variable to live in a different file than where it is used.