2021-11-15 10:02:05 +00:00
|
|
|
{ pkgs, ... }:
|
2022-07-13 11:18:43 +00:00
|
|
|
let
|
|
|
|
jsonData = builtins.fromJSON (builtins.readFile ./userdata/userdata.json);
|
|
|
|
in
|
2021-11-15 10:02:05 +00:00
|
|
|
{
|
2022-07-13 11:18:43 +00:00
|
|
|
services.userdata = {
|
2022-07-13 11:47:13 +00:00
|
|
|
hostname = (if jsonData ? "hostname" then jsonData.hostname else null);
|
|
|
|
domain = (if jsonData ? "domain" then jsonData.domain else null);
|
|
|
|
timezone = (if jsonData ? "timezone" then jsonData.timezone else "Europe/Uzhgorod");
|
2022-07-13 11:18:43 +00:00
|
|
|
autoUpgrade = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "autoUpgrade" && jsonData.autoUpgrade ? "enable")
|
|
|
|
then jsonData.autoUpgrade.enable
|
|
|
|
else true
|
|
|
|
);
|
|
|
|
allowReboot = (
|
|
|
|
if (jsonData ? "autoUpgrade" && jsonData.autoUpgrade ? "allowReboot")
|
|
|
|
then jsonData.autoUpgrade.allowReboot
|
|
|
|
else true
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
2022-07-13 11:47:13 +00:00
|
|
|
username = (if jsonData ? "username" then jsonData.username else null);
|
|
|
|
hashedMasterPassword = (if jsonData ? "hashedMasterPassword" then jsonData.hashedMasterPassword else null);
|
|
|
|
sshKeys = (if jsonData ? "sshKeys" then jsonData.sshKeys else [ ]);
|
2022-07-13 11:18:43 +00:00
|
|
|
api = {
|
|
|
|
token = jsonData.api.token;
|
2022-07-13 12:12:54 +00:00
|
|
|
enableSwagger = (
|
|
|
|
if (jsonData ? "api" && jsonData.api "enableSwagger")
|
|
|
|
then jsonData.api.enableSwagger
|
|
|
|
else false
|
|
|
|
);
|
|
|
|
skippedMigrations = (
|
|
|
|
if (jsonData ? "api" && jsonData.api ? "skippedMigrations")
|
|
|
|
then jsonData.api.skippedMigrations
|
|
|
|
else [ ]
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
backblaze = {
|
2022-07-13 12:12:54 +00:00
|
|
|
bucket = (
|
|
|
|
if (jsonData ? "backblaze" && jsonData.backblaze ? "bucket")
|
|
|
|
then jsonData.backblaze.bucket
|
|
|
|
else ""
|
|
|
|
);
|
|
|
|
accountId = (
|
|
|
|
if (jsonData ? "backblaze" && jsonData.backblaze ? "accountId")
|
|
|
|
then jsonData.backblaze.accountId
|
|
|
|
else ""
|
|
|
|
);
|
|
|
|
accountKey = (
|
|
|
|
if (jsonData ? "backblaze" && jsonData.backblaze ? "accountKey")
|
|
|
|
then jsonData.backblaze.accountKey
|
|
|
|
else ""
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
cloudflare = {
|
2022-07-13 12:12:54 +00:00
|
|
|
apiKey = (
|
|
|
|
if (jsonData ? "cloudflare" && jsonData.cloudflare ? "apiKey"))
|
|
|
|
then jsonData.cloudflare.apiKey
|
|
|
|
else null
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
2022-07-13 11:47:13 +00:00
|
|
|
databasePassword = (if jsonData ? "databasePassword" then jsonData.databasePassword else null);
|
2022-07-13 11:18:43 +00:00
|
|
|
bitwarden = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "bitwarden" && jsonData.bitwarden ? "enable")
|
|
|
|
then jsonData.bitwarden.enable
|
|
|
|
else false
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
gitea = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "gitea" && jsonData.gitea ? "enable")
|
|
|
|
then jsonData.gitea.enable
|
|
|
|
else false
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
nextcloud = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "nextcloud" && jsonData.nextcloud ? "enable")
|
|
|
|
then jsonData.nextcloud.enable
|
|
|
|
else false
|
|
|
|
);
|
|
|
|
adminPassword = (
|
|
|
|
if (jsonData ? "nextcloud" && jsonData.nextcloud ? "adminPassword")
|
|
|
|
then jsonData.nextcloud.adminPassword
|
|
|
|
else null
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
pleroma = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "pleroma" && jsonData.pleroma ? "enable")
|
|
|
|
then jsonData.pleroma.enable
|
|
|
|
else false
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
jitsi = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "jitsi" && jsonData.jitsi ? "enable")
|
|
|
|
then jsonData.jitsi.enable
|
|
|
|
else false
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
|
|
|
ocserv = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "ocserv" && jsonData.ocserv ? "enable")
|
|
|
|
then jsonData.ocserv.enable
|
|
|
|
else false
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
2022-07-13 11:48:02 +00:00
|
|
|
resticPassword = (if jsonData ? "resticPassword" then jsonData.resticPassword else null);
|
2022-07-13 11:18:43 +00:00
|
|
|
ssh = {
|
2022-07-13 12:12:54 +00:00
|
|
|
enable = (
|
|
|
|
if (jsonData ? "ssh" && jsonData.ssh ? "enable")
|
|
|
|
then jsonData.ssh.enable
|
|
|
|
else true
|
|
|
|
);
|
|
|
|
rootKeys = (
|
|
|
|
if (jsonData ? "ssh" && jsonData.ssh ? "rootKeys")
|
|
|
|
then jsonData.ssh.rootKeys
|
|
|
|
else [ "" ]
|
|
|
|
);
|
|
|
|
passwordAuthentication = (
|
|
|
|
if (jsonData ? "ssh" && jsonData.ssh ? "passwordAuthentication")
|
|
|
|
then jsonData.ssh.passwordAuthentication
|
|
|
|
else true
|
|
|
|
);
|
2022-07-13 11:18:43 +00:00
|
|
|
};
|
2022-07-13 11:41:47 +00:00
|
|
|
users = (if jsonData ? "users" then jsonData.users else [ ]);
|
2021-11-15 10:02:05 +00:00
|
|
|
};
|
|
|
|
}
|