From f949ce7449cfa2bd42992e7791a94a7249ec4976 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Tue, 3 Aug 2021 23:29:31 -0700 Subject: [PATCH] nixos/hqplayerd: set HOME to path in state directory The service likes to write files uploaded by the user to the service user's $HOME. In our case the hqplayerd user has no home directory, since it's a system user, and regardless we'd like to keep the service's state contained. With this change the unit forces HOME to point to /var/lib/hqplayer/home, which works around the issue. --- nixos/modules/services/audio/hqplayerd.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/audio/hqplayerd.nix b/nixos/modules/services/audio/hqplayerd.nix index 3a703c97c0f7..b4d8468a2375 100644 --- a/nixos/modules/services/audio/hqplayerd.nix +++ b/nixos/modules/services/audio/hqplayerd.nix @@ -100,8 +100,9 @@ in systemd = { tmpfiles.rules = [ - "d ${configDir} 0755 ${cfg.user} ${cfg.group} - -" - "d ${stateDir} 0755 ${cfg.user} ${cfg.group} - -" + "d ${configDir} 0755 ${cfg.user} ${cfg.group} - -" + "d ${stateDir} 0755 ${cfg.user} ${cfg.group} - -" + "d ${stateDir}/home 0755 ${cfg.user} ${cfg.group} - -" ]; services.hqplayerd = { @@ -110,6 +111,8 @@ in requires = [ "network-online.target" "sound.target" "systemd-udev-settle.service" ]; after = [ "network-online.target" "sound.target" "systemd-udev-settle.service" "local-fs.target" "remote-fs.target" "systemd-tmpfiles-setup.service" ]; + environment.HOME = "${stateDir}/home"; + unitConfig.ConditionPathExists = [ configDir stateDir ]; preStart =