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:
parent
423ebf862b
commit
91b6b2c370
8 changed files with 31 additions and 18 deletions
|
|
@ -255,19 +255,17 @@ in {
|
|||
sysperms = true;
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
|
||||
"d '${cfg.dataDir}/blocks' 0770 ${cfg.user} ${cfg.group} - -"
|
||||
];
|
||||
|
||||
systemd.services.bitcoind = {
|
||||
description = "Bitcoin daemon";
|
||||
requires = [ "nix-bitcoin-secrets.target" ];
|
||||
after = [ "network.target" "nix-bitcoin-secrets.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
preStart = ''
|
||||
if [[ ! -e ${cfg.dataDir} ]]; then
|
||||
mkdir -m 0770 -p '${cfg.dataDir}'
|
||||
fi
|
||||
if [[ ! -e ${cfg.dataDir}/blocks ]]; then
|
||||
mkdir -m 0770 -p '${cfg.dataDir}/blocks'
|
||||
fi
|
||||
chown -R '${cfg.user}:${cfg.group}' '${cfg.dataDir}'
|
||||
${optionalString cfg.dataDirReadableByGroup "chmod -R g+rX '${cfg.dataDir}/blocks'"}
|
||||
|
||||
cfg=$(cat ${configFile}; printf "rpcpassword="; cat "${config.nix-bitcoin.secretsDir}/bitcoin-rpcpassword")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue