mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(meta): remove meta
This commit is contained in:
parent
dc1c82317c
commit
dc6b335423
5 changed files with 0 additions and 307 deletions
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
config,
|
||||
access,
|
||||
...
|
||||
}: let
|
||||
nixosModule = {
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
config = {
|
||||
_module.args.access = access // {
|
||||
systemFor = hostName: if hostName == config.networking.hostName
|
||||
then config
|
||||
else access.systemFor hostName;
|
||||
systemForOrNull = hostName: if hostName == config.networking.hostName
|
||||
then config
|
||||
else access.systemForOrNull hostName;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
config = {
|
||||
network.nixos.extraModules = [
|
||||
nixosModule
|
||||
];
|
||||
|
||||
_module.args.access = {
|
||||
systemFor = hostName: config.network.nodes.${hostName};
|
||||
systemForOrNull = hostName: config.network.nodes.${hostName} or null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
meta,
|
||||
root,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options = {
|
||||
lib = mkOption {
|
||||
type = types.attrsOf (types.attrsOf types.unspecified);
|
||||
};
|
||||
network.importing = {
|
||||
nixosImports = mkOption {
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
network.importing = {
|
||||
nixosImports = mkDefault (map toString [
|
||||
(root + "/nixos/systems/HN.nix")
|
||||
(root + "/nixos/systems/HN/nixos.nix")
|
||||
]);
|
||||
};
|
||||
lib.nixfiles.nixosImport = hostName:
|
||||
lib.nodeImport {
|
||||
inherit (config.network.importing) nixosImports;
|
||||
profiles = meta.nixos;
|
||||
homeImports = [];
|
||||
users = [];
|
||||
inherit hostName;
|
||||
};
|
||||
_module.args = {inherit (config.lib) nixfiles;};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
lib,
|
||||
meta,
|
||||
config,
|
||||
...
|
||||
}@metaArgs: let
|
||||
/*
|
||||
This module:
|
||||
* Makes hosts nixosModules.
|
||||
* Manages module imports and specialArgs.
|
||||
* Builds network.nodes.
|
||||
*/
|
||||
enableNixosBuilder = false;
|
||||
in with lib; {
|
||||
options.network = {
|
||||
nixos = {
|
||||
extraModules = mkOption {
|
||||
type = types.listOf types.unspecified;
|
||||
default = [];
|
||||
};
|
||||
specialArgs = mkOption {
|
||||
type = types.attrsOf types.unspecified;
|
||||
default = {};
|
||||
};
|
||||
modulesPath = mkOption {
|
||||
type = types.path;
|
||||
default = toString (pkgs.path + "/nixos/modules");
|
||||
};
|
||||
builder = mkOption {
|
||||
type = types.unspecified;
|
||||
};
|
||||
};
|
||||
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
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
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;
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.lazyAttrsOf (
|
||||
if enableNixosBuilder then types.unspecified else nixosType
|
||||
);
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
config.network = {
|
||||
nixos = {
|
||||
extraModules = [
|
||||
meta.modules.nixos
|
||||
];
|
||||
specialArgs = {
|
||||
inherit (config.network) nodes;
|
||||
inherit inputs meta pkgs;
|
||||
};
|
||||
builder = mkOptionDefault ({
|
||||
pkgs ? metaArgs.pkgs,
|
||||
system ? pkgs.system,
|
||||
lib ? if args ? pkgs then pkgs.lib else metaArgs.lib,
|
||||
nixosSystem ? import (pkgs.path + "/nixos/lib/eval-config.nix"),
|
||||
baseModules ? import (modulesPath + "/module-list.nix"),
|
||||
modulesPath ? toString (pkgs.path + "/nixos/modules"),
|
||||
specialArgs ? config.network.nixos.specialArgs,
|
||||
extraModules ? config.network.nixos.extraModules,
|
||||
imports ? [ ],
|
||||
name,
|
||||
...
|
||||
}@args: let
|
||||
args' = builtins.removeAttrs args [
|
||||
"extraModules" "specialArgs" "modulesPath" "baseModules" "lib" "pkgs" "system" "imports" "name"
|
||||
];
|
||||
c = nixosSystem ({
|
||||
inherit lib baseModules extraModules pkgs system;
|
||||
modules = imports;
|
||||
specialArgs =
|
||||
{
|
||||
inherit baseModules name;
|
||||
inherit (config.network.nixos) modulesPath;
|
||||
}
|
||||
// config.network.nixos.specialArgs;
|
||||
} // args');
|
||||
in if enableNixosBuilder then c.config else {
|
||||
inherit imports;
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options = {
|
||||
networks = mkOption {
|
||||
type = with types;
|
||||
attrsOf (submodule ({
|
||||
name,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
options = {
|
||||
member_configs = mkOption {
|
||||
type = unspecified;
|
||||
};
|
||||
members = mkOption {
|
||||
type = unspecified;
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
config = {
|
||||
networks = let
|
||||
names = ["gensokyo" "chitei" "internet" "tailscale"];
|
||||
network_filter = network: rec {
|
||||
member_configs = filterAttrs (_: nodeConfig: nodeConfig.networks.${network}.interfaces != []) config.network.nodes;
|
||||
members = mapAttrs (_: nodeConfig: nodeConfig.networks.${network}) member_configs;
|
||||
};
|
||||
networks' = genAttrs names network_filter;
|
||||
in
|
||||
networks';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) attrsOf package;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep;
|
||||
cfg = config.outputs.packages;
|
||||
fmt = import ../../ci/fmt.nix;
|
||||
in {
|
||||
options.outputs.packages = mkOption {
|
||||
type = attrsOf package;
|
||||
default = { };
|
||||
};
|
||||
|
||||
config.outputs.packages = {
|
||||
inherit (pkgs.buildPackages)
|
||||
terraform tflint
|
||||
alejandra deadnix statix
|
||||
;
|
||||
nf-deploy = pkgs.writeShellScriptBin "nf-deploy" ''
|
||||
exec ${pkgs.runtimeShell} ${../../ci/deploy.sh} "$@"
|
||||
'';
|
||||
nf-statix = pkgs.writeShellScriptBin "nf-statix" ''
|
||||
if [[ $# -eq 0 ]]; then
|
||||
set -- check
|
||||
fi
|
||||
|
||||
if [[ ''${1-} = check ]]; then
|
||||
shift
|
||||
set -- check --config ${../../ci/statix.toml} "$@"
|
||||
fi
|
||||
|
||||
exec ${getExe cfg.statix} "$@"
|
||||
'';
|
||||
nf-deadnix = let
|
||||
inherit (fmt.nix) blacklistDirs;
|
||||
excludes = "${getExe pkgs.buildPackages.findutils} ${concatStringsSep " " blacklistDirs} -type f";
|
||||
in pkgs.writeShellScriptBin "nf-deadnix" ''
|
||||
exec ${getExe cfg.deadnix} "$@" \
|
||||
--no-lambda-arg \
|
||||
--exclude $(${excludes})
|
||||
'';
|
||||
nf-alejandra = let
|
||||
inherit (fmt.nix) blacklistDirs;
|
||||
excludes = concatMapStringsSep " " (dir: "--exclude ${dir}") blacklistDirs;
|
||||
in pkgs.writeShellScriptBin "nf-alejandra" ''
|
||||
exec ${getExe cfg.alejandra} \
|
||||
${excludes} \
|
||||
"$@"
|
||||
'';
|
||||
nf-lint-tf = pkgs.writeShellScriptBin "nf-lint-tf" ''
|
||||
${getExe cfg.terraform} fmt "$@" &&
|
||||
${cfg.tflint}/bin/tflint
|
||||
'';
|
||||
nf-lint-nix = pkgs.writeShellScriptBin "nf-lint-nix" ''
|
||||
${getExe cfg.nf-statix} check "$@" &&
|
||||
${getExe cfg.nf-deadnix} -f "$@"
|
||||
'';
|
||||
nf-fmt-nix = let
|
||||
inherit (fmt.nix) whitelist;
|
||||
includes = concatStringsSep " " whitelist;
|
||||
in pkgs.writeShellScriptBin "nf-fmt-nix" ''
|
||||
exec ${getExe cfg.nf-alejandra} ${includes} "$@"
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue