Set a option with its default value in nixos configuration

I want to add a new path into nix.nixPath. I have some options to do this, such as edting NIX_PATH in shell’s profiles.

But I want to set it in configuration.nix. I can get default value from website or nixpkgs repo.
I wonder how I can get it using nix expression in configuration.nix. I know it is lazy in config, so using argument named config cannot work.

For example(what i want to do):

{ config, ... }:
{ a = config.a ++ [ sth ]; }

List options are merged, not replaced, so { a = [ sth ]; } should be enough.

my system version is 19.03, and it is replaced, not merged.
The only merged one is systemPackgaes, the other, such as nix.nixPath is not for me


nix.nixPath = mkOptionDefault [

a try if you want to merge with the option’s default value.

1 Like

This can work. Thanks.

As an alternative, more literal approach, this could work:

{ config, options, ... }:
{ nix.nixPath = options.nix.nixPath.default ++ [sth]; }