From 81f1c549a7d070ff9243c250013b2d4a3226724e Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sat, 10 Mar 2018 16:27:04 +0100 Subject: [PATCH] mastus: use nixos gogs service --- mastus/gogs.nix | 94 +++++++++++++------------------------------------ pkgs/gogs.nix | 21 ----------- 2 files changed, 25 insertions(+), 90 deletions(-) delete mode 100644 pkgs/gogs.nix diff --git a/mastus/gogs.nix b/mastus/gogs.nix index 98b538b..67a59bc 100644 --- a/mastus/gogs.nix +++ b/mastus/gogs.nix @@ -1,75 +1,31 @@ { config, pkgs, ... }: -let - gitHome = "/srv/git.gebner.org"; - - gogs = pkgs.callPackage ../pkgs/gogs.nix { }; - - gogsPort = 8001; - gogsConfig = pkgs.writeText "gogs.ini" '' -APP_NAME = Gogs: Go Git Service -RUN_USER = git -RUN_MODE = prod - -[database] -DB_TYPE = sqlite3 -HOST = 127.0.0.1:3306 -NAME = gogs -USER = root -PASSWD = -SSL_MODE = disable -PATH = ${gitHome}/data/gogs.db - -[repository] -ROOT = ${gitHome}/gogs-repositories - -[server] -DOMAIN = git.gebner.org -HTTP_PORT = ${toString gogsPort} -ROOT_URL = https://git.gebner.org/ -DISABLE_SSH = false -SSH_PORT = 22 -OFFLINE_MODE = true - -[mailer] -ENABLED = false - -[service] -REGISTER_EMAIL_CONFIRM = false -ENABLE_NOTIFY_MAIL = false -DISABLE_REGISTRATION = true -REQUIRE_SIGNIN_VIEW = false - -[picture] -DISABLE_GRAVATAR = false -AVATAR_UPLOAD_PATH = ${gitHome}/data/avatars - -[session] -PROVIDER = file - -[log] -ROOT_PATH = ${gitHome}/logs -MODE = file -LEVEL = Info - -[security] -INSTALL_LOCK = true -''; -in { - users.extraUsers.git = { home = gitHome; extraGroups = [ "git" ]; }; + users.extraUsers.git = { home = config.services.gogs.stateDir; extraGroups = [ "git" ]; }; users.extraGroups.git = { }; - systemd.services.gogs = { - path = with pkgs; [ git openssh bash ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "simple"; - Restart = "always"; - User = "git"; - Group = "git"; - ExecStart = "${gogs}/gogs web -c ${gogsConfig}"; - WorkingDirectory = gitHome; - }; + services.gogs = rec { + enable = true; + stateDir = "/srv/git.gebner.org"; + user = "git"; + group = "git"; + appName = "Gabriel Ebner's git server"; + domain = "git.gebner.org"; + rootUrl = "https://git.gebner.org/"; + httpPort = 8001; + cookieSecure = true; + extraConfig = '' + [picture] + DISABLE_GRAVATAR = false + AVATAR_UPLOAD_PATH = ${stateDir}/data/avatars + + [log] + ROOT_PATH = ${stateDir}/logs + MODE = file + LEVEL = Info + + [service] + DISABLE_REGISTRATION = true + ''; }; services.nginx.httpConfig = '' @@ -119,7 +75,7 @@ in } upstream gogs { - server 127.0.0.1:${toString gogsPort}; + server 127.0.0.1:${toString config.services.gogs.httpPort}; } ''; } diff --git a/pkgs/gogs.nix b/pkgs/gogs.nix deleted file mode 100644 index ab3f2e6..0000000 --- a/pkgs/gogs.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ nixpkgs ? import {} }: with nixpkgs; -stdenv.mkDerivation rec { - name = "gogs-${version}"; - version = "0.9.48"; - - src = fetchzip { - url = "https://github.com/gogits/gogs/releases/download/v${version}/linux_amd64.zip"; - sha256 = "1z00lqcz7nwbyavs1mwgsr9zjnqrjjmqvxy43p8gap768y45pvlb"; - }; - - buildPhase = '' - patchelf \ - --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ - --set-rpath ${pam}/lib \ - gogs - ''; - - installPhase = '' - cp -ra ./ $out/ - ''; -}