systemd: install systemd files when user is root (revert c2aa831) (#9274)

* systemd: install systemd files when user is root (revert c2aa831)

* Apply suggestions from code review

Co-authored-by: Anillc <void@anil.lc>

---------

Co-authored-by: Anillc <void@anil.lc>
This commit is contained in:
David Alcalde
2026-05-11 16:36:25 -05:00
committed by GitHub
parent bc63bedcab
commit 5b73f949a1
4 changed files with 2 additions and 28 deletions

View File

@@ -467,7 +467,7 @@ in
systemctl = "${ensureSystemd} systemctl";
in
mkIf (systemdCfg.enable && config.home.username != "root") (
mkIf systemdCfg.enable (
hm.dag.entryAfter [ "onFilesChange" "reloadSystemd" ] ''
if [[ -v PIPEWIRE_RELOAD ]]; then
if [[ -v DRY_RUN ]]; then

View File

@@ -454,8 +454,7 @@ in
# If we run under a Linux system we assume that systemd is
# available, in particular we assume that systemctl is in PATH.
# Do not install any user services if username is root.
config = mkIf (cfg.enable && config.home.username != "root") {
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "systemd" pkgs lib.platforms.linux)
];

View File

@@ -1,7 +1,6 @@
{
systemd-services = ./services.nix;
systemd-packages = ./packages.nix;
systemd-services-disabled-for-root = ./services-disabled-for-root.nix;
systemd-session-variables = ./session-variables.nix;
systemd-user-config = ./user-config.nix;
systemd-empty-user-config = ./empty-user-config.nix;

View File

@@ -1,24 +0,0 @@
{ lib, ... }:
{
home.username = lib.mkForce "root";
systemd.user.services."test-service@" = {
Unit = {
Description = "A basic test service";
};
Service = {
Environment = [
"VAR1=1"
"VAR2=2"
];
ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
};
};
nmt.script = ''
serviceFile=home-files/.config/systemd/user/test-service@.service
assertPathNotExists $serviceFile
'';
}