Append to a etc.environment file

The package pkgs.nfs-utils does the following to /etc/request-key.conf:

  requestKeyConfFile = pkgs.writeText "request-key.conf" ''
    create id_resolver * * ${pkgs.nfs-utils}/bin/nfsidmap -t 600 %k %d
  '';

    environment.etc = {
      "idmapd.conf".source = idmapdConfFile;
      "nfs.conf".source = nfsConfFile;
      "request-key.conf".source = requestKeyConfFile;
    };

In order for my CIFS mounts to work, I also need to add this line:
create dns_resolver * * /run/current-system/sw/bin/key.dns_resolver %k

to /etc/request-key.conf

How can I append this to the nfs-utils package file? I’ve tried many things, like setting it in a seperate etc.environment.“request-key.conf” for instance, but then it complains about conflicting destinations. It then suggests to add lib.mkForce or lib.mkDefault, but this will just cause it to take one of the values instead of merging them together. I also tried making a derivation, but since the original contents from nfs-utils come from a local let...in statement, there is no way to access it in the override (as far as I know at least).

Have you tried lib.mkAfter, like this?

environment.etc."request-key.conf".source = lib.mkAfter ''
  create dns_resolver * * /run/current-system/sw/bin/key.dns_resolver %k
'';

Ah no, that won’t work because the source option wants a path. Hmm.

That was my first thought as well but the source option expecting a path complicates things there.

Guess for now I’ll work around it by including what nfs-utils adds and then force it to my own config. Not ideal because now I have to hope nfs-utils never changes it…

1 Like