about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-02-17 22:51:13 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-02-17 22:51:13 +0100
commite2cb67573509e4bde23c2ca5aa093794ddfb69b1 (patch)
treea16f16c82e4c22bcc7c51f70105546b7347fbfb1
parentDotfiles: Emacs: Open file in same window on left click (diff)
downloadnixos-config-e2cb67573509e4bde23c2ca5aa093794ddfb69b1.tar.gz
nixos-config-e2cb67573509e4bde23c2ca5aa093794ddfb69b1.tar.bz2
nixos-config-e2cb67573509e4bde23c2ca5aa093794ddfb69b1.zip
Nix: Initial darwin setup
-rw-r--r--flake.lockbin7272 -> 7775 bytes
-rw-r--r--flake.nix20
-rw-r--r--hosts/darwin.nix4
-rw-r--r--hosts/default.nix14
4 files changed, 33 insertions, 5 deletions
diff --git a/flake.lock b/flake.lock
index 1b6f6ae..d1174f7 100644
--- a/flake.lock
+++ b/flake.lock
Binary files differdiff --git a/flake.nix b/flake.nix
index 1f474c1..d51c66d 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,6 +9,11 @@
       inputs.nixpkgs.follows = "nixpkgs";
     };
 
+    nix-darwin = {
+      url = "github:LnL7/nix-darwin";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
     hardware.url = "github:NixOS/nixos-hardware";
 
     impermanence.url = "github:nix-community/impermanence";
@@ -40,7 +45,7 @@
     };
   };
 
-  outputs = inputs @ { self, nixpkgs, home-manager, ... }:
+  outputs = inputs @ { self, nixpkgs, home-manager, nix-darwin, ... }:
     let
       user = "baitinq";
 
@@ -71,25 +76,35 @@
 
       commonInherits = {
         inherit (nixpkgs) lib;
-        inherit inputs nixpkgs home-manager;
+        inherit inputs nixpkgs home-manager nix-darwin;
         inherit user secrets dotfiles hosts hardwares systems;
       };
     in
     {
       nixosConfigurations = import ./hosts (commonInherits // {
         isNixOS = true;
+        isMacOS = false;
+        isIso = false;
+        isHardware = true;
+      });
+
+      darwinConfigurations = import ./hosts (commonInherits // {
+        isNixOS = false;
+        isMacOS = true;
         isIso = false;
         isHardware = true;
       });
 
       homeConfigurations = import ./hosts (commonInherits // {
         isNixOS = false;
+        isMacOS = false;
         isIso = false;
         isHardware = false;
       });
 
       isoConfigurations = import ./hosts (commonInherits // {
         isNixOS = true;
+        isMacOS = false;
         isIso = true;
         isHardware = false;
         user = "nixos";
@@ -97,6 +112,7 @@
 
       nixosNoHardwareConfigurations = import ./hosts (commonInherits // {
         isNixOS = true;
+        isMacOS = false;
         isIso = false;
         isHardware = false;
       });
diff --git a/hosts/darwin.nix b/hosts/darwin.nix
new file mode 100644
index 0000000..5c17eea
--- /dev/null
+++ b/hosts/darwin.nix
@@ -0,0 +1,4 @@
+{...}:
+{
+    services.nix-daemon.enable = true;
+}
\ No newline at end of file
diff --git a/hosts/default.nix b/hosts/default.nix
index 7623863..0fc93e7 100644
--- a/hosts/default.nix
+++ b/hosts/default.nix
@@ -1,6 +1,6 @@
-{ lib, inputs, secrets, dotfiles, hosts, hardwares, systems, isNixOS, isIso, isHardware, user, nixpkgs, home-manager, ... }:
+{ lib, inputs, secrets, dotfiles, hosts, hardwares, systems, isNixOS, isMacOS, isIso, isHardware, user, nixpkgs, home-manager, nix-darwin, ... }:
 let
-  mkHost = { host, hardware, stateVersion, system, timezone, location, extraOverlays, extraModules }: isNixOS: isIso: isHardware:
+  mkHost = { host, hardware, stateVersion, system, timezone, location, extraOverlays, extraModules }: isNixOS: isMacOS: isIso: isHardware:
     let
       pkgs = import nixpkgs {
         inherit system;
@@ -43,6 +43,14 @@ let
             }
           ] ++ extraSpecialModules;
         }
+    else if isMacOS
+    then
+      nix-darwin.lib.darwinSystem
+      {
+        inherit system;
+        modules = [ ./darwin.nix ];
+        specialArgs = extraArgs;
+      }
     else
       home-manager.lib.homeManagerConfiguration
         {
@@ -63,4 +71,4 @@ in
     Map each element of the list applying the mkHost function to its elements and returning a set in the listToAttrs format
     builtins.listToAttrs on the result
   */
-builtins.listToAttrs (map (mInput@{ host, hardware, system, ... }: { name = host + "-" + hardware + "-" + system; value = mkHost mInput isNixOS isIso isHardware; }) permutatedHosts)
+builtins.listToAttrs (map (mInput@{ host, hardware, system, ... }: { name = host + "-" + hardware + "-" + system; value = mkHost mInput isNixOS isMacOS isIso isHardware; }) permutatedHosts)