refactor: stop using inputs.self

This commit is contained in:
arcnmx 2024-05-21 14:28:34 -07:00
parent 213430704f
commit 8601560f7d
27 changed files with 111 additions and 130 deletions

View file

@ -1,13 +1,13 @@
{
inputs,
config,
gensokyo-zone,
lib,
...
}: let
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkDefault mkForce;
inherit (lib.attrsets) attrNames attrValues filterAttrs mapAttrs' nameValuePair;
inherit (inputs.self.lib.lib) unmerged;
inherit (gensokyo-zone.lib) unmerged;
cfg = config.services.github-runners;
nixosConfig = config;
enabledRunners = filterAttrs (_: runner: runner.enable) cfg;

View file

@ -1,12 +1,12 @@
{
inputs,
lib,
config,
gensokyo-zone,
lib,
...
}: let
inherit (inputs.self.lib.lib) mkBaseDn;
inherit (lib) mkIf mkMerge mkBefore mkDefault mkOptionDefault mkEnableOption mkOption;
inherit (lib.strings) splitString concatMapStringsSep;
inherit (gensokyo-zone.lib) mkBaseDn;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkDefault mkOptionDefault;
inherit (config.lib.access) mkSnakeOil;
cfg = config.services.kanidm;
in {

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault mapListToAttrs;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault mapListToAttrs;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkOptionDefault;
inherit (lib.attrsets) mapAttrsToList;

View file

@ -1,11 +1,11 @@
{
config,
gensokyo-zone,
lib,
inputs,
pkgs,
...
}: let
inherit (inputs.self.lib.lib) mapOptionDefaults;
inherit (gensokyo-zone.lib) mapOptionDefaults;
inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkOptionDefault;
inherit (lib.attrsets) attrValues;

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) unmerged mkAlmostOptionDefault;
inherit (gensokyo-zone.lib) unmerged mkAlmostOptionDefault;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkOptionDefault;
inherit (lib.attrsets) filterAttrs mapAttrsToList nameValuePair;

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault mapOptionDefaults mapListToAttrs;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault mapOptionDefaults mapListToAttrs;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkOptionDefault;
inherit (lib.attrsets) attrNames mapAttrs mapAttrsToList;

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault mapListToAttrs;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault mapListToAttrs;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkOptionDefault;
inherit (lib.attrsets) mapAttrs mapAttrsToList;

View file

@ -1,7 +1,7 @@
{
inputs,
config,
pkgs,
gensokyo-zone,
lib,
utils,
...
@ -12,7 +12,7 @@
inherit (lib.lists) singleton optional filter concatMap;
inherit (lib.strings) concatStringsSep escapeShellArg;
inherit (utils) escapeSystemdExecArg;
inherit (inputs.self.lib.lib) unmerged;
inherit (gensokyo-zone.lib) unmerged;
inherit (config) networking;
inherit (networking) access;
enabledNamespaces = filter (ns: ns.enable) (attrValues networking.namespaces);

View file

@ -1,21 +1,19 @@
{
config,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault mkAddress6;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkOptionDefault mkForce;
inherit (lib.attrsets) attrValues mapAttrs;
inherit (lib.lists) optional filter concatMap;
inherit (config.services) nginx;
let
listenModule = {
nixosConfig,
config,
virtualHost,
listenKind,
gensokyo-zone,
lib,
...
}: {
}: let
inherit (gensokyo-zone.lib) mkAlmostOptionDefault mkAddress6;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkOptionDefault mkForce;
inherit (lib.lists) optional;
inherit (nixosConfig.services) nginx;
in {
options = with lib.types; {
enable =
mkEnableOption "this port"
@ -108,19 +106,19 @@
listenDirectives = mkMerge (map (conf: mkOptionDefault "listen ${conf};") config.listenConfigs);
};
};
listenType = {
specialArgs,
modules ? [],
}:
lib.types.submoduleWith {
inherit specialArgs;
modules = [listenModule] ++ modules;
};
hostModule = {
nixosConfig,
config,
gensokyo-zone,
lib,
...
}: let
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkOptionDefault mkForce;
inherit (lib.attrsets) attrValues mapAttrs;
inherit (lib.lists) filter concatMap;
inherit (nixosConfig.services) nginx;
cfg = attrValues config.listen';
enabledCfg = filter (port: port.enable) cfg;
mkListen = listen: addr: let
@ -134,9 +132,10 @@
in {
options = with lib.types; {
listen' = mkOption {
type = attrsOf (listenType {
type = attrsOf (submoduleWith {
modules = [listenModule];
specialArgs = {
inherit nixosConfig;
inherit nixosConfig gensokyo-zone;
virtualHost = config;
listenKind = "virtualHost";
};
@ -164,15 +163,23 @@
streamServerModule = {
nixosConfig,
config,
gensokyo-zone,
lib,
...
}: let
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkOptionDefault mkForce;
inherit (lib.attrsets) attrValues;
inherit (lib.lists) filter;
inherit (nixosConfig.services) nginx;
enabledListen = filter (port: port.enable) (attrValues config.listen);
in {
options = with lib.types; {
listen = mkOption {
type = attrsOf (listenType {
type = attrsOf (submoduleWith {
modules = [listenModule];
specialArgs = {
inherit nixosConfig;
inherit nixosConfig gensokyo-zone;
virtualHost = config;
streamServer = config;
listenKind = "streamServer";
@ -208,7 +215,10 @@
));
};
};
in {
in
{lib, ...}: let
inherit (lib.options) mkOption;
in {
options.services.nginx = with lib.types; {
virtualHosts = mkOption {
type = attrsOf (submoduleWith {
@ -223,4 +233,4 @@ in {
});
};
};
}
}

View file

@ -1,16 +1,16 @@
{
config,
gensokyo-zone,
lib,
inputs,
pkgs,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkBefore mkAfter mkOptionDefault;
inherit (lib.attrsets) mapAttrs' mapAttrsToList listToAttrs nameValuePair;
inherit (lib.lists) concatLists;
inherit (lib.strings) toUpper hasPrefix concatMapStringsSep concatStringsSep;
inherit (lib.strings) toUpper hasPrefix concatMapStringsSep;
inherit (lib.trivial) flip;
inherit (config.services) samba-wsdd;
cfg = config.services.samba;

View file

@ -1,11 +1,11 @@
{
config,
gensokyo-zone,
lib,
inputs,
pkgs,
...
}: let
inherit (inputs.self.lib.lib) mkWinPath userIs;
inherit (gensokyo-zone.lib) mkWinPath userIs;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
inherit (lib.attrsets) filterAttrs mapAttrsToList listToAttrs nameValuePair;

View file

@ -1,11 +1,11 @@
{
config,
pkgs,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) userIs;
inherit (gensokyo-zone.lib) userIs;
inherit (config.lib.steam) mkSharePath;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;

View file

@ -1,11 +1,11 @@
{
config,
gensokyo-zone,
lib,
inputs,
pkgs,
...
}: let
inherit (inputs.self.lib.lib) unmerged;
inherit (gensokyo-zone.lib) unmerged;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
inherit (lib.strings) match concatStringsSep escapeShellArg optionalString;

View file

@ -1,14 +1,14 @@
{
name,
config,
lib,
access,
inputs,
gensokyo-zone,
lib,
...
}: let
inherit (inputs.self) nixosConfigurations;
inherit (inputs.self.lib) systems;
inherit (inputs.self.lib.lib) domain mkAddress6;
inherit (gensokyo-zone) systems;
inherit (gensokyo-zone.self) nixosConfigurations;
inherit (gensokyo-zone.lib) domain mkAddress6;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
inherit (lib.attrsets) mapAttrs attrValues;

View file

@ -1,13 +1,9 @@
{
name,
config,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) domain;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkOptionDefault;
in {
options.ci = with lib.types; {
enable =
@ -20,26 +16,4 @@ in {
default = false;
};
};
config = {
deploy = let
nixos = config.built;
in {
sshUser = mkOptionDefault "root";
user = mkOptionDefault "root";
sshOpts = mkIf (config.type == "NixOS") (
mkOptionDefault ["-p" "${builtins.toString (builtins.head nixos.config.services.openssh.ports)}"]
);
autoRollback = mkOptionDefault true;
magicRollback = mkOptionDefault true;
fastConnection = mkOptionDefault false;
hostname = mkOptionDefault "${name}.local.${domain}";
profiles.system = {
user = "root";
path = let
inherit (inputs.self.legacyPackages.${config.system}.deploy-rs) activate;
in
activate.nixos nixos;
};
};
};
}

View file

@ -1,15 +1,15 @@
{
name,
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) domain;
inherit (gensokyo-zone.lib) domain;
inherit (lib.modules) mkIf mkOptionDefault;
in {
options = let
inherit (inputs.self.lib.lib) json;
inherit (gensokyo-zone.lib) json;
inherit (lib.types) nullOr;
inherit (lib.options) mkOption;
in {
@ -33,7 +33,7 @@ in {
profiles.system = {
user = "root";
path = let
inherit (inputs.self.legacyPackages.${config.system}.deploy-rs) activate;
inherit (gensokyo-zone.self.legacyPackages.${config.system}.deploy-rs) activate;
in
activate.nixos nixos;
};

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) eui64;
inherit (gensokyo-zone.lib) eui64;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkOptionDefault;
inherit (lib.trivial) mapNullable;

View file

@ -1,23 +1,21 @@
{
config,
gensokyo-zone,
lib,
inputs,
pkgs,
...
}: let
inherit (lib.modules) mkDefault;
in {
}: {
services.nginx.virtualHosts.gensokyoZone = {
serverName = config.networking.domain;
locations = {
"/" = {
root = inputs.website.packages.${pkgs.system}.gensokyoZone;
root = gensokyo-zone.inputs.website.packages.${pkgs.system}.gensokyoZone;
};
"/docs" = {
root = pkgs.linkFarm "genso-docs-wwwroot" [
{
name = "docs";
path = inputs.self.packages.${pkgs.system}.docs;
path = gensokyo-zone.self.packages.${pkgs.system}.docs;
}
];
};

View file

@ -1,12 +1,12 @@
{
inputs,
name,
config,
gensokyo-zone,
lib,
...
}: let
inherit (lib.modules) mkIf mkOrder mkDefault mkOverride;
inherit (inputs.self.lib.lib) domain;
inherit (gensokyo-zone.lib) domain;
in {
networking = {
nftables.enable = true;

View file

@ -2,7 +2,6 @@
config,
options,
lib,
inputs,
gensokyo-zone,
...
}: let

View file

@ -1,9 +1,9 @@
{inputs, ...}: let
inherit (inputs.self) overlays;
{gensokyo-zone, ...}: let
inherit (gensokyo-zone.self) overlays;
in {
nixpkgs = {
overlays = [
inputs.arcexprs.overlays.default
gensokyo-zone.inputs.arcexprs.overlays.default
overlays.default
];
config = {

View file

@ -1,14 +1,14 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.attrsets) listToAttrs nameValuePair;
inherit (lib.lists) genList;
inherit (inputs.self.lib.lib) unmerged;
inherit (gensokyo-zone.lib) unmerged;
cfg = config.services.github-runner-zone;
genZone = f: genList f cfg.count;
genZoneAttrs = prefix: f: listToAttrs (genZone (i: nameValuePair "${prefix}${toString i}" (f i)));

View file

@ -1,8 +1,8 @@
{
inputs,
system,
access,
config,
gensokyo-zone,
lib,
...
}: let
@ -15,7 +15,7 @@
};
hostname = "sso.${config.networking.domain}";
hostname-strict = false;
inherit (inputs.self.legacyPackages.${system.system}) patchedNixpkgs;
inherit (gensokyo-zone.self.legacyPackages.${system.system}) patchedNixpkgs;
keycloakModulePath = "services/web-apps/keycloak.nix";
in {
# upstream keycloak makes an incorrect assumption in its assertions, so we patch it

View file

@ -1,12 +1,12 @@
{
inputs,
pkgs,
config,
access,
gensokyo-zone,
lib,
...
}: let
inherit (inputs.self.lib.lib) mkAlmostOptionDefault mapAlmostOptionDefaults;
inherit (gensokyo-zone.lib) mkAlmostOptionDefault mapAlmostOptionDefaults;
inherit (lib.modules) mkIf mkMerge mkBefore mkDefault mkOptionDefault;
inherit (lib.strings) replaceStrings;
inherit (config.security) ipa;

View file

@ -1,10 +1,10 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (inputs.self.lib.lib) userIs mkAlmostOptionDefault;
inherit (gensokyo-zone.lib) userIs mkAlmostOptionDefault;
inherit (lib.modules) mkMerge mkDefault;
inherit (lib.attrsets) mapAttrs filterAttrs;
ldapUsers = filterAttrs (_: userIs "peeps") config.users.users;

View file

@ -1,12 +1,12 @@
{
inputs,
config,
access,
system,
access,
gensokyo-zone,
lib,
...
}: let
inherit (inputs.self.lib.lib) mkBaseDn;
inherit (gensokyo-zone.lib) mkBaseDn;
inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.strings) toUpper removeSuffix;
cfg = config.services.samba;

View file

@ -1,11 +1,11 @@
{
config,
gensokyo-zone,
lib,
inputs,
...
}: let
inherit (lib.attrsets) filterAttrs mapAttrsToList;
inherit (inputs.self.lib.lib) userIs;
inherit (gensokyo-zone.lib) userIs;
in {
users.groups = {
peeps = {