about summary refs log tree commit diff
path: root/lib/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/default.nix')
-rw-r--r--lib/default.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 0000000..7f0f8ed
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,62 @@
+{ inputs, overlays }:
+{
+  mkSystem =
+    { hostname
+    , system
+    , desktop ? false
+    }:
+    inputs.nixpkgs.lib.nixosSystem {
+      inherit system;
+      specialArgs = {
+        inherit inputs system hostname desktop;
+      };
+      modules = [
+        ../modules/deskop
+        ../modules/system
+        ../hosts/${hostname}
+        {
+          networking.hostName = hostname;
+          # Apply overlay and allow unfree packages
+          nixpkgs = {
+            inherit overlays;
+            config.allowUnfree = true;
+          };
+          # Add each input as a registry
+          nix.registry = inputs.nixpkgs.lib.mapAttrs'
+            (n: v:
+              inputs.nixpkgs.lib.nameValuePair (n) ({ flake = v; }))
+            inputs;
+        }
+      ]
+    };
+
+  mkHome =
+    { username
+    , system
+    , hostname
+    , desktop ? false
+    }:
+    inputs.home-manager.lib.homeManagerConfiguration {
+      inherit username system;
+      extraSpecialArgs = {
+        inherit system hostname graphical;
+      };
+      homeDirectory = "/home/${username}";
+      configuration = ../users/${username};
+      extraModules = [
+        ../modules/home-manager
+        # Base configuration
+        {
+          nixpkgs = {
+            inherit overlays;
+            config.allowUnfree = true;
+          };
+          programs = {
+            home-manager.enable = true;
+            git.enable = true;
+          };
+          systemd.user.startServices = "sd-switch";
+        }
+      ];
+    };
+}