From 29b672194d4badd35d063d46365ed9f4ec60a32c Mon Sep 17 00:00:00 2001 From: damidoug Date: Fri, 14 Nov 2025 20:18:15 +0100 Subject: [PATCH] aerospace: add assertion to ensure launchd.enable and after-startup-command are used instead of start-at-login and after-login-command --- modules/programs/aerospace.nix | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/programs/aerospace.nix b/modules/programs/aerospace.nix index 8260baad3..e6d69a4e6 100644 --- a/modules/programs/aerospace.nix +++ b/modules/programs/aerospace.nix @@ -135,6 +135,46 @@ in config = lib.mkIf cfg.enable { assertions = [ (lib.hm.assertions.assertPlatform "programs.aerospace" pkgs lib.platforms.darwin) + + # 1. Fail if user sets start-at-login = true BUT launchd is disabled. + { + assertion = + !((lib.hasAttr "start-at-login" cfg.settings) && (cfg.settings."start-at-login" == true)) + || (cfg.launchd.enable == true); + message = '' + You have set `programs.aerospace.settings."start-at-login" = true;` + but `programs.aerospace.launchd.enable` is false. + + This tells AeroSpace to manage its own startup, which can conflict + with Home Manager. + + To manage startup with Home Manager, please set + `programs.aerospace.launchd.enable = true;` + (You can leave `start-at-login = true` in your settings, it will be + correctly overridden). + ''; + } + + # 2. Fail if user sets after-login-command (in any case). + { + assertion = + !( + (lib.hasAttr "after-login-command" cfg.settings) + && (lib.isList cfg.settings."after-login-command") + && (cfg.settings."after-login-command" != [ ]) + ); + message = '' + You have set `programs.aerospace.settings."after-login-command"`. + + This setting is not supported when using this Home Manager module, + as it either conflicts with the launchd service (if enabled) + or bypasses it (if disabled). + + The correct way to run commands after AeroSpace starts is to use: + 1. `programs.aerospace.launchd.enable = true;` + 2. `programs.aerospace.settings."after-startup-command" = [ ... ];` + ''; + } ]; home = { @@ -145,7 +185,7 @@ in generatedConfig = tomlFormat.generate "aerospace" ( filterNulls ( cfg.settings - // lib.optionalAttrs cfg.launchd.enable { + // { # Override these to avoid launchd conflicts start-at-login = false; after-login-command = [ ];