feat: try rework
This commit is contained in:
parent
1ddbd3b8b6
commit
ecf10628c3
51 changed files with 1941 additions and 445 deletions
34
validation/service/common.nix
Normal file
34
validation/service/common.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
let
|
||||
ensureAttrset = context: value:
|
||||
if builtins.isAttrs value then
|
||||
value
|
||||
else
|
||||
throw "${context} must be an attrset.";
|
||||
|
||||
ensureString = context: value:
|
||||
if builtins.isString value then
|
||||
value
|
||||
else
|
||||
throw "${context} must be a string.";
|
||||
|
||||
ensureNonEmptyString = context: value:
|
||||
if builtins.isString value && value != "" then
|
||||
value
|
||||
else
|
||||
throw "${context} must be a non-empty string.";
|
||||
|
||||
ensureInt = context: value:
|
||||
if builtins.isInt value then
|
||||
value
|
||||
else
|
||||
throw "${context} must be an int.";
|
||||
|
||||
ensureList = context: value:
|
||||
if builtins.isList value then
|
||||
value
|
||||
else
|
||||
throw "${context} must be a list.";
|
||||
in
|
||||
rec {
|
||||
inherit ensureAttrset ensureString ensureNonEmptyString ensureInt ensureList;
|
||||
}
|
||||
20
validation/service/continuwuity.nix
Normal file
20
validation/service/continuwuity.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
let
|
||||
common = import ./common.nix;
|
||||
in
|
||||
rec {
|
||||
getTrustedServers = serviceData:
|
||||
let
|
||||
matrix =
|
||||
if serviceData ? matrix then
|
||||
common.ensureAttrset "config/services.nix matrix" serviceData.matrix
|
||||
else
|
||||
throw "config/services.nix must define matrix attrset.";
|
||||
|
||||
trustedServers =
|
||||
if matrix ? trusted_servers then
|
||||
common.ensureList "config/services.nix matrix.trusted_servers" matrix.trusted_servers
|
||||
else
|
||||
throw "config/services.nix matrix.trusted_servers must exist.";
|
||||
in
|
||||
trustedServers;
|
||||
}
|
||||
36
validation/service/kiwix.nix
Normal file
36
validation/service/kiwix.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
let
|
||||
common = import ./common.nix;
|
||||
in
|
||||
rec {
|
||||
getKiwix = serviceData:
|
||||
let
|
||||
kiwix =
|
||||
if serviceData ? kiwix then
|
||||
common.ensureAttrset "config/services.nix kiwix" serviceData.kiwix
|
||||
else
|
||||
throw "config/services.nix must define kiwix attrset.";
|
||||
|
||||
rootDir =
|
||||
if kiwix ? root_dir then
|
||||
common.ensureNonEmptyString "config/services.nix kiwix.root_dir" kiwix.root_dir
|
||||
else
|
||||
throw "config/services.nix kiwix.root_dir must exist.";
|
||||
|
||||
webPort =
|
||||
if kiwix ? port then
|
||||
common.ensureInt "config/services.nix kiwix.port" kiwix.port
|
||||
else
|
||||
throw "config/services.nix kiwix.port must exist.";
|
||||
|
||||
zimUrls =
|
||||
if kiwix ? urls then
|
||||
common.ensureList "config/services.nix kiwix.urls" kiwix.urls
|
||||
else
|
||||
throw "config/services.nix kiwix.urls must exist.";
|
||||
in
|
||||
{
|
||||
root_dir = rootDir;
|
||||
port = webPort;
|
||||
urls = zimUrls;
|
||||
};
|
||||
}
|
||||
51
validation/service/qbittorrent.nix
Normal file
51
validation/service/qbittorrent.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
let
|
||||
common = import ./common.nix;
|
||||
in
|
||||
rec {
|
||||
getQbittorrent = serviceData:
|
||||
let
|
||||
qbt =
|
||||
if serviceData ? qbittorrent then
|
||||
common.ensureAttrset "config/services.nix qbittorrent" serviceData.qbittorrent
|
||||
else
|
||||
throw "config/services.nix must define qbittorrent attrset.";
|
||||
|
||||
webPort =
|
||||
if qbt ? port then
|
||||
common.ensureInt "config/services.nix qbittorrent.port" qbt.port
|
||||
else
|
||||
throw "config/services.nix qbittorrent.port must exist.";
|
||||
|
||||
rootDir =
|
||||
if qbt ? root_dir then
|
||||
common.ensureNonEmptyString "config/services.nix qbittorrent.root_dir" qbt.root_dir
|
||||
else
|
||||
throw "config/services.nix qbittorrent.root_dir must exist.";
|
||||
|
||||
vpn =
|
||||
if qbt ? vpn then
|
||||
common.ensureAttrset "config/services.nix qbittorrent.vpn" qbt.vpn
|
||||
else
|
||||
throw "config/services.nix qbittorrent.vpn must exist.";
|
||||
|
||||
usernameFile =
|
||||
if vpn ? username_file then
|
||||
common.ensureNonEmptyString "config/services.nix qbittorrent.vpn.username_file" vpn.username_file
|
||||
else
|
||||
throw "config/services.nix qbittorrent.vpn.username_file must exist.";
|
||||
|
||||
passwordFile =
|
||||
if vpn ? password_file then
|
||||
common.ensureNonEmptyString "config/services.nix qbittorrent.vpn.password_file" vpn.password_file
|
||||
else
|
||||
throw "config/services.nix qbittorrent.vpn.password_file must exist.";
|
||||
in
|
||||
{
|
||||
port = webPort;
|
||||
root_dir = rootDir;
|
||||
vpn = {
|
||||
username_file = usernameFile;
|
||||
password_file = passwordFile;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue