mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
Add forgejo module
This commit is contained in:
parent
cf72cd15e1
commit
5b81a54b48
1 changed files with 47 additions and 0 deletions
47
modules/system/forgejo/default.nix
Normal file
47
modules/system/forgejo/default.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.myConfig.forgejo;
|
||||
|
||||
user = config.users.users.forgejo.name;
|
||||
in
|
||||
{
|
||||
options.myConfig.forgejo = {
|
||||
enable = lib.mkEnableOption "";
|
||||
subdomain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 3000;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
sops.secrets."forgejo/admin-password".owner = user;
|
||||
|
||||
services.forgejo = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
DOMAIN = "${cfg.subdomain}.${config.networking.domain}";
|
||||
ROOT_URL = "https://${config.services.forgejo.settings.server.DOMAIN}/";
|
||||
HTTP_PORT = cfg.port;
|
||||
};
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.forgejo.preStart =
|
||||
let
|
||||
createCmd = "${lib.getExe config.services.forgejo.package} admin user create";
|
||||
passwordPath = config.sops.secrets."forgejo/admin-password".path;
|
||||
in
|
||||
''${createCmd} --username seb --password "$(cat ${passwordPath})" --email "sebastian.stork@pm.me" --admin || true'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue