zaphyra's git: nixfiles

zaphyra's nixfiles

commit d27220df693cb41b1323931c28d5a778138df9f3
parent 8a81f67d4d0897c34a5731c6d49812ee17e82acf
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Thu, 18 Jun 2026 15:01:15 +0200

default.nix: some refactoring
2 files changed, 64 insertions(+), 24 deletions(-)
M
default.nix
|
57
++++++++++++++++++++++++++++++++++-----------------------
M
flake.nix
|
31
++++++++++++++++++++++++++++++-
diff --git a/default.nix b/default.nix
@@ -1,4 +1,6 @@
 let
+  defaultSystem = if (builtins ? currentSystem) then builtins.currentSystem else "x86_64-linux";
+
   npins = import ./npins;
   overlays = import ./overlays { inherit npins; };
   nixosConfigurations = import ./machines { inherit lib npins; };

@@ -14,7 +16,6 @@ let
 in
 {
 
-  self = import ./.;
   outPath = ./.;
 
   inherit

@@ -24,36 +25,46 @@ in
     nixosConfigurations
     ;
 
-  formatter = lib.zpha.forAllSystems {
-    inherit (npins) nixpkgs;
-    body = pkgs: pkgs.nixfmt;
-  };
-
   nixosModules = import ./nixosModules { inherit lib; };
 
-  packages = lib.zpha.forAllSystems {
-    overlays = overlays.default;
-    body =
-      pkgs:
+  formatter =
+    {
+      system ? defaultSystem,
+    }:
+    (import npins.nixpkgs {
+      inherit system;
+    }).nixfmt;
+
+  packages =
+    {
+      system ? defaultSystem,
+    }:
+    let
+      pkgs = import npins.nixpkgs {
+        inherit system;
+        overlays = overlays.default;
+      };
+    in
+    (
       (import ./packages pkgs)
       // (builtins.listToAttrs (
         lib.flatten [
           (lib.flip lib.mapAttrsToList nixosConfigurations (
-            machineName: nixosConfiguration: [
-              (lib.nameValuePair "deploySystem-${machineName}" (
-                pkgs.zpha.deploySystem.override {
-                  systemConfig = nixosConfiguration.config;
-                }
-              ))
-              (lib.nameValuePair "setupDisk-${machineName}" (
-                pkgs.zpha.setupDisk.override {
+            machineName: nixosConfiguration:
+            (
+              let
+                attrs = {
                   systemConfig = nixosConfiguration.config;
-                }
-              ))
-            ]
+                };
+              in
+              [
+                (lib.nameValuePair "deploySystem-${machineName}" (pkgs.zpha.deploySystem.override attrs))
+                (lib.nameValuePair "setupDisk-${machineName}" (pkgs.zpha.setupDisk.override attrs))
+              ]
+            )
           ))
         ]
-      ));
-  };
+      ))
+    );
 
 }
diff --git a/flake.nix b/flake.nix
@@ -1 +1,30 @@
-{ outputs = _: import ./.; }
+{
+  outputs =
+    _:
+    let
+      systems = [
+        "x86_64-linux"
+        "aarch64-linux"
+      ];
+      defaultNix = import ./.;
+      packagesForSystems = builtins.listToAttrs (
+        map (system: {
+          name = system;
+          value = defaultNix.packages { inherit system; };
+        }) systems
+      );
+      formatterForSystems = builtins.listToAttrs (
+        map (system: {
+          name = system;
+          value = defaultNix.formatter { inherit system; };
+        }) systems
+      );
+    in
+    builtins.mapAttrs (
+      name: value:
+      if name == "packages" then
+        packagesForSystems
+      else
+        (if name == "formatter" then formatterForSystems else value)
+    ) defaultNix;
+}