From 63d49a4b11615dfe343ba036c6e1637d9beb19dc Mon Sep 17 00:00:00 2001 From: Quandrax <128057564+Quandrax@users.noreply.github.com> Date: Tue, 2 Jun 2026 20:04:00 +0200 Subject: [PATCH] hmmodule: add startup script if systemd is enabled --- nix/hm-modules.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/nix/hm-modules.nix b/nix/hm-modules.nix index eba05e2f..21196e9a 100644 --- a/nix/hm-modules.nix +++ b/nix/hm-modules.nix @@ -11,10 +11,15 @@ let variables = lib.concatStringsSep " " cfg.systemd.variables; extraCommands = lib.concatStringsSep " && " cfg.systemd.extraCommands; systemdActivation = "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"; - autostart_sh = pkgs.writeShellScript "autostart.sh" '' - ${lib.optionalString cfg.systemd.enable systemdActivation} - ${cfg.autostart_sh} - ''; + addAutostartScript = cfg.autostart_sh != "" || cfg.systemd.enable; + autostart_sh = + if addAutostartScript then + pkgs.writeShellScript "autostart.sh" '' + ${lib.optionalString cfg.systemd.enable systemdActivation} + ${cfg.autostart_sh} + '' + else + null; in { options = { @@ -228,7 +233,7 @@ in ) ) + lib.optionalString (cfg.extraConfig != "") cfg.extraConfig - + lib.optionalString (cfg.autostart_sh != "") "\nexec-once=~/.config/mango/autostart.sh\n"; + + lib.optionalString (addAutostartScript) "\nexec-once=~/.config/mango/autostart.sh\n"; validatedConfig = pkgs.runCommand "mango-config.conf" { } '' cp ${pkgs.writeText "mango-config.conf" finalConfigText} "$out" @@ -251,7 +256,7 @@ in { source = validatedConfig; }; - "mango/autostart.sh" = lib.mkIf (cfg.autostart_sh != "") { + "mango/autostart.sh" = lib.mkIf addAutostartScript { source = autostart_sh; executable = true; };