From fe37ad29e05e214dfbb43d7ec5c10ef031d58781 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 13 Oct 2024 20:15:40 +0200
Subject: [PATCH] Inherit user app enablement from OS

---
 lib/modules/software.nix | 25 ++++++++++++++++++++++++-
 lib/modules/valhalla.nix |  4 ----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/modules/software.nix b/lib/modules/software.nix
index 6f65ae04..d51361e0 100644
--- a/lib/modules/software.nix
+++ b/lib/modules/software.nix
@@ -1,10 +1,33 @@
 { lib, config, ... }:
 let
-  inherit (lib) mkOption types;
+  inherit (lib) mkDefault mkOption types;
   cfg = config.valhalla;
+
+  mkUsersOption = osConfig: mkOption {
+    type = types.attrsOf (types.submodule (
+      { ... }: {
+        config = {
+          programs = builtins.mapAttrs (
+            name: config: {
+              enable = mkDefault config.enable;
+            }) osConfig.programs;
+        };
+      }));
+  };
 in {
+  imports = [
+    ./programs/git.nix
+    ./programs/nextcloud.nix
+    ./programs/oh-my-posh.nix
+    ./programs/rclone.nix
+  ];
+
   options = {
     valhalla = {
+      users = mkUsersOption cfg;
+      linux.users = mkUsersOption cfg.linux;
+      windows.users = mkUsersOption cfg.windows;
+
       software = let
         inherit (cfg.software) coding common desktopExperience school server;
       in {
diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix
index 130f5462..25fa9008 100644
--- a/lib/modules/valhalla.nix
+++ b/lib/modules/valhalla.nix
@@ -5,10 +5,6 @@ in {
     ./hardware.nix
     ./i18n.nix
     ./os.nix
-    ./programs/git.nix
-    ./programs/nextcloud.nix
-    ./programs/oh-my-posh.nix
-    ./programs/rclone.nix
     ./partition.nix
     ./software.nix
     ./users.nix