use a mk* style in services
This commit is contained in:
parent
e551313ccf
commit
45ad9cb9d9
15 changed files with 269 additions and 5 deletions
|
@ -10,9 +10,12 @@ let
|
|||
|
||||
self = rec {
|
||||
PostgresDB = callPackage ./postgresdb {};
|
||||
mkPostgresDB = callPackage ./postgresdb/mkdefault.nix {inherit PostgresDB;};
|
||||
|
||||
HaproxyConfig = callPackage ./haproxy/config.nix {inherit utils;};
|
||||
mkHaproxyConfig = callPackage ./haproxy/mkconfig.nix {inherit HaproxyConfig;};
|
||||
HaproxyService = callPackage ./haproxy/unit.nix {inherit utils;};
|
||||
mkHaproxyService = callPackage ./haproxy/mkunit.nix {inherit HaproxyService;};
|
||||
mkHaproxySiteConfig = callPackage ./haproxy/siteconfig.nix {};
|
||||
|
||||
CaddyConfig = callPackage ./caddy/config.nix {inherit utils;};
|
||||
|
@ -21,21 +24,29 @@ let
|
|||
mkCaddySiteConfig = callPackage ./caddy/mksiteconfig.nix {inherit CaddySiteConfig;};
|
||||
|
||||
NginxService = callPackage ./nginx/unit.nix {inherit utils;};
|
||||
mkNginxService = callPackage ./nginx/mkunit.nix {inherit NginxService;};
|
||||
NginxSiteConfig = callPackage ./nginx/siteconfig.nix {inherit utils;};
|
||||
mkNginxSiteConfig = callPackage ./nginx/mksiteconfig.nix {inherit NginxSiteConfig;};
|
||||
|
||||
PHPConfig = callPackage ./php/config.nix {inherit utils;};
|
||||
mkPHPSiteConfig = callPackage ./php/siteconfig.nix {inherit PHPConfig;};
|
||||
|
||||
PHPFPMConfig = callPackage ./php-fpm/config.nix {inherit utils;};
|
||||
mkPHPFPMConfig = callPackage ./php-fpm/mkconfig.nix {inherit PHPFPMConfig;};
|
||||
PHPFPMService = callPackage ./php-fpm/unit.nix {inherit utils;};
|
||||
mkPHPFPMService = callPackage ./php-fpm/mkunit.nix {inherit PHPFPMService;};
|
||||
PHPFPMSiteConfig = callPackage ./php-fpm/siteconfig.nix {inherit utils;};
|
||||
mkPHPFPMSiteConfig = callPackage ./php-fpm/mksiteconfig.nix {inherit PHPFPMSiteConfig;};
|
||||
|
||||
TtrssEnvironment = callPackage ./ttrss/environment.nix {};
|
||||
TtrssConfig = callPackage ./ttrss/config.nix {};
|
||||
mkTtrssConfig = callPackage ./ttrss/mkconfig.nix {inherit TtrssConfig;};
|
||||
TtrssUpdateService = callPackage ./ttrss/update.nix {inherit utils;};
|
||||
mkTtrssUpdateService = callPackage ./ttrss/mkupdate.nix {inherit TtrssUpdateService;};
|
||||
TtrssUpgradeDBService = callPackage ./ttrss/dbupgrade.nix {};
|
||||
mkTtrssUpgradeDBService = callPackage ./ttrss/mkdbupgrade.nix {inherit TtrssUpgradeDBService;};
|
||||
TtrssPHPNormalizeHeaders = callPackage ./ttrss/normalize-headers.nix {inherit utils;};
|
||||
mkTtrssPHPNormalizeHeaders = callPackage ./ttrss/mk-normalize-headers.nix {inherit TtrssPHPNormalizeHeaders;};
|
||||
};
|
||||
in
|
||||
self
|
||||
|
|
31
haproxy/mkconfig.nix
Normal file
31
haproxy/mkconfig.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ HaproxyConfig
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, user
|
||||
, group
|
||||
, statsEnable ? false
|
||||
, statsPort ? null
|
||||
, prometheusStatsUri ? null
|
||||
, certPath ? null
|
||||
, acls ? []
|
||||
, backends ? []
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
{
|
||||
inherit name configDir configFile;
|
||||
inherit user group;
|
||||
pkg = HaproxyConfig {
|
||||
inherit configDir configFile;
|
||||
inherit user group;
|
||||
inherit statsEnable statsPort;
|
||||
inherit prometheusStatsUri;
|
||||
inherit certPath;
|
||||
|
||||
inherit acls backends;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "fileset";
|
||||
}
|
17
haproxy/mkunit.nix
Normal file
17
haproxy/mkunit.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ HaproxyService
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name configDir configFile;
|
||||
pkg = HaproxyService {
|
||||
inherit configDir configFile;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "systemd-unit";
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
, siteName
|
||||
, siteRoot
|
||||
, phpFpmSiteSocket ? ""
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
rec {
|
||||
inherit name siteConfigDir;
|
||||
|
@ -21,5 +22,7 @@ rec {
|
|||
siteSocket = nginxSocket;
|
||||
serviceRoot = siteRoot;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "fileset";
|
||||
}
|
||||
|
|
24
nginx/mkunit.nix
Normal file
24
nginx/mkunit.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ NginxService
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, user
|
||||
, group
|
||||
, runtimeDirectory
|
||||
, serviceSuffix
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
{
|
||||
inherit name configDir configFile;
|
||||
inherit user group;
|
||||
inherit runtimeDirectory;
|
||||
pkg = NginxService {
|
||||
inherit serviceSuffix;
|
||||
inherit user group;
|
||||
inherit configDir configFile;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "systemd-unit";
|
||||
}
|
20
php-fpm/mkconfig.nix
Normal file
20
php-fpm/mkconfig.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ PHPFPMConfig
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, siteConfigDir
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name configDir configFile;
|
||||
inherit siteConfigDir;
|
||||
|
||||
pkg = PHPFPMConfig {
|
||||
inherit configDir configFile siteConfigDir;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "fileset";
|
||||
}
|
|
@ -10,12 +10,11 @@
|
|||
, siteSocket
|
||||
, socketUser
|
||||
, socketGroup
|
||||
, dependsOn
|
||||
, connectsTo
|
||||
, dependsOn ? {}
|
||||
, connectsTo ? {}
|
||||
}:
|
||||
rec {
|
||||
inherit name user group siteSocket;
|
||||
inherit dependsOn connectsTo;
|
||||
|
||||
pkg = PHPFPMSiteConfig {
|
||||
inherit (PHPFPMConfig) siteConfigDir;
|
||||
|
@ -26,5 +25,7 @@ rec {
|
|||
serviceRoot = siteRoot;
|
||||
allowedClients = "127.0.0.1";
|
||||
};
|
||||
|
||||
inherit dependsOn connectsTo;
|
||||
type = "fileset";
|
||||
}
|
||||
|
|
26
php-fpm/mkunit.nix
Normal file
26
php-fpm/mkunit.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ PHPFPMService
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, phpIniConfigDir
|
||||
, phpIniConfigFile
|
||||
, runtimeDirectory
|
||||
, serviceSuffix
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name configDir configFile;
|
||||
inherit phpIniConfigDir phpIniConfigFile;
|
||||
inherit runtimeDirectory;
|
||||
|
||||
pkg = PHPFPMService {
|
||||
inherit serviceSuffix;
|
||||
configFile = "${configDir}/${configFile}";
|
||||
phpIni = "${phpIniConfigDir}/${phpIniConfigFile}";
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "systemd-unit";
|
||||
}
|
18
php/siteconfig.nix
Normal file
18
php/siteconfig.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ PHPConfig
|
||||
}:
|
||||
{ name
|
||||
, configDir
|
||||
, configFile
|
||||
, pkgExtraArguments ? {}
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
rec {
|
||||
inherit name configDir configFile;
|
||||
inherit dependsOn;
|
||||
|
||||
pkg = PHPConfig ({
|
||||
inherit configDir configFile;
|
||||
} // pkgExtraArguments);
|
||||
|
||||
type = "fileset";
|
||||
}
|
20
postgresdb/mkdefault.nix
Normal file
20
postgresdb/mkdefault.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ PostgresDB
|
||||
}:
|
||||
{ name
|
||||
, username
|
||||
, password
|
||||
, database
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name;
|
||||
pkg = PostgresDB {
|
||||
postgresUsername = username;
|
||||
postgresPassword = password;
|
||||
postgresDatabase = database;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "postgresql-database";
|
||||
}
|
14
ttrss/mk-normalize-headers.nix
Normal file
14
ttrss/mk-normalize-headers.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ TtrssPHPNormalizeHeaders
|
||||
}:
|
||||
{ name
|
||||
, configDir ? "/etc/php"
|
||||
, configFile ? "normalize-headers.php"
|
||||
}:
|
||||
rec {
|
||||
inherit name configDir configFile;
|
||||
|
||||
pkg = TtrssPHPNormalizeHeaders {
|
||||
inherit configDir configFile;
|
||||
};
|
||||
type = "fileset";
|
||||
}
|
37
ttrss/mkconfig.nix
Normal file
37
ttrss/mkconfig.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ TtrssConfig
|
||||
}:
|
||||
{ name
|
||||
, user
|
||||
, group
|
||||
, serviceName
|
||||
, document_root
|
||||
, lock_directory
|
||||
, cache_directory
|
||||
, feed_icons_directory
|
||||
, enabled_plugins ? []
|
||||
, auth_remote_post_logout_url ? null
|
||||
|
||||
, db_host
|
||||
, db_port
|
||||
, db_username
|
||||
, db_password
|
||||
, db_database
|
||||
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name;
|
||||
pkg = TtrssConfig {
|
||||
name = serviceName;
|
||||
inherit document_root lock_directory cache_directory feed_icons_directory;
|
||||
inherit user group;
|
||||
|
||||
inherit db_host db_port db_username db_password db_database;
|
||||
inherit enabled_plugins;
|
||||
inherit auth_remote_post_logout_url;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "fileset";
|
||||
}
|
17
ttrss/mkdbupgrade.nix
Normal file
17
ttrss/mkdbupgrade.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ TtrssUpgradeDBService
|
||||
}:
|
||||
{ name
|
||||
, user
|
||||
, binDir
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name;
|
||||
pkg = TtrssUpgradeDBService {
|
||||
inherit user binDir;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "wrapper";
|
||||
}
|
25
ttrss/mkupdate.nix
Normal file
25
ttrss/mkupdate.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ TtrssUpdateService
|
||||
}:
|
||||
{ name
|
||||
, user
|
||||
, group
|
||||
, documentRoot
|
||||
, readOnlyPaths
|
||||
, readWritePaths
|
||||
, postgresServiceName
|
||||
, dependsOn ? {}
|
||||
}:
|
||||
|
||||
{
|
||||
inherit name;
|
||||
pkg = TtrssUpdateService {
|
||||
inherit documentRoot;
|
||||
inherit user group;
|
||||
|
||||
inherit readOnlyPaths readWritePaths;
|
||||
inherit postgresServiceName;
|
||||
};
|
||||
|
||||
inherit dependsOn;
|
||||
type = "systemd-unit";
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
, lib
|
||||
, utils
|
||||
}:
|
||||
{ document_root
|
||||
{ documentRoot
|
||||
, user
|
||||
, group
|
||||
, readOnlyPaths ? []
|
||||
|
@ -22,7 +22,7 @@
|
|||
# - LOCK_DIRECTORY should be writable.
|
||||
|
||||
let
|
||||
fullPath = "${document_root}";
|
||||
fullPath = "${documentRoot}";
|
||||
roPaths = [fullPath] ++ readOnlyPaths;
|
||||
in
|
||||
utils.systemd.mkService rec {
|
||||
|
|
Loading…
Reference in a new issue