refactor: separate module options into options.nix
This commit is contained in:
parent
cb94d7c6fb
commit
c978882918
|
@ -1,51 +1,11 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
options.aether = {
|
||||
inherit (import ../options.nix { inherit lib; }) domain https acmeEmail;
|
||||
|
||||
forgejo = {
|
||||
subdomain = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "git";
|
||||
description = ''
|
||||
The subdomain to host the Forgejo instance under.
|
||||
|
||||
If null, then Forgejo is hosted at the domain itself.
|
||||
'';
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "git";
|
||||
description = ''
|
||||
The user to run Forgejo with.
|
||||
'';
|
||||
};
|
||||
|
||||
createUser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to create the Forgejo user automatically.
|
||||
'';
|
||||
};
|
||||
|
||||
templates = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
A directory of templates for customizing Forgejo's appearance.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
let
|
||||
cfg = config.aether.forgejo;
|
||||
forgejo = config.services.forgejo;
|
||||
srv = forgejo.settings.server;
|
||||
in {
|
||||
in {
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
# Web server
|
||||
|
||||
services.nginx.enable = true;
|
||||
|
@ -62,7 +22,7 @@
|
|||
security.acme.defaults.email = cfg.acmeEmail;
|
||||
|
||||
networking.firewall.allowedTCPPorts =
|
||||
[ 80 ] ++ lib.optional config.aether.https;
|
||||
[ 80 ] ++ lib.optional config.aether.https 443;
|
||||
|
||||
# Forgejo
|
||||
|
||||
|
@ -83,8 +43,8 @@
|
|||
lib.optional
|
||||
(!(builtins.isNull cfg.templates))
|
||||
"L+ ${cfg.stateDir}/custom/templates - - - - ${cfg.templates}";
|
||||
}
|
||||
// lib.mkIf cfg.createUser {
|
||||
}
|
||||
// lib.mkIf cfg.createUser {
|
||||
users.users.${forgejo.user} = {
|
||||
home = forgejo.stateDir;
|
||||
useDefaultShell = true;
|
||||
|
@ -92,5 +52,4 @@
|
|||
isSystemUser = true;
|
||||
};
|
||||
users.groups.${forgejo.group} = {};
|
||||
};
|
||||
}
|
||||
|
|
45
modules/forgejo/options.nix
Normal file
45
modules/forgejo/options.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
args@{ config, lib, ... }:
|
||||
{
|
||||
options.aether = {
|
||||
inherit (import ../options.nix args)
|
||||
domain
|
||||
https
|
||||
acmeEmail;
|
||||
|
||||
forgejo = {
|
||||
subdomain = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "git";
|
||||
description = ''
|
||||
The subdomain to host the Forgejo instance under.
|
||||
|
||||
If null, then Forgejo is hosted at the domain itself.
|
||||
'';
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "git";
|
||||
description = ''
|
||||
The user to run Forgejo with.
|
||||
'';
|
||||
};
|
||||
|
||||
createUser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to create the Forgejo user automatically.
|
||||
'';
|
||||
};
|
||||
|
||||
templates = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
A directory of templates for customizing Forgejo's appearance.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue