From 7b5d72822942f4b07a9075b5e220d436befa2d21 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Fri, 14 Feb 2025 14:05:36 +0530 Subject: [PATCH] fix: Temporarily rely on parent module name to get the `homeModules` working --- nix/lib.nix | 16 +++++++--------- nix/services/default.nix | 9 +++++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/nix/lib.nix b/nix/lib.nix index 6fb0ad4..136ec5e 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -4,7 +4,7 @@ # where module filename is of form `${name}.nix`. The submodule takes this # 'name' parameter, and is expected to set the final process-compose config in # its `outputs.settings` option. - multiService = process-manager-name: mod: + multiService = name: mod: { config, pkgs, lib, ... }: let # Derive name from filename @@ -87,19 +87,17 @@ }); }; }; - config = lib.optionalAttrs (process-manager-name == "launchd") + config = lib.optionalAttrs (name == "homeModules") { + systemd.user.services = lib.pipe config.services.${service} [ + (lib.filterAttrs (_: cfg: cfg.enable)) + (lib.concatMapAttrs (_: cfg: cfg.outputs.systemd)) + ]; launchd.agents = lib.pipe config.services.${service} [ (lib.concatMapAttrs (_: cfg: lib.mapAttrs (_: cf: { ... }: { imports = [ cf ]; }) cfg.outputs.launchd)) ]; } - // lib.optionalAttrs (process-manager-name == "systemd") { - systemd.user.services = lib.pipe config.services.${service} [ - (lib.filterAttrs (_: cfg: cfg.enable)) - (lib.concatMapAttrs (_: cfg: cfg.outputs.systemd)) - ]; - } - // lib.optionalAttrs (process-manager-name == "process-compose") { + // lib.optionalAttrs (name == "processComposeModules") { settings = { imports = lib.pipe config.services.${service} [ diff --git a/nix/services/default.nix b/nix/services/default.nix index 08f9f51..d71d521 100644 --- a/nix/services/default.nix +++ b/nix/services/default.nix @@ -28,10 +28,15 @@ let in { processComposeModules = { - imports = (builtins.map (multiService "process-compose") services) ++ [ ./devShell.nix ]; + imports = (builtins.map (multiService "processComposeModules") services) ++ [ ./devShell.nix ]; }; homeModules = { - imports = (builtins.map (multiService "systemd") services) ++ (builtins.map (multiService "launchd") services); + imports = (builtins.map (multiService "homeModules") services); + # imports = lib.pipe services [ + # (map (multiService "systemd")) + # (map (multiService "launchd")) + # ]; + # imports = (builtins.map (multiService "systemd") services) ++ (builtins.map (multiService "launchd") services); }; }