about summary refs log tree commit diff
path: root/lib/mk_system.nix
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2024-01-23 00:20:54 +0900
committersefidel <contact@sefidel.net>2024-01-23 01:05:04 +0900
commitb311d7f8459fe1e90f7b0cbf5862b22a2cbedff5 (patch)
treed7b8af8e685699a1e66afcb10b668363d604106e /lib/mk_system.nix
parentb670811db1c645c9c4effff1829e90b380318427 (diff)
downloadnixrc-b311d7f8459fe1e90f7b0cbf5862b22a2cbedff5.tar.gz
nixrc-b311d7f8459fe1e90f7b0cbf5862b22a2cbedff5.zip
feat(lib)!: refactor
Diffstat (limited to 'lib/mk_system.nix')
-rw-r--r--lib/mk_system.nix45
1 files changed, 27 insertions, 18 deletions
diff --git a/lib/mk_system.nix b/lib/mk_system.nix
index 54dddbe..2aca550 100644
--- a/lib/mk_system.nix
+++ b/lib/mk_system.nix
@@ -1,23 +1,32 @@
-{ self, ... } @ args:
-
-{ name, nixpkgs, system ? "x86_64-linux", overlays ? null, extraModules ? null }:
-nixpkgs.lib.nixosSystem (
-  let
-    configFolder = "${self}/nixos";
-    entryPoint = "${configFolder}/${name}/configuration.nix";
-    hardware = "${configFolder}/${name}/hardware-configuration.nix";
-  in
-  {
-    system = system;
+{ self, unstable, ... } @ args:
+{
+  mkSystem = { name, nixpkgs ? unstable, system ? "x86_64-linux", overlays ? null, extraModules ? null }:
+    nixpkgs.lib.nixosSystem (
+      let
+        configFolder = "${self}/nixos";
+        entryPoint = "${configFolder}/${name}/configuration.nix";
+        hardware = "${configFolder}/${name}/hardware-configuration.nix";
+      in
+      {
+        system = system;
 
-    specialArgs = args;
+        specialArgs = args;
 
-    modules = [
-      {
-        networking.hostName = name;
-        nix.flakes.enable = true;
-        system.configurationRevision = self.rev or "dirty";
-        documentation.man = { enable = true; generateCaches = true; };
+        modules = [
+          {
+            networking.hostName = name;
+            nix.flakes.enable = true;
+            system.configurationRevision = self.rev or "dirty";
+            documentation.man = { enable = true; generateCaches = true; };
+          }
+          entryPoint
+          hardware
+          # TODO: import all modules (use mapModules?)
+          ../modules/flakes.nix
+          ../modules/nix.nix
+          ../modules/nixpkgs.nix
+        ] ++ nixpkgs.lib.optional (overlays != null) { nixpkgs.overlays = overlays; }
+        ++ nixpkgs.lib.optionals (extraModules != null) extraModules;
       }
       entryPoint
       hardware