From d85f50b71fa58651bbc7baef3fcc29a4a271eef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Sat, 18 Jul 2020 17:46:13 +0200 Subject: [PATCH] nixos/gitlab: Support pages Fixes #84525 --- nixos/modules/services/misc/gitlab.nix | 38 ++++++++++++++++++++++ pkgs/servers/http/gitlab-pages/default.nix | 24 ++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 64 insertions(+) create mode 100644 pkgs/servers/http/gitlab-pages/default.nix diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 425f35f37cb6..df3d9b4d4d63 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -73,6 +73,11 @@ let redisConfig.production.url = cfg.redisUrl; + pagesArgs = [ + "-pages-domain" gitlabConfig.production.pages.host + "-pages-root" "${gitlabConfig.production.shared.path}/pages" + ] ++ cfg.pagesExtraArgs; + gitlabConfig = { # These are the default settings from config/gitlab.example.yml production = flip recursiveUpdate cfg.extraConfig { @@ -236,6 +241,13 @@ in { description = "Reference to the gitaly package"; }; + packages.pages = mkOption { + type = types.package; + default = pkgs.gitlab-pages; + defaultText = "pkgs.gitlab-pages"; + description = "Reference to the gitlab-pages package"; + }; + statePath = mkOption { type = types.str; default = "/var/gitlab/state"; @@ -451,6 +463,12 @@ in { }; }; + pagesExtraArgs = mkOption { + type = types.listOf types.str; + default = [ "-listen-proxy" "127.0.0.1:8090" ]; + description = "Arguments to pass to the gitlab-pages daemon"; + }; + secrets.secretFile = mkOption { type = with types; nullOr path; default = null; @@ -754,6 +772,26 @@ in { }; }; + systemd.services.gitlab-pages = mkIf (gitlabConfig.production.pages.enabled or false) { + description = "GitLab static pages daemon"; + after = [ "network.target" "redis.service" "gitlab.service" ]; # gitlab.service creates configs + wantedBy = [ "multi-user.target" ]; + + path = [ pkgs.unzip ]; + + serviceConfig = { + Type = "simple"; + TimeoutSec = "infinity"; + Restart = "on-failure"; + + User = cfg.user; + Group = cfg.group; + + ExecStart = "${cfg.packages.pages}/bin/gitlab-pages ${escapeShellArgs pagesArgs}"; + WorkingDirectory = gitlabEnv.HOME; + }; + }; + systemd.services.gitlab-workhorse = { after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; diff --git a/pkgs/servers/http/gitlab-pages/default.nix b/pkgs/servers/http/gitlab-pages/default.nix new file mode 100644 index 000000000000..441dba9fb7b5 --- /dev/null +++ b/pkgs/servers/http/gitlab-pages/default.nix @@ -0,0 +1,24 @@ +{ buildGoModule, lib, fetchFromGitLab }: + +buildGoModule rec { + pname = "gitlab-pages"; + version = "1.21.0"; + + src = fetchFromGitLab { + owner = "gitlab-org"; + repo = "gitlab-pages"; + rev = "v${version}"; + sha256 = "0f317lx4iarlsbnq2ipcm4lpx66xzl8wfilj8xajq1csz19ws24z"; + }; + + vendorSha256 = "186rxvl523n1d87jz4zzbj83ikzw9d0c1wrj78xs4iqzm8z3snh0"; + subPackages = [ "." ]; + doCheck = false; # Broken + + meta = with lib; { + description = "Daemon used to serve static websites for GitLab users"; + homepage = "https://gitlab.com/gitlab-org/gitlab-pages"; + license = licenses.mit; + maintainers = with maintainers; [ das_j ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 296e1d8d4585..dcf13f62ba7b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16295,6 +16295,8 @@ in gatling = callPackage ../servers/http/gatling { }; + gitlab-pages = callPackage ../servers/http/gitlab-pages { }; + glabels = callPackage ../applications/graphics/glabels { }; nats-server = callPackage ../servers/nats-server { };