From 150d2f2e07ec82b21ee126a00418fc329a521cb1 Mon Sep 17 00:00:00 2001 From: soraefir Date: Wed, 17 Apr 2024 08:26:08 +0200 Subject: [PATCH] Cfg updated --- flake.nix | 74 +++++++---------------------------- generator.nix | 86 ++++++++++++++++++++--------------------- systems/asguard/cfg.nix | 7 +++- systems/avalon/cfg.nix | 3 +- systems/ci/cfg.nix | 2 + systems/iriy/cfg.nix | 2 + systems/sandbox/cfg.nix | 2 + systems/valinor/cfg.nix | 2 + 8 files changed, 74 insertions(+), 104 deletions(-) diff --git a/flake.nix b/flake.nix index 2b0e444..63b3116 100755 --- a/flake.nix +++ b/flake.nix @@ -30,67 +30,23 @@ }; outputs = inputs: - let - gen = import ./generator.nix { inherit inputs; }; - sys = builtins.attrNames - # (builtins.filterSource (path: type: type == "directory") - (builtins.readDir ./systems); # ); - gensys = builtins.listToAttrs - (builtins.map (x: gen.generate { syspath = x; }) sys); + let gen = import ./generator.nix { inherit inputs; }; in { devShells = import ./shells { inherit inputs; }; - inherit gensys; - # nixosConfigurations = { - # valinor = gen.generate { - # type = "nixos"; - # system = ""; - # host = "valinor"; - # }; - # iriy = gen.generate { - # type = "nixos"; - # system = "x86_64-linux"; - # host = "iriy"; - # }; - # efir = gen.generate { - # type = "nixos"; - # system = "x86_64-linux"; - # host = "efir"; - # }; - # avalon = gen.generate { - # type = "nixos"; - # system = "x86_64-linux"; - # host = "avalon"; - # }; - # ci = gen.generate { - # type = "nixos"; - # system = "x86_64-linux"; - # host = "ci"; - # }; - # sandbox = gen.generate { - # type = "nixos"; - # system = "x86_64-linux"; - # host = "sandbox"; - # }; - # }; - # darwinConfigurations = { - # asgard = gen.generate { - # type = "macos"; - # system = "x86_64-darwin"; - # host = "asgard"; - # }; - # }; - # homeConfigurations = { - # yomi = gen.generate { - # type = "home"; - # system = "arm-64"; - # host = "example"; - # }; - # example = gen.generate { - # type = "home"; - # system = "-"; # supports any - # host = "example"; - # }; - # }; + + nixosConfigurations = { + valinor = gen.generate { host = "valinor"; }; + iriy = gen.generate { host = "iriy"; }; + efir = gen.generate { host = "efir"; }; + avalon = gen.generate { host = "avalon"; }; + ci = gen.generate { host = "ci"; }; + sandbox = gen.generate { host = "sandbox"; }; + }; + darwinConfigurations = { asgard = gen.generate { host = "asgard"; }; }; + homeConfigurations = { + yomi = gen.generate { host = "example"; }; + example = gen.generate { host = "example"; }; + }; }; # ===== Unsupported/NotImplemented ====== diff --git a/generator.nix b/generator.nix index 4ad6c57..ad786c9 100755 --- a/generator.nix +++ b/generator.nix @@ -1,65 +1,65 @@ { inputs, ... }: { - generate = { syspath }: + generate = { host }: let - syscfg = import ./systems/${syspath}/cfg.nix; + syscfg = import ./systems/${host}/cfg.nix; nameValuePair = name: value: { inherit name value; }; in ({ - "nixos" = { - nisoxConfigurations."${syscfg.hostname}" = - inputs.nixpkgs.lib.nixosSystem { - system = syscfg.system; - modules = [ - ./modules/shared/syscfg - ./modules/shared/sops - ./modules/nixos - syscfg - syspath - inputs.sops-nix.nixosModules.sops - inputs.home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users = builtins.listToAttrs (map (userConfig: - nameValuePair userConfig.username { - imports = [ - ./modules/shared/syscfg - ./modules/shared/colors - ./modules/home - syscfg - { usercfg = userConfig; } - inputs.nix-colors.homeManagerModule - inputs.hyprland.homeManagerModules.default - ]; - }) syscfg.syscfg.users); - } - ]; - }; + "nixos" = inputs.nixpkgs.lib.nixosSystem { + system = syscfg.syscfg.system; + modules = [ + ./modules/shared/syscfg + ./modules/shared/sops + ./modules/nixos + syscfg + ./systems/${host} + inputs.sops-nix.nixosModules.sops + inputs.home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit inputs; }; + home-manager.users = builtins.listToAttrs (map (userConfig: + nameValuePair userConfig.username { + imports = [ + ./modules/shared/syscfg + ./modules/shared/colors + ./modules/home + syscfg + { usercfg = userConfig; } + inputs.nix-colors.homeManagerModule + inputs.hyprland.homeManagerModules.default + ]; + }) syscfg.syscfg.users); + } + ]; }; "macos" = inputs.darwin.lib.darwinSystem { system = syscfg.system; modules = [ + ./modules/shared/syscfg + ./modules/shared/sops + syscfg + ./systems/${host} inputs.sops-nix.nixosModules.sops - syspath inputs.home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users.sora = { - imports = [ - inputs.nix-colors.homeManagerModule - inputs.hyprland.homeManagerModules - ./systems/${syspath}/home.nix - ]; - }; + home-manager.users = builtins.listToAttrs (map (userConfig: + nameValuePair userConfig.username { + imports = [ + inputs.nix-colors.homeManagerModule + inputs.hyprland.homeManagerModules + ]; + }) syscfg.syscfg.users); } ]; }; "home" = inputs.home-manager.lib.homeManagerConfiguration { - modules = [ ./modules/home ./systems/${syscfg.hostname}/home.nix ]; + modules = [ ./modules/home ]; }; _ = throw "Unsupported system"; - }.${syscfg.type}); + }.${syscfg.syscfg.type}); } diff --git a/systems/asguard/cfg.nix b/systems/asguard/cfg.nix index 0db3279..332ea37 100644 --- a/systems/asguard/cfg.nix +++ b/systems/asguard/cfg.nix @@ -1,3 +1,8 @@ { - + syscfg = { + hostname = "asguard"; + defaultUser = "sora"; + type = "macos"; + system = "x86_64-darwin"; + }; } diff --git a/systems/avalon/cfg.nix b/systems/avalon/cfg.nix index 82de28f..257f836 100644 --- a/systems/avalon/cfg.nix +++ b/systems/avalon/cfg.nix @@ -1,6 +1,8 @@ { syscfg = { hostname = "avalon"; + system = "x86_64-linux"; + type = "nixos"; defaultUser = "sora"; users = [ { @@ -36,7 +38,6 @@ enable = true; ip4 = "10.10.1.2/32"; ip6 = "fd10:10:10::2/128"; - pk = config.sops.secrets.avalon_wg_priv.path; }; }; } diff --git a/systems/ci/cfg.nix b/systems/ci/cfg.nix index dd38507..4f43414 100644 --- a/systems/ci/cfg.nix +++ b/systems/ci/cfg.nix @@ -1,6 +1,8 @@ { syscfg = { hostname = "ci"; + type = "nixos"; + system = "x86_64-linux"; defaultUser = "ci"; users = [{ username = "ci"; diff --git a/systems/iriy/cfg.nix b/systems/iriy/cfg.nix index fd5bf58..ee5e4f8 100644 --- a/systems/iriy/cfg.nix +++ b/systems/iriy/cfg.nix @@ -1,6 +1,8 @@ { syscfg = { hostname = "iriy"; + type = "nixos"; + system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora"; diff --git a/systems/sandbox/cfg.nix b/systems/sandbox/cfg.nix index 73d6562..880bb31 100644 --- a/systems/sandbox/cfg.nix +++ b/systems/sandbox/cfg.nix @@ -1,6 +1,8 @@ { syscfg = { hostname = "sandbox"; + type = "nixos"; + system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora"; diff --git a/systems/valinor/cfg.nix b/systems/valinor/cfg.nix index 8b3e799..442e47f 100644 --- a/systems/valinor/cfg.nix +++ b/systems/valinor/cfg.nix @@ -1,6 +1,8 @@ { syscfg = { hostname = "valinor"; + type = "nixos"; + system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora";