Commit 421cf6f

HPCesia <me@hpcesia.com>
2025-09-30 09:12:50
feat: generate nixos configuration
1 parent a6baacd
Changed files (3)
modules
flake
gen-configuration
hosts
chaser-kevin
chaser-pardofelis
modules/flake/gen-configuration/nixos.nix
@@ -0,0 +1,42 @@
+{
+  inputs,
+  lib,
+  config,
+  withSystem,
+  ...
+}: let
+  prefix = config.flake.meta.host.prefix;
+  collectHostsModules = modules:
+    lib.filterAttrs
+    (name: _: lib.hasPrefix prefix name)
+    modules;
+in {
+  flake.nixosConfigurations =
+    lib.pipe
+    (collectHostsModules config.flake.modules.nixos)
+    [
+      (lib.mapAttrs' (
+        name: value: {
+          name = lib.removePrefix prefix name;
+          inherit value;
+        }
+      ))
+      (lib.mapAttrs' (
+        name: module: {
+          inherit name;
+          value = withSystem config.flake.meta.host.hosts.${name}.system (
+            {pkgs, ...}:
+              inputs.nixpkgs.lib.nixosSystem {
+                modules = [
+                  module
+                  {
+                    networking.hostName = name;
+                    nixpkgs.pkgs = pkgs;
+                  }
+                ];
+              }
+          );
+        }
+      ))
+    ];
+}
modules/hosts/chaser-kevin/default.nix
@@ -0,0 +1,6 @@
+{
+  flake.meta.host.hosts.kevin = {
+    system = "x86_64-linux";
+  };
+  flake.modules.nixos."hosts/kevin" = {};
+}
modules/hosts/chaser-pardofelis/default.nix
@@ -0,0 +1,6 @@
+{
+  flake.meta.host.hosts.pardofelis = {
+    system = "x86_64-linux";
+  };
+  flake.modules.nixos."hosts/pardofelis" = {};
+}