From 1b63b28b794e89503d99ab4e1ac0a10fe6f1cf2c Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Tue, 5 Oct 2021 11:26:41 -0400 Subject: [PATCH] update phpipam settings --- modules/phpipam.nix | 56 +++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/modules/phpipam.nix b/modules/phpipam.nix index ff3d464..23cf0ae 100644 --- a/modules/phpipam.nix +++ b/modules/phpipam.nix @@ -33,24 +33,14 @@ in enable = lib.mkEnableOption "Enable phpipam"; - domainName = lib.mkOption { + hostname = lib.mkOption { type = lib.types.str; default = "localhost"; }; - useTLS = lib.mkOption { - type = lib.types.bool; - default = false; - }; - - certificatePath = lib.mkOption { - type = lib.types.str; - default = "/etc/nixos/phpipam.crt"; - }; - - certificateKeyPath = lib.mkOption { - type = lib.types.str; - default = "/etc/nixos/phpipam.key"; + virtualHost = lib.mkOption { + type = lib.types.attrs; + default = { }; }; }; @@ -92,25 +82,25 @@ in nginx = { enable = true; - virtualHosts."${cfg.domainName}" = { - addSSL = cfg.useTLS; - sslCertificate = cfg.certificatePath; - sslCertificateKey = cfg.certificateKeyPath; - extraConfig = "access_log syslog:server=unix:/dev/log;"; - root = phpipamHtdocs; - locations."/".extraConfig = '' - try_files $uri $uri/ /index.php; index index.php; - ''; - locations."/api/".extraConfig = '' - try_files $uri $uri/ /api/index.php; - ''; - locations."~ \\.php$".extraConfig = '' - fastcgi_pass unix:${config.services.phpfpm.pools.www.socket}; - fastcgi_index index.php; - try_files $uri $uri/ index.php = 404; - include ${pkgs.nginx}/conf/fastcgi.conf; - ''; - }; + virtualHosts."${cfg.hostname}" = lib.mkMerge [ + cfg.virtualHost + { + extraConfig = "access_log syslog:server=unix:/dev/log;"; + root = phpipamHtdocs; + locations."/".extraConfig = '' + try_files $uri $uri/ /index.php; index index.php; + ''; + locations."/api/".extraConfig = '' + try_files $uri $uri/ /api/index.php; + ''; + locations."~ \\.php$".extraConfig = '' + fastcgi_pass unix:${config.services.phpfpm.pools.www.socket}; + fastcgi_index index.php; + try_files $uri $uri/ index.php = 404; + include ${pkgs.nginx}/conf/fastcgi.conf; + ''; + } + ]; }; mysql = {