refactor(nixos): simplify registry option definitions #129

Merged
alexion merged 2 commits from refactor/inline-shell-shortcut-type into main 2026-10-05 00:20:30 -04:00
4 changed files with 31 additions and 32 deletions

View File

@@ -5,40 +5,40 @@
tab = lib.mkOption { tab = lib.mkOption {
type = lib.types.str; type = lib.types.str;
example = "Apps"; example = "Apps";
description = "Homepage tab that contains this entry."; description = "Groups the entry in a Homepage tab.";
}; };
section = lib.mkOption { section = lib.mkOption {
type = lib.types.str; type = lib.types.str;
example = "Media"; example = "Media";
description = "Homepage section that contains this entry."; description = "Groups the entry in a Homepage section.";
}; };
name = lib.mkOption { name = lib.mkOption {
type = lib.types.str; type = lib.types.str;
example = "Navidrome"; example = "Navidrome";
description = "Homepage display name for this entry."; description = "Sets the display name in Homepage.";
}; };
description = lib.mkOption { description = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
example = "Music"; example = "Music";
description = "Homepage description for this entry."; description = "Sets the description in Homepage.";
}; };
icon = lib.mkOption { icon = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
example = "navidrome.png"; example = "navidrome.png";
description = "Homepage icon for this entry."; description = "Sets the icon in Homepage.";
}; };
href = lib.mkOption { href = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
example = "https://music.alexion.dev"; example = "https://music.alexion.dev";
description = "Homepage link override for this entry."; description = "Overrides the generated Homepage link.";
}; };
}; };
}; };

View File

@@ -36,7 +36,7 @@
domain = lib.mkOption { domain = lib.mkOption {
type = lib.types.str; type = lib.types.str;
example = "files.alexion.dev"; example = "files.alexion.dev";
description = "Public domain for this route."; description = "Records the public domain for this route.";
}; };
protocol = lib.mkOption { protocol = lib.mkOption {
@@ -45,14 +45,14 @@
"https" "https"
"udp" "udp"
]; ];
description = "Public protocol for this route."; description = "Selects the public protocol for this route.";
}; };
port = lib.mkOption { port = lib.mkOption {
type = lib.types.nullOr lib.types.port; type = lib.types.nullOr lib.types.port;
default = null; default = null;
example = 3923; example = 3923;
description = "HTTP backend port for an HTTP or HTTPS route."; description = "Sets the HTTP backend port for an HTTP or HTTPS route.";
}; };
ports = lib.mkOption { ports = lib.mkOption {
@@ -62,7 +62,7 @@
2456 2456
2457 2457
]; ];
description = "UDP ports for a UDP route."; description = "Sets the UDP ports for a UDP route.";
}; };
}; };
}; };

View File

@@ -1,21 +1,20 @@
{ lib, ... }: { lib, ... }:
let
entryType = lib.types.submodule {
options = {
command = lib.mkOption {
type = lib.types.str;
example = "nvim";
description = "Command expanded by this shell shortcut.";
};
abbreviation = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether fish realizes this shell shortcut as an abbreviation instead of an alias.";
};
};
};
in
{ {
type = lib.types.coercedTo lib.types.str (command: { inherit command; }) entryType; type = lib.types.coercedTo lib.types.str (command: { inherit command; }) (
lib.types.submodule {
options = {
command = lib.mkOption {
type = lib.types.str;
example = "nvim";
description = "Sets the command expanded by this shortcut.";
};
abbreviation = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Uses a Fish abbreviation instead of an alias.";
};
};
}
);
} }

View File

@@ -5,14 +5,14 @@ let
assertion = lib.mkOption { assertion = lib.mkOption {
type = lib.types.functionTo lib.types.bool; type = lib.types.functionTo lib.types.bool;
description = '' description = ''
Tests this registry's flattened collected entries. Tests the registry's flattened entries.
''; '';
}; };
message = lib.mkOption { message = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = '' description = ''
Describes the registry validation failure. Describes the validation failure.
''; '';
}; };
}; };
@@ -23,7 +23,7 @@ in
type = lib.mkOption { type = lib.mkOption {
type = lib.types.raw; type = lib.types.raw;
description = '' description = ''
Defines the NixOS option type for one registry entry. Defines the NixOS option type for a registry entry.
''; '';
}; };
@@ -31,7 +31,7 @@ in
type = lib.types.listOf checkType; type = lib.types.listOf checkType;
default = [ ]; default = [ ];
description = '' description = ''
Contains validation checks for this registry's flattened collected entries. Lists validation checks for the registry's flattened entries.
''; '';
}; };
}; };