refactor(nixos): use mkWebApp module to simplify web app definitions
This commit is contained in:
parent
2292baecf6
commit
a5d8bfcdd5
8 changed files with 81 additions and 91 deletions
|
@ -1,33 +1,25 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkIf singleton;
|
||||
inherit (lib.pantheon) mkRootDomain mkStrOption mkPortOption;
|
||||
inherit (lib) singleton;
|
||||
inherit (lib.pantheon.modules) mkWebApp;
|
||||
cfg = config.server.web-apps.forgejo;
|
||||
upstreamCfg = config.services.forgejo;
|
||||
in
|
||||
{
|
||||
options.server.web-apps.forgejo = {
|
||||
enable = mkEnableOption "";
|
||||
url = mkStrOption;
|
||||
port = mkPortOption 3000;
|
||||
mkWebApp {
|
||||
inherit config;
|
||||
name = "forgejo";
|
||||
defaultPort = 3000;
|
||||
persistDirs = singleton {
|
||||
directory = upstreamCfg.stateDir;
|
||||
inherit (upstreamCfg) user group;
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
persistDirs = singleton {
|
||||
directory = upstreamCfg.stateDir;
|
||||
inherit (upstreamCfg) user group;
|
||||
};
|
||||
server.networking.ddns.domains = singleton (mkRootDomain cfg.url);
|
||||
server.web-servers.nginx.proxies = mkIf config.server.web-servers.nginx.enable (singleton {
|
||||
source = cfg.url;
|
||||
target = "http://${config.system.hostname}:${builtins.toString cfg.port}";
|
||||
});
|
||||
extraConfig = {
|
||||
services.forgejo = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
DOMAIN = cfg.url;
|
||||
ROOT_URL = "https://${cfg.url}/";
|
||||
DOMAIN = cfg.domain;
|
||||
ROOT_URL = "https://${cfg.domain}/";
|
||||
HTTP_PORT = cfg.port;
|
||||
};
|
||||
"repository.signing".FORMAT = "ssh";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue