Compare commits
No commits in common. "dcfd6941b3ae763398e9333f2b82d0a5863058a9" and "0950fedf9889448874f9e8d0c2cce8843768f39d" have entirely different histories.
dcfd6941b3
...
0950fedf98
|
@ -6,7 +6,6 @@ let
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./ci.nix
|
./ci.nix
|
||||||
./import-users.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
sops.secrets = {
|
sops.secrets = {
|
||||||
|
@ -14,6 +13,9 @@ in {
|
||||||
owner = "gitea";
|
owner = "gitea";
|
||||||
group = "gitea";
|
group = "gitea";
|
||||||
};
|
};
|
||||||
|
"gitea/passwd-ssh-key" = { };
|
||||||
|
"gitea/ssh-known-hosts" = { };
|
||||||
|
"gitea/import-user-env" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
services.gitea = {
|
services.gitea = {
|
||||||
|
@ -35,7 +37,7 @@ in {
|
||||||
ROOT_URL = "https://${domain}/";
|
ROOT_URL = "https://${domain}/";
|
||||||
PROTOCOL = "http+unix";
|
PROTOCOL = "http+unix";
|
||||||
SSH_PORT = sshPort;
|
SSH_PORT = sshPort;
|
||||||
START_SSH_SERVER = true;
|
START_SSH_SERVER = true;
|
||||||
};
|
};
|
||||||
indexer.REPO_INDEXER_ENABLED = true;
|
indexer.REPO_INDEXER_ENABLED = true;
|
||||||
service.DISABLE_REGISTRATION = true;
|
service.DISABLE_REGISTRATION = true;
|
||||||
|
@ -46,9 +48,12 @@ in {
|
||||||
ENABLE_FEDERATED_AVATAR = false;
|
ENABLE_FEDERATED_AVATAR = false;
|
||||||
};
|
};
|
||||||
actions.ENABLED = true;
|
actions.ENABLED = true;
|
||||||
|
"ui.meta".DESCRIPTION = "Bokstavelig talt programvareverkstedet";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.gitea-themes.monokai = pkgs.gitea-theme-monokai;
|
||||||
|
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
services.nginx.virtualHosts."${domain}" = {
|
services.nginx.virtualHosts."${domain}" = {
|
||||||
|
@ -61,41 +66,42 @@ in {
|
||||||
client_max_body_size 512M;
|
client_max_body_size 512M;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
locations."/metrics" = {
|
|
||||||
proxyPass = "http://unix:${cfg.settings.server.HTTP_ADDR}";
|
|
||||||
extraConfig = ''
|
|
||||||
allow ${values.hosts.ildkule.ipv4};
|
|
||||||
allow ${values.hosts.ildkule.ipv6};
|
|
||||||
deny all;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ sshPort ];
|
networking.firewall.allowedTCPPorts = [ sshPort ];
|
||||||
|
|
||||||
# Extra customization
|
# Automatically import users
|
||||||
|
systemd.services.gitea-import-users = {
|
||||||
services.gitea-themes.monokai = pkgs.gitea-theme-monokai;
|
enable = true;
|
||||||
|
preStart=''${pkgs.rsync}/bin/rsync -e "${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=$CREDENTIALS_DIRECTORY/ssh-known-hosts -i $CREDENTIALS_DIRECTORY/sshkey" -a pvv@smtp.pvv.ntnu.no:/etc/passwd /tmp/passwd-import'';
|
||||||
systemd.services.install-gitea-customization = {
|
serviceConfig = {
|
||||||
description = "Install extra customization in gitea's CUSTOM_DIR";
|
ExecStart = pkgs.writers.writePython3 "gitea-import-users" { libraries = [ pkgs.python3Packages.requests ]; } (builtins.readFile ./gitea-import-users.py);
|
||||||
wantedBy = [ "gitea.service" ];
|
LoadCredential=[
|
||||||
requiredBy = [ "gitea.service" ];
|
"sshkey:${config.sops.secrets."gitea/passwd-ssh-key".path}"
|
||||||
|
"ssh-known-hosts:${config.sops.secrets."gitea/ssh-known-hosts".path}"
|
||||||
serviceConfig = {
|
];
|
||||||
Type = "oneshot";
|
DynamicUser="yes";
|
||||||
User = cfg.user;
|
EnvironmentFile=config.sops.secrets."gitea/import-user-env".path;
|
||||||
Group = cfg.group;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
script = let
|
|
||||||
logo-svg = ../../../../assets/logo_blue_regular.svg;
|
|
||||||
logo-png = ../../../../assets/logo_blue_regular.png;
|
|
||||||
in ''
|
|
||||||
install -Dm444 ${logo-svg} ${cfg.customDir}/public/img/logo.svg
|
|
||||||
install -Dm444 ${logo-png} ${cfg.customDir}/public/img/logo.png
|
|
||||||
install -Dm444 ${./loading.apng} ${cfg.customDir}/public/img/loading.png
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.timers.gitea-import-users = {
|
||||||
|
requires = [ "gitea.service" ];
|
||||||
|
after = [ "gitea.service" ];
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "*-*-* 02:00:00";
|
||||||
|
Persistent = true;
|
||||||
|
Unit = "gitea-import-users.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
system.activationScripts.linkGiteaLogo.text = let
|
||||||
|
logo-svg = ../../../../assets/logo_blue_regular.svg;
|
||||||
|
logo-png = ../../../../assets/logo_blue_regular.png;
|
||||||
|
in ''
|
||||||
|
install -Dm444 ${logo-svg} ${cfg.stateDir}/custom/public/img/logo.svg
|
||||||
|
install -Dm444 ${logo-png} ${cfg.stateDir}/custom/public/img/logo.png
|
||||||
|
install -Dm444 ${./loading.apng} ${cfg.stateDir}/custom/public/img/loading.png
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
let
|
|
||||||
cfg = config.services.gitea;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
sops.secrets = {
|
|
||||||
"gitea/passwd-ssh-key" = { };
|
|
||||||
"gitea/ssh-known-hosts" = { };
|
|
||||||
"gitea/import-user-env" = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.gitea-import-users = lib.mkIf cfg.enable {
|
|
||||||
enable = true;
|
|
||||||
preStart=''${pkgs.rsync}/bin/rsync -e "${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=$CREDENTIALS_DIRECTORY/ssh-known-hosts -i $CREDENTIALS_DIRECTORY/sshkey" -a pvv@smtp.pvv.ntnu.no:/etc/passwd /tmp/passwd-import'';
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = pkgs.writers.writePython3 "gitea-import-users" {
|
|
||||||
libraries = with pkgs.python3Packages; [ requests ];
|
|
||||||
} (builtins.readFile ./gitea-import-users.py);
|
|
||||||
LoadCredential=[
|
|
||||||
"sshkey:${config.sops.secrets."gitea/passwd-ssh-key".path}"
|
|
||||||
"ssh-known-hosts:${config.sops.secrets."gitea/ssh-known-hosts".path}"
|
|
||||||
];
|
|
||||||
DynamicUser="yes";
|
|
||||||
EnvironmentFile=config.sops.secrets."gitea/import-user-env".path;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.timers.gitea-import-users = lib.mkIf cfg.enable {
|
|
||||||
requires = [ "gitea.service" ];
|
|
||||||
after = [ "gitea.service" ];
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "*-*-* 02:00:00";
|
|
||||||
Persistent = true;
|
|
||||||
Unit = "gitea-import-users.service";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in New Issue