diff --git a/all-packages.nix b/all-packages.nix index e08304a..029bbd4 100644 --- a/all-packages.nix +++ b/all-packages.nix @@ -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 diff --git a/haproxy/mkconfig.nix b/haproxy/mkconfig.nix new file mode 100644 index 0000000..d40da34 --- /dev/null +++ b/haproxy/mkconfig.nix @@ -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"; +} diff --git a/haproxy/mkunit.nix b/haproxy/mkunit.nix new file mode 100644 index 0000000..9eae110 --- /dev/null +++ b/haproxy/mkunit.nix @@ -0,0 +1,17 @@ +{ HaproxyService +}: +{ name +, configDir +, configFile +, dependsOn ? {} +}: + +{ + inherit name configDir configFile; + pkg = HaproxyService { + inherit configDir configFile; + }; + + inherit dependsOn; + type = "systemd-unit"; +} diff --git a/nginx/mksiteconfig.nix b/nginx/mksiteconfig.nix index f95ad83..83018ea 100644 --- a/nginx/mksiteconfig.nix +++ b/nginx/mksiteconfig.nix @@ -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"; } diff --git a/nginx/mkunit.nix b/nginx/mkunit.nix new file mode 100644 index 0000000..2a06494 --- /dev/null +++ b/nginx/mkunit.nix @@ -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"; +} diff --git a/php-fpm/mkconfig.nix b/php-fpm/mkconfig.nix new file mode 100644 index 0000000..14ebecb --- /dev/null +++ b/php-fpm/mkconfig.nix @@ -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"; +} diff --git a/php-fpm/mksiteconfig.nix b/php-fpm/mksiteconfig.nix index cd8f1cd..0852dbd 100644 --- a/php-fpm/mksiteconfig.nix +++ b/php-fpm/mksiteconfig.nix @@ -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"; } diff --git a/php-fpm/mkunit.nix b/php-fpm/mkunit.nix new file mode 100644 index 0000000..b90c3b5 --- /dev/null +++ b/php-fpm/mkunit.nix @@ -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"; +} diff --git a/php/siteconfig.nix b/php/siteconfig.nix new file mode 100644 index 0000000..3ff0cfe --- /dev/null +++ b/php/siteconfig.nix @@ -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"; +} diff --git a/postgresdb/mkdefault.nix b/postgresdb/mkdefault.nix new file mode 100644 index 0000000..ffff2b8 --- /dev/null +++ b/postgresdb/mkdefault.nix @@ -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"; +} diff --git a/ttrss/mk-normalize-headers.nix b/ttrss/mk-normalize-headers.nix new file mode 100644 index 0000000..b9852e5 --- /dev/null +++ b/ttrss/mk-normalize-headers.nix @@ -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"; +} diff --git a/ttrss/mkconfig.nix b/ttrss/mkconfig.nix new file mode 100644 index 0000000..f224126 --- /dev/null +++ b/ttrss/mkconfig.nix @@ -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"; +} diff --git a/ttrss/mkdbupgrade.nix b/ttrss/mkdbupgrade.nix new file mode 100644 index 0000000..5fd2de0 --- /dev/null +++ b/ttrss/mkdbupgrade.nix @@ -0,0 +1,17 @@ +{ TtrssUpgradeDBService +}: +{ name +, user +, binDir +, dependsOn ? {} +}: + +{ + inherit name; + pkg = TtrssUpgradeDBService { + inherit user binDir; + }; + + inherit dependsOn; + type = "wrapper"; +} diff --git a/ttrss/mkupdate.nix b/ttrss/mkupdate.nix new file mode 100644 index 0000000..9ef78ca --- /dev/null +++ b/ttrss/mkupdate.nix @@ -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"; +} diff --git a/ttrss/update.nix b/ttrss/update.nix index 204d501..0107381 100644 --- a/ttrss/update.nix +++ b/ttrss/update.nix @@ -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 {