Is it possible to use some code in my configuration.nix that will be able to read a file during a nixos-rebuild... and store its content as an environment variable? Something like:
Not sure about arbitrary directories but you can read a file in the current directory (which is /etc/nixos) using builtins.readFile. For instance here is how I add custom TLS certificates:
No. There are very few options you can set in configuration.nix that don’t end up stored in the Nix store. That’s how it can do atomic upgrades and rollbacks; because as much as humanly possible is in the nix store, and referred to by a top level derivation that symlinks to everything.
Setting environment variables for services will store the value in a systemd unit file in the store, or in a script file in the store, or something. Most NixOS services have an extraConfig option or something, which allows you to specify custom text for the config file, allowing you to specify a path of your choice rather than a nix store path. Looks like CodiMD doesn’t have such an option, so you probably need to do some hacking to do what you want.
Not sure about arbitrary directories but you can read a file in the current directory (which is /etc/nixos) using builtins.readFile. For instance here is how I add custom TLS certificates:
No. There are very few options you can set in configuration.nix that
don’t end up stored in the Nix store. That’s how it can do atomic
upgrades and rollbacks; because as much as humanly possible is in the
nix store, and referred to by a top level derivation that symlinks to
everything.
I knew this, thanks
Setting environment variables for services will store
[…]
Thank you, I can’t find where I read that declared environment variables
are not stored (in the store)… and it did not make much sense to me
The environment variable I used for testing is defined for the root env
and stored in a couple of files in the store, e.g.:
Most NixOS services have an extraConfig option or something, which
allows you to specify custom text for the config file, allowing you to
specify a path of your choice rather than a nix store path. Looks like
CodiMD doesn’t have such an option,