Oh weird, maybe I need to go back and see if I did something wrong with the hostname, because now that I think about it you're right--they should all be evaluated at once. I think the system.activationScripts are an exception though. They seem to run after everything's evaluated (they print their "installing" messages right after nix does "setting up /etc..." but before it starts systemd units). Which is the sensible way to do it, you wouldn't want them to run before nix knows the expressions are valid. I was mostly wondering if there's a separate "pre-nix-eval" hook somewhere. I could see it being useful for other things too, like checking that the nixpkgs repo exists if you have your own or aborting if there's no network connection. Jeff
On 1/23/15, Wout Mertens <wout.mert...@gmail.com> wrote: > 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