nixnixospppd

How do we refer to etc package from NixOS configuration?


I want to get a path, which leads to nixos /etc location (any one of /run/current-system/etc or /nix/store/hashhere-etc-1.0). I use this path to configure pppd connect script, some kind of the following,

  environment.etc."huawei" =
    { text = ''
        /dev/ttyUSB0
        38400
        lock
        crtscts
        nodetach
        noipdefault
        # Below here what I've struggled
        connect ${pkgs.etc}/${environment.etc."huawei-script".target}
      '';
      mode = "0777";
      target = "ppp/peers/huawei"; };

I have tried to write ${pkgs.etc} or ${system.build.etc} or even ${environment.etc} resulting errors.

The directory structure is actually relative, but I think it's safer to use absolute path.

    /nix/store/...etc.../ppp/peers
    |- huawei
    |- huawei.d
       |- huawei.sh
       |- huawei.chat 

Solution

  • If I understand correctly your problem is you simply need to pass the string value of the target attribute to the huawei.text connect directive. As per the description for the target attribute the value is a path relative to /etc so you should be able to either:

    1. Make the value of the connect directive the string literal connect /etc/ppp/peers/huawei or
    2. make the etc.huaweiattribute set a recursive one so that the attributes can refer to each other then do

      environment.etc.huawei = rec {
          target = "ppp/peers/huawei";
          text = ''...
                   # Below here what I've struggled
                   connect ${target}
          '';
      };