summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix107
1 files changed, 75 insertions, 32 deletions
diff --git a/flake.nix b/flake.nix
index ca3e1c5..c493fcd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,6 +13,11 @@
       inputs.nixpkgs.follows = "nixpkgs";
     };
 
+    nixos-apple-silicon = {
+      url = "github:nix-community/nixos-apple-silicon";
+      inputs.nixpkgs.follows = "nixpkgs-unstable";
+    };
+
     agenix = {
       url = "github:ryantm/agenix";
       inputs.nixpkgs.follows = "nixpkgs";
@@ -38,6 +43,7 @@
       nixpkgs,
       nixpkgs-unstable,
       lix-module,
+      nixos-apple-silicon,
       agenix,
       home-manager,
       nix-vscode-extensions,
@@ -45,22 +51,37 @@
       ...
     }:
     let
-      system = "x86_64-linux";
-
-      machines = [
-        "graphite"
-        "bismuth"
+      systems = {
+        x86 = "x86_64-linux";
+        arm = "aarch64-linux";
+      };
+
+      machines = with systems; [
+        {
+          name = "graphite";
+          system = x86;
+        }
+        {
+          name = "moissanite";
+          system = arm;
+        }
+        {
+          name = "bismuth";
+          system = x86;
+        }
       ];
 
       overlays = [
         lix-module.overlays.default
+        nixos-apple-silicon.overlays.default # unused on non-asahi machines
         agenix.overlays.default
         nix-vscode-extensions.overlays.default
         nixpkgs-esp-dev.overlays.default
         (import ./overlay.nix)
       ];
 
-      packageSets =
+      packageSetsForSystem =
+        system:
         let
           commonPkgsInputs = {
             inherit system;
@@ -72,38 +93,60 @@
 
           unstablePkgs = import nixpkgs-unstable commonPkgsInputs;
 
-          auxiliaryPkgs = import ./pkgs { inherit pkgs unstablePkgs nixpkgs nixpkgs-unstable; };
+          auxiliaryPkgs = import ./pkgs {
+            inherit
+              pkgs
+              unstablePkgs
+              nixpkgs
+              nixpkgs-unstable
+              ;
+          };
         };
 
+      inherit (nixpkgs) lib;
     in
     {
-      nixosConfigurations = nixpkgs.lib.genAttrs machines (
-        machine:
-        let
-          specialArgs = inputs // packageSets // { me = machine; };
-        in
-        nixpkgs.lib.nixosSystem {
-          inherit system specialArgs;
-
-          modules = [
-            ./machines/${machine}
-
-            home-manager.nixosModules.home-manager
-            {
-              home-manager.useGlobalPkgs = true;
-              home-manager.useUserPackages = true;
-              home-manager.backupFileExtension = "hm-backup";
-              home-manager.extraSpecialArgs = specialArgs;
-              home-manager.users.mel = import ./machines/${machine}/home.nix;
-            }
-
-            lix-module.nixosModules.default
-            agenix.nixosModules.default
-          ];
-        }
+      nixosConfigurations = lib.mergeAttrsList (
+        map (
+          machine:
+          let
+            packageSets = packageSetsForSystem machine.system;
+
+            specialArgs = inputs // packageSets // { me = machine; };
+          in
+          {
+            ${machine.name} = lib.nixosSystem {
+              inherit (machine) system;
+              inherit specialArgs;
+
+              modules = [
+                ./machines/${machine.name}
+
+                home-manager.nixosModules.home-manager
+                {
+                  home-manager.useGlobalPkgs = true;
+                  home-manager.useUserPackages = true;
+                  home-manager.backupFileExtension = "hm-backup";
+                  home-manager.extraSpecialArgs = specialArgs;
+                  home-manager.users.mel = import ./machines/${machine.name}/home.nix;
+                }
+
+                lix-module.nixosModules.default
+                agenix.nixosModules.default
+              ];
+            };
+          }
+        ) machines
       );
 
       # compatibility wrapper for nixos-option
-      legacyPackages.${system} = with packageSets; pkgs.recurseIntoAttrs pkgs;
+      legacyPackages = lib.genAttrs (lib.attrValues systems) (
+        system:
+        let
+          packageSets = packageSetsForSystem system;
+        in
+        with packageSets;
+        pkgs.recurseIntoAttrs pkgs
+      );
     };
 }