This commit is contained in:
soraefir 2024-04-17 00:25:54 +02:00
parent 6441652b8c
commit b644c87517
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
6 changed files with 172 additions and 151 deletions

113
flake.nix
View File

@ -30,62 +30,67 @@
}; };
outputs = inputs: outputs = inputs:
let
let gen = import ./generator.nix { inherit inputs; }; 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);
in { in {
devShells = import ./shells { inherit inputs; }; devShells = import ./shells { inherit inputs; };
inherit gensys;
nixosConfigurations = { # nixosConfigurations = {
valinor = gen.generate { # valinor = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "";
host = "valinor"; # host = "valinor";
}; # };
iriy = gen.generate { # iriy = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "x86_64-linux";
host = "iriy"; # host = "iriy";
}; # };
efir = gen.generate { # efir = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "x86_64-linux";
host = "efir"; # host = "efir";
}; # };
avalon = gen.generate { # avalon = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "x86_64-linux";
host = "avalon"; # host = "avalon";
}; # };
ci = gen.generate { # ci = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "x86_64-linux";
host = "ci"; # host = "ci";
}; # };
sandbox = gen.generate { # sandbox = gen.generate {
type = "nixos"; # type = "nixos";
system = "x86_64-linux"; # system = "x86_64-linux";
host = "sandbox"; # host = "sandbox";
}; # };
}; # };
darwinConfigurations = { # darwinConfigurations = {
asgard = gen.generate { # asgard = gen.generate {
type = "macos"; # type = "macos";
system = "x86_64-darwin"; # system = "x86_64-darwin";
host = "asgard"; # host = "asgard";
}; # };
}; # };
homeConfigurations = { # homeConfigurations = {
yomi = gen.generate { # yomi = gen.generate {
type = "home"; # type = "home";
system = "arm-64"; # system = "arm-64";
host = "example"; # host = "example";
}; # };
example = gen.generate { # example = gen.generate {
type = "home"; # type = "home";
system = "-"; # supports any # system = "-"; # supports any
host = "example"; # host = "example";
}; # };
}; # };
}; };
# ===== Unsupported/NotImplemented ====== # ===== Unsupported/NotImplemented ======

View File

@ -1,17 +1,19 @@
{ inputs, ... }: { { inputs, ... }: {
generate = { type, system, host }: generate = { syspath }:
let let
syscfg = import ./systems/${syspath}/cfg.nix;
nameValuePair = name: value: { inherit name value; }; nameValuePair = name: value: { inherit name value; };
syscfg = import ./systems/${host}/cfg.nix;
in ({ in ({
"nixos" = inputs.nixpkgs.lib.nixosSystem { "nixos" = {
system = system; nisoxConfigurations."${syscfg.hostname}" =
inputs.nixpkgs.lib.nixosSystem {
system = syscfg.system;
modules = [ modules = [
./modules/shared/syscfg ./modules/shared/syscfg
./modules/shared/sops ./modules/shared/sops
./modules/nixos ./modules/nixos
syscfg syscfg
./systems/${host} syspath
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
{ {
@ -33,11 +35,13 @@
} }
]; ];
}; };
};
"macos" = inputs.darwin.lib.darwinSystem { "macos" = inputs.darwin.lib.darwinSystem {
system = system; system = syscfg.system;
modules = [ modules = [
inputs.sops-nix.nixosModules.sops inputs.sops-nix.nixosModules.sops
./systems/${host} syspath
inputs.home-manager.darwinModules.home-manager inputs.home-manager.darwinModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
@ -47,15 +51,15 @@
imports = [ imports = [
inputs.nix-colors.homeManagerModule inputs.nix-colors.homeManagerModule
inputs.hyprland.homeManagerModules inputs.hyprland.homeManagerModules
./systems/${host}/home.nix ./systems/${syspath}/home.nix
]; ];
}; };
} }
]; ];
}; };
"home" = inputs.home-manager.lib.homeManagerConfiguration { "home" = inputs.home-manager.lib.homeManagerConfiguration {
modules = [ ./modules/home ./systems/${host}/home.nix ]; modules = [ ./modules/home ./systems/${syscfg.hostname}/home.nix ];
}; };
_ = throw "Unsupported system"; _ = throw "Unsupported system";
}.${type}); }.${syscfg.type});
} }

View File

@ -1,5 +1,5 @@
{ config, lib, pkgs, ... }: { { config, lib, pkgs, ... }: {
config = lib.mkMerge[ config = lib.mkMerge [
(lib.mkIf (config.syscfg.make.gui) { (lib.mkIf (config.syscfg.make.gui) {
xdg.portal = { xdg.portal = {
enable = true; enable = true;
@ -63,5 +63,6 @@
XDG_TEMPLATES_DIR="$HOME/media/templates" XDG_TEMPLATES_DIR="$HOME/media/templates"
XDG_VIDEOS_DIR="$HOME/media/video" XDG_VIDEOS_DIR="$HOME/media/video"
''; '';
})]; })
];
} }

View File

@ -1,4 +1,4 @@
{ ... }: { ... }:
{ {
virtualisation.arion.projects. # virtualisation.arion.projects.
} }

View File

@ -98,6 +98,14 @@ in with lib; {
options.usercfg = userOpt; options.usercfg = userOpt;
options.syscfg = { options.syscfg = {
hostname = mkOption { type = types.str; }; hostname = mkOption { type = types.str; };
type = mkOption {
type = types.enum [ "nixos" "macos" "home" ];
default = "nixos";
};
system = mkOption {
type = types.enum [ "x86_64-linux" "x86_64-darwin" "-" ];
default = "x86_64-linux";
};
defaultUser = mkOption { type = types.str; }; defaultUser = mkOption { type = types.str; };
make = makeOpt; make = makeOpt;
net = netOpt; net = netOpt;

3
systems/asguard/cfg.nix Normal file
View File

@ -0,0 +1,3 @@
{
}