feat: clean up the repo

This commit is contained in:
Kat Inskip 2023-04-29 12:00:58 -07:00
parent bc9c310c77
commit f6ec9f37eb
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
249 changed files with 804 additions and 13048 deletions

View file

@ -1,171 +1,94 @@
{ pkgs, inputs, lib, meta, config, ... }:
/*
This module:
* Makes hosts nixosModules.
* Manages module imports and specialArgs.
* Builds network.nodes.
*/
with lib;
{
pkgs,
inputs,
lib,
meta,
config,
...
}:
/*
This module:
* Makes hosts nixosModules.
* Manages module imports and specialArgs.
* Builds network.nodes.
*/
with lib; {
options.network = {
nixos = {
extraModules = mkOption {
type = types.listOf types.unspecified;
default = [ ];
default = [];
};
specialArgs = mkOption {
type = types.attrsOf types.unspecified;
default = { };
default = {};
};
modulesPath = mkOption {
type = types.path;
default = toString (pkgs.path + "/nixos/modules");
};
};
darwin = {
extraModules = mkOption {
type = types.listOf types.unspecified;
default = [ ];
};
specialArgs = mkOption {
type = types.attrsOf types.unspecified;
default = { };
};
modulesPath = mkOption {
type = types.path;
default = toString (inputs.darwin + "/modules");
};
};
esphome = {
extraModules = mkOption {
type = types.listOf types.unspecified;
default = [ ];
};
specialArgs = mkOption {
type = types.attrsOf types.unspecified;
default = { };
};
};
nodes.all = mkOption {
type = types.attrsOf types.unspecified;
default = config.network.nodes.nixos // config.network.nodes.darwin // config.network.nodes.esphome;
};
nodes.esphome = let
esphomeType = types.submoduleWith {
modules = config.network.esphome.extraModules;
inherit (config.network.esphome) specialArgs;
};
in mkOption {
type = types.attrsOf esphomeType;
default = { };
};
nodes.nixos =
let
nixosModule = { name, config, meta, modulesPath, lib, ... }: with lib; {
options = {
nixpkgs.crossOverlays = mkOption {
type = types.listOf types.unspecified;
default = [ ];
nodes = let
nixosModule = {
name,
config,
meta,
modulesPath,
lib,
...
}:
with lib; {
options = {
nixpkgs.crossOverlays = mkOption {
type = types.listOf types.unspecified;
default = [];
};
};
config = {
nixpkgs = {
system = mkDefault "x86_64-linux";
pkgs = let
pkgsReval = import pkgs.path {
inherit (config.nixpkgs) localSystem crossSystem crossOverlays;
inherit (pkgs) overlays config;
};
in
mkDefault (
if config.nixpkgs.config == pkgs.config && config.nixpkgs.system == pkgs.targetPlatform.system
then pkgs
else pkgsReval
);
};
};
};
config = {
nixpkgs = {
system = mkDefault "x86_64-linux";
pkgs =
let
pkgsReval = import pkgs.path {
inherit (config.nixpkgs) localSystem crossSystem crossOverlays;
inherit (pkgs) overlays config;
};
in
mkDefault (if config.nixpkgs.config == pkgs.config && config.nixpkgs.system == pkgs.targetPlatform.system then pkgs else pkgsReval);
};
};
};
nixosType =
let
baseModules = import (config.network.nixos.modulesPath + "/module-list.nix");
in
types.submoduleWith {
modules = baseModules
++ singleton nixosModule
++ config.network.nixos.extraModules;
nixosType = let
baseModules = import (config.network.nixos.modulesPath + "/module-list.nix");
in
types.submoduleWith {
modules =
baseModules
++ singleton nixosModule
++ config.network.nixos.extraModules;
specialArgs = {
inherit baseModules;
inherit (config.network.nixos) modulesPath;
} // config.network.nixos.specialArgs;
};
specialArgs =
{
inherit baseModules;
inherit (config.network.nixos) modulesPath;
}
// config.network.nixos.specialArgs;
};
in
mkOption {
type = types.attrsOf nixosType;
default = { };
};
nodes.darwin =
let
darwinModule = { name, config, meta, modulesPath, lib, ... }: with lib; {
config = {
_module.args.pkgs = pkgs;
nixpkgs = {
system = mkDefault pkgs.system;
};
};
};
darwinType =
let
baseModules = import (config.network.darwin.modulesPath + "/module-list.nix");
flakeModule = (config.network.darwin.modulesPath + "/system/flake-overrides.nix");
in
types.submoduleWith {
modules = baseModules
++ singleton darwinModule
++ singleton flakeModule
++ config.network.darwin.extraModules;
specialArgs = {
inherit baseModules;
inherit (config.network.darwin) modulesPath;
} // config.network.darwin.specialArgs;
};
in
mkOption {
type = types.attrsOf darwinType;
default = { };
default = {};
};
};
config.network = {
esphome = {
extraModules = [
meta.modules.esphome
];
specialArgs = {
target = config.deploy.targets.home;
inherit (config.network) nodes;
inherit inputs meta;
};
};
darwin = {
extraModules = [
inputs.home-manager.darwinModules.home-manager
meta.modules.system
meta.modules.type
meta.system
];
specialArgs = {
inherit (config.network) nodes;
inherit inputs meta;
};
};
nixos = {
extraModules = [
inputs.home-manager.nixosModules.home-manager
meta.modules.nixos
meta.modules.system
meta.modules.type
meta.system
inputs.home-manager.nixosModules.home-manager
meta.modules.nixos
meta.system
];
specialArgs = {
inherit (config.network) nodes;