From 2593b09878b31568cd8436765777fbef4ed0e915 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Mon, 12 Sep 2022 12:21:18 -0700 Subject: [PATCH] add functions to easily create siteconfigs --- PHP-FPM/mksiteconfig.nix | 24 ++++++++++++++++++++++++ all-packages.nix | 4 +++- caddy/mksiteconfig.nix | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 PHP-FPM/mksiteconfig.nix create mode 100644 caddy/mksiteconfig.nix diff --git a/PHP-FPM/mksiteconfig.nix b/PHP-FPM/mksiteconfig.nix new file mode 100644 index 0000000..5b5f8ae --- /dev/null +++ b/PHP-FPM/mksiteconfig.nix @@ -0,0 +1,24 @@ +{ PHPFPMSiteConfig +}: +{ PHPFPMConfig +, PHPFPMService +, name +, siteName +, siteRoot +, socketUser +, socketGroup +}: +rec { + inherit name; + siteSocket = "/run/php-fpm/${name}.sock"; + pkg = PHPFPMSiteConfig { + inherit (PHPFPMConfig) siteConfigDir; + inherit (PHPFPMService) user group; + inherit siteSocket socketUser socketGroup; + + service = siteName; + serviceRoot = siteRoot; + allowedClients = "127.0.0.1"; + }; + type = "fileset"; +} diff --git a/all-packages.nix b/all-packages.nix index 1986a17..d9ab8ad 100644 --- a/all-packages.nix +++ b/all-packages.nix @@ -8,16 +8,18 @@ let callPackage = pkgs.lib.callPackageWith (pkgs // self); - self = { + self = rec { PostgresDB = callPackage ./PostgresDB {}; CaddyConfig = callPackage ./caddy/config.nix {inherit utils;}; CaddyService = callPackage ./caddy/unit.nix {inherit utils;}; CaddySiteConfig = callPackage ./caddy/siteconfig.nix {inherit utils;}; + mkCaddySiteConfig = callPackage ./caddy/mksiteconfig.nix {inherit CaddySiteConfig;}; PHPFPMConfig = callPackage ./PHP-FPM/config.nix {inherit utils;}; PHPFPMService = callPackage ./PHP-FPM/unit.nix {inherit utils;}; 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 {}; diff --git a/caddy/mksiteconfig.nix b/caddy/mksiteconfig.nix new file mode 100644 index 0000000..00cf146 --- /dev/null +++ b/caddy/mksiteconfig.nix @@ -0,0 +1,23 @@ +{ CaddySiteConfig +}: +{ CaddyConfig +, CaddyService +, name +, port +, siteName +, siteRoot +, siteSocket ? "" +}: +{ + inherit name; + pkg = CaddySiteConfig rec { + inherit (CaddyConfig) siteConfigDir; + + portBinding = port; + bindService = siteName; + siteSocket = "${CaddyService.runtimeDirectory}/${siteName}.sock"; + serviceRoot = siteRoot; + phpFpmSiteSocket = siteSocket; + }; + type = "fileset"; +}