about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2025-01-19 09:03:42 +1000
committersefidel <contact@sefidel.net>2025-01-19 09:03:42 +1000
commit73340250f8e141124fd38a12a7412480dcd00a3c (patch)
treee49646fe57b5e152831194a100e59f7614b5ad6c
parent4ae754da489191312f8ff2058f237f25aa6993ef (diff)
downloadnixrc-73340250f8e141124fd38a12a7412480dcd00a3c.tar.gz
nixrc-73340250f8e141124fd38a12a7412480dcd00a3c.zip
feat(lib): add mkDarwin
-rw-r--r--lib/mk_darwin.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/mk_darwin.nix b/lib/mk_darwin.nix
new file mode 100644
index 0000000..1da4dc3
--- /dev/null
+++ b/lib/mk_darwin.nix
@@ -0,0 +1,23 @@
+{ self, unstable, nix-darwin, ... } @ args:
+{
+  mkDarwin = { name, nixpkgs ? unstable, system ? "aarch64-darwin", overlays ? null, extraModules ? null }:
+    nix-darwin.lib.darwinSystem (
+      let
+        configFolder = "${self}/darwin";
+        entryPoint = "${configFolder}/${name}/configuration.nix";
+      in
+      {
+        system = system;
+        pkgs = import nixpkgs { inherit system; };
+
+        modules = [
+          {
+            networking.hostName = name;
+            system.configurationRevision = self.rev or self.dirtyRev;
+          }
+          entryPoint
+        ] ++ nixpkgs.lib.optional (overlays != null) { nixpkgs.overlays = overlays; }
+        ++ nixpkgs.lib.optionals (extraModules != null) extraModules;
+      }
+    );
+}