What do you mean with "only get installed at the end"?

Also, networking.hostName should work, the whole config gets evaluated "at
once". There's no "running" in Nix, only side-effects of evaluation.

Wout.

On Fri Jan 23 2015 at 7:45:38 PM Jeff Johnson <jef...@gmail.com> wrote:

> Hi all! I'm trying to set up tarsnap on nixos. This is my tarsnap.nix so
> far:
>
>     config:
>
>     let
>       keySrc   = ../rawpriv/tarsnap;
>       cacheDir = "/var/cache/tarsnap";
>
>       rcSrc = builtins.toFile "tarsnaprc" ''
>         aggressive-networking # TODO is this a good idea?
>         humanize-numbers
>       '';
>
>       script = homeDir:
>         let
>           keyDst = "${homeDir}/tarsnap.key";
>           rcDst  = "${homeDir}/.tarsnaprc";
>         in ''
>           echo "installing ${keyDst}"  ; install -m400
> ${keySrc}/`hostname`.key ${keyDst}
>           echo "installing ${rcDst}"   ; ln -fs ${rcSrc} ${rcDst}
>           echo "installing ${cacheDir}"; mkdir -p ${cacheDir}
>         '';
>
>     in {
>       system.activationScripts = { tarsnap = script "/root"; };
>       services.tarsnap = {
>         inherit config;
>         enable   = true;
>         keyfile  = keyDst;
>         cachedir = cacheDir;
>       };
>     }
>
> It works except that the keyfile and cachedir only get installed at
> the end, so nix complains that they don't exist unless I create them
> manually first. Is there a way to make the script run earlier? And
> another possibly-related question: is there a way to find out the
> hostname? I can't just do `networking.hostName` because that's set in
> the top-level config after this module runs. Do I just pass it as an
> argument? Thanks
> Jeff
> _______________________________________________
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev

Reply via email to