All modules with preStart: Use systemd.tmpfiles.rules

This is NixOS' recommended way to setup service dirs
https://github.com/NixOS/nixpkgs/pull/56265. This commit hands off the
initial data directory creation to systemd.tmpfiles.rules. All other
preStart scripts are left intact to limit this changes' scope.
This commit is contained in:
nixbitcoin 2020-05-06 12:43:57 +02:00
parent 423ebf862b
commit 91b6b2c370
No known key found for this signature in database
GPG key ID: DD11F9AD5308B3BA
8 changed files with 31 additions and 18 deletions

View file

@ -78,6 +78,10 @@ in {
};
users.groups.clightning = {};
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${config.users.users.clightning.name} ${config.users.users.clightning.group} - -"
];
systemd.services.clightning = {
description = "Run clightningd";
path = [ pkgs.nix-bitcoin.bitcoind ];
@ -85,7 +89,6 @@ in {
requires = [ "bitcoind.service" ];
after = [ "bitcoind.service" ];
preStart = ''
mkdir -m 0770 -p ${cfg.dataDir}
cp ${configFile} ${cfg.dataDir}/config
chown -R 'clightning:clightning' '${cfg.dataDir}'
# The RPC socket has to be removed otherwise we might have stale sockets