gitlab: I think this is the right config

This commit is contained in:
silver 2023-05-24 16:56:59 +01:00
parent 02fb3e28cd
commit e0e1b83e12

View file

@ -1,48 +1,96 @@
{ ... }: { config, pkgs, lib, ... }:
with lib;
let let
hostname = "gitlab.skynet.ie"; cfg = config.services.skynet_gitlab;
user = "git";
in { in {
imports = [ imports = [
./acme.nix ./acme.nix
./dns.nix
./firewall.nix
./nginx.nix ./nginx.nix
]; ];
options.services.skynet_gitlab = {
enable = mkEnableOption "Skynet Gitlab";
host = {
ip = mkOption {
type = types.str;
};
name = mkOption {
type = types.str;
};
};
domain = {
tld = mkOption {
type = types.str;
default = "ie";
};
base = mkOption {
type = types.str;
default = "skynet";
};
sub = mkOption {
type = types.str;
default = "gitlab";
};
};
user = mkOption {
type = types.str;
default = "git";
};
};
config = mkIf cfg.enable {
age.secrets.gitlab_pw = { age.secrets.gitlab_pw = {
file = ../secrets/gitlab/pw.age; file = ../secrets/gitlab/pw.age;
owner = user; owner = cfg.user;
group = user; group = cfg.user;
}; };
age.secrets.gitlab_db = { age.secrets.gitlab_db = {
file = ../secrets/gitlab/db.age; file = ../secrets/gitlab/db.age;
owner = user; owner = cfg.user;
group = user; group = cfg.user;
}; };
age.secrets.gitlab_db_pw = { age.secrets.gitlab_db_pw = {
file = ../secrets/gitlab/db_pw.age; file = ../secrets/gitlab/db_pw.age;
owner = user; owner = cfg.user;
group = user; group = cfg.user;
}; };
# using https://nixos.org/manual/nixos/stable/index.html#module-services-gitlab as a guide # using https://nixos.org/manual/nixos/stable/index.html#module-services-gitlab as a guide
skynet_dns.records.cname = [
"${cfg.domain.sub} CNAME ${cfg.host.name}"
];
services.nginx = { networking.firewall.allowedTCPPorts = [
virtualHosts."${hostname}" = { 80
443
# for git
22
];
services.nginx. virtualHosts."${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
forceSSL = true; forceSSL = true;
useACMEHost = "skynet"; useACMEHost = "skynet";
locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket"; locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
}; };
};
services.gitlab = { services.gitlab = {
enable = true; enable = true;
databasePasswordFile = config.age.secrets.gitlab_db_pw.path; databasePasswordFile = config.age.secrets.gitlab_db_pw.path;
initialRootPasswordFile = config.age.secrets.gitlab_pw.path; initialRootPasswordFile = config.age.secrets.gitlab_pw.path;
https = true; https = true;
host = "${hostname}"; host = "${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}";
port = 443; port = 443;
user = user; user = cfg.user;
group = user; group = cfg.user;
#smtp = { #smtp = {
# enable = true; # enable = true;
# address = "localhost"; # address = "localhost";
@ -64,5 +112,5 @@
}; };
}; };
}; };
};
} }