From 28c8db6cb7c25550ca06bfa1110e012ed3b3d7a5 Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Mon, 16 Mar 2026 15:49:43 -0600 Subject: [PATCH] split home-manager into their own submodules --- .codex/rules/default.rules | 2 + config/base.nix | 2 + config/home-manager.nix | 1 + config/jawz-home.nix | 32 ++++++ config/jawz.nix | 23 ---- docs/constitution.md | 11 +- docs/playbooks/add-module.md | 6 +- docs/playbooks/split-home-manager.md | 19 ++++ docs/reference/index.md | 34 +++--- modules/apps/internet.nix | 66 ------------ modules/apps/internet/home.nix | 68 ++++++++++++ modules/apps/internet/nixos.nix | 19 ++++ modules/dev/emacs.nix | 88 --------------- modules/dev/emacs/common.nix | 44 ++++++++ modules/dev/emacs/home.nix | 61 +++++++++++ modules/dev/emacs/nixos.nix | 16 +++ modules/dev/javascript.nix | 60 ----------- modules/dev/javascript/common.nix | 25 +++++ modules/dev/javascript/home.nix | 43 ++++++++ modules/dev/javascript/nixos.nix | 27 +++++ modules/dev/nix.nix | 60 ----------- modules/dev/nix/common.nix | 45 ++++++++ modules/dev/nix/home.nix | 40 +++++++ modules/dev/nix/nixos.nix | 30 ++++++ modules/dev/python.nix | 66 ------------ modules/dev/python/common.nix | 31 ++++++ modules/dev/python/home.nix | 36 +++++++ modules/dev/python/nixos.nix | 26 +++++ modules/home-manager.nix | 4 + modules/modules.nix | 8 ++ modules/scripts/download.nix | 112 -------------------- modules/scripts/download/common.nix | 25 +++++ modules/scripts/download/home.nix | 25 +++++ modules/scripts/download/nixos.nix | 95 +++++++++++++++++ modules/scripts/update-org-agenda-cache.nix | 32 +++--- modules/shell/multimedia.nix | 67 ------------ modules/shell/multimedia/common.nix | 10 ++ modules/shell/multimedia/home.nix | 62 +++++++++++ modules/shell/multimedia/nixos.nix | 27 +++++ modules/shell/{tools.nix => tools/home.nix} | 100 +++++++++-------- modules/shell/tools/nixos.nix | 27 +++++ parts/core.nix | 57 ++++++++++ specs/001-ai-docs/research.md | 5 + 43 files changed, 1011 insertions(+), 626 deletions(-) create mode 100644 .codex/rules/default.rules create mode 100644 config/jawz-home.nix create mode 100644 docs/playbooks/split-home-manager.md delete mode 100644 modules/apps/internet.nix create mode 100644 modules/apps/internet/home.nix create mode 100644 modules/apps/internet/nixos.nix delete mode 100644 modules/dev/emacs.nix create mode 100644 modules/dev/emacs/common.nix create mode 100644 modules/dev/emacs/home.nix create mode 100644 modules/dev/emacs/nixos.nix delete mode 100644 modules/dev/javascript.nix create mode 100644 modules/dev/javascript/common.nix create mode 100644 modules/dev/javascript/home.nix create mode 100644 modules/dev/javascript/nixos.nix delete mode 100644 modules/dev/nix.nix create mode 100644 modules/dev/nix/common.nix create mode 100644 modules/dev/nix/home.nix create mode 100644 modules/dev/nix/nixos.nix delete mode 100644 modules/dev/python.nix create mode 100644 modules/dev/python/common.nix create mode 100644 modules/dev/python/home.nix create mode 100644 modules/dev/python/nixos.nix create mode 100644 modules/home-manager.nix delete mode 100644 modules/scripts/download.nix create mode 100644 modules/scripts/download/common.nix create mode 100644 modules/scripts/download/home.nix create mode 100644 modules/scripts/download/nixos.nix delete mode 100644 modules/shell/multimedia.nix create mode 100644 modules/shell/multimedia/common.nix create mode 100644 modules/shell/multimedia/home.nix create mode 100644 modules/shell/multimedia/nixos.nix rename modules/shell/{tools.nix => tools/home.nix} (53%) create mode 100644 modules/shell/tools/nixos.nix diff --git a/.codex/rules/default.rules b/.codex/rules/default.rules new file mode 100644 index 0000000..6e4c1b2 --- /dev/null +++ b/.codex/rules/default.rules @@ -0,0 +1,2 @@ +prefix_rule(pattern=["deadnix", "-e"], decision="allow") +prefix_rule(pattern=["nix", "eval"], decision="allow") diff --git a/config/base.nix b/config/base.nix index 98e8729..496dff1 100644 --- a/config/base.nix +++ b/config/base.nix @@ -26,6 +26,7 @@ backupFileExtension = "hbckup"; useUserPackages = true; useGlobalPkgs = true; + sharedModules = [ ../modules/home-manager.nix ]; extraSpecialArgs = { inherit inputs outputs; }; @@ -98,6 +99,7 @@ "flakes" "pipe-operators" ]; + download-buffer-size = 134217728; substituters = [ "${config.my.servers.atticd.url}/nixos" "${config.my.servers.atticd.url}/webref" diff --git a/config/home-manager.nix b/config/home-manager.nix index 2d9622b..6005b61 100644 --- a/config/home-manager.nix +++ b/config/home-manager.nix @@ -21,6 +21,7 @@ let }; in { + imports = [ ./jawz-home.nix ]; home.stateVersion = "23.05"; programs = { direnv = { diff --git a/config/jawz-home.nix b/config/jawz-home.nix new file mode 100644 index 0000000..44df969 --- /dev/null +++ b/config/jawz-home.nix @@ -0,0 +1,32 @@ +{ + lib, + inputs, + osConfig, + ... +}: +let + inherit (osConfig.networking) hostName; + nixosHosts = inputs.self.lib.getNixosHosts osConfig.my.ips hostName lib; + nixosHostsMatch = lib.concatStringsSep " " nixosHosts; +in +{ + home.file.".librewolf/.stignore".source = ../dotfiles/stignore; + programs.ssh = lib.mkIf osConfig.my.secureHost { + enable = true; + enableDefaultConfig = false; + matchBlocks = { + vps = { + hostname = osConfig.my.ips.vps; + user = "jawz"; + port = 3456; + identityFile = osConfig.sops.secrets."private_keys/${hostName}".path; + }; + "${nixosHostsMatch}" = { + user = "jawz"; + identityFile = osConfig.sops.secrets."private_keys/${hostName}".path; + }; + "${osConfig.my.servers.gitea.host} github.com gitlab.com bitbucket.org".identityFile = + osConfig.sops.secrets."git_private_keys/${hostName}".path; + }; + }; +} diff --git a/config/jawz.nix b/config/jawz.nix index fd33b82..e986abf 100644 --- a/config/jawz.nix +++ b/config/jawz.nix @@ -6,8 +6,6 @@ }: let inherit (config.networking) hostName; - nixosHosts = inputs.self.lib.getNixosHosts config.my.ips hostName lib; - nixosHostsMatch = lib.concatStringsSep " " nixosHosts; in { sops.secrets = lib.mkIf config.my.secureHost ( @@ -26,27 +24,6 @@ in "git_private_keys/${hostName}" = keyConfig "${baseDir}_git"; } ); - home-manager.users.jawz = { - home.file.".librewolf/.stignore".source = ../dotfiles/stignore; - programs.ssh = lib.mkIf config.my.secureHost { - enable = true; - enableDefaultConfig = false; - matchBlocks = { - vps = { - hostname = config.my.ips.vps; - user = "jawz"; - port = 3456; - identityFile = config.sops.secrets."private_keys/${hostName}".path; - }; - "${nixosHostsMatch}" = { - user = "jawz"; - identityFile = config.sops.secrets."private_keys/${hostName}".path; - }; - "${config.my.servers.gitea.host} github.com gitlab.com bitbucket.org".identityFile = - config.sops.secrets."git_private_keys/${hostName}".path; - }; - }; - }; users.users.jawz = { uid = 1000; linger = true; diff --git a/docs/constitution.md b/docs/constitution.md index 6ebec3d..9d67a19 100644 --- a/docs/constitution.md +++ b/docs/constitution.md @@ -7,7 +7,7 @@ ## Repository Overview - Architecture: Flake-based repo using `flake-parts` with inputs for pkgs (stable/unstable), stylix, home-manager, sops-nix, and service overlays. Common modules are composed through `parts/core.nix` and `parts/hosts.nix`. -- Module auto-import: `modules/modules.nix` auto-imports `.nix` files under `modules/apps`, `modules/dev`, `modules/scripts`, `modules/servers`, `modules/services`, `modules/shell`, `modules/websites`, and `modules/network`, excluding `librewolf.nix`. Factories live in `modules/factories/` (`mkserver`, `mkscript`), and shared options are in `modules/nix` and `modules/users`. +- Module auto-import: `modules/modules.nix` auto-imports legacy flat modules under `modules/apps`, `modules/dev`, `modules/scripts`, `modules/servers`, `modules/services`, `modules/shell`, `modules/websites`, and `modules/network`, excluding `librewolf.nix`, and also discovers nested `nixos.nix` files under those trees. `config/base.nix` registers `modules/home-manager.nix` as a Home Manager shared module, which discovers nested `home.nix` files under `modules/` for every Home Manager user. Factories live in `modules/factories/` (`mkserver`, `mkscript`), and shared options are in `modules/nix` and `modules/users`. - Hosts and toggles: Host definitions live in `hosts//configuration.nix` with host-specific toggles in `hosts//toggles.nix`. The `my` namespace carries toggles for apps/dev/scripts/services/shell, feature flags like `enableProxy` and `enableContainers`, and per-host `interfaces` and `ips` maps. - Port assignment: Service ports should live with the service module when the port is intrinsic to a server definition under `modules/servers/`. Miscellaneous or host-specific ports that do not belong to a server module should be centralized in `my.ports` in `modules/modules.nix` and referenced via `config.my.ports.*` (use `toString config.my.ports.*` where a string is required). - Main server and proxies: `my.mainServer` selects the host that should serve traffic by default (default `vps`). Reverse proxies use helpers in `parts/core.nix` (`proxy`, `proxyReverse`, `proxyReverseFix`, `proxyReversePrivate`) and pick IPs from `my.ips` plus the hostName/ip set by `mkserver` options. Nginx defaults to `proxyReverse` for any server with `enableProxy = true` unless `useDefaultProxy = false` or the server is listed in the Fix/Private proxy lists. @@ -30,10 +30,10 @@ config.services = { ``` ## Terminology and Naming Standards -- Module: A Nix module under `modules//.nix` auto-imported into the system. +- Module: Prefer a feature directory under `modules///` with `nixos.nix` for system concerns and `home.nix` for Home Manager concerns. Legacy flat modules at `modules//.nix` remain valid during migration. - Factory: Shared option constructors in `modules/factories/` (use `mkserver` for server modules, `mkscript` for script units). - Options: Settings under the `my` namespace (e.g., `my.services.`, `my.scripts.