From d83255dc91b978bc7edfd06b0f419ea7de66293b Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Sun, 19 May 2024 14:32:22 -0400 Subject: [PATCH] Stable modular build --- modules/lib.nix | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/modules/lib.nix b/modules/lib.nix index 2a92084..5b2a854 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -2,26 +2,45 @@ , home-manager , nix-darwin }: +let + makeImports = + { attrs + , home-manager-modules + }: (if (isNull attrs.configuration) then [ ] else [ attrs.configuration ]) + ++ [ + (import ./main.nix attrs) + ] ++ (if attrs.home-manager.enable then + home-manager-modules + else + [ ]); +in { - makeNixOsModule = { system, configuration ? null, ... }@attrs: + makeNixOsModule = + { system + , configuration ? null + , ... + }@attrs: nixpkgs.lib.nixosSystem { system = system; - modules = (if (isNull configuration) then [ ] else [ configuration ]) ++ - (if attrs.home-manager.enable then - [ home-manager.nixosModules.default ] - else - [ ]); + modules = (makeImports { + attrs = attrs; + home-manager-modules = [ home-manager.nixosModules.default ]; + }); }; makeDarwinModule = - { system ? "x86_64-darwin", user, configuration ? null, ... }@attrs: + { system ? "x86_64-darwin" + , user + , configuration ? null + , ... + }@attrs: nix-darwin.lib.darwinSystem { - modules = (import ./main.nix attrs) - ++ (if attrs.home-manager.enable then [ - home-manager.darwinModules.home-manager - (import ./macos-home-manager.nix { user = user; }) - ] else - [ ]) - ++ (if (isNull configuration) then [ configuration ] else [ ]) ++ [ + modules = (makeImports { + attrs = attrs; + home-manager-modules = [ + home-manager.darwinModules.home-manager + (import ./macos-home-manager.nix { user = user; }) + ]; + }) ++ [ (import ./macos.nix { user = user; system = system;