mastus: use nixos gogs service

This commit is contained in:
Gabriel Ebner 2018-03-10 16:27:04 +01:00
parent 533cdabc8f
commit 81f1c549a7
2 changed files with 25 additions and 90 deletions

@ -1,75 +1,31 @@
{ config, pkgs, ... }: { 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 = { }; users.extraGroups.git = { };
systemd.services.gogs = { services.gogs = rec {
path = with pkgs; [ git openssh bash ]; enable = true;
wantedBy = [ "multi-user.target" ]; stateDir = "/srv/git.gebner.org";
serviceConfig = { user = "git";
Type = "simple"; group = "git";
Restart = "always"; appName = "Gabriel Ebner's git server";
User = "git"; domain = "git.gebner.org";
Group = "git"; rootUrl = "https://git.gebner.org/";
ExecStart = "${gogs}/gogs web -c ${gogsConfig}"; httpPort = 8001;
WorkingDirectory = gitHome; 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 = '' services.nginx.httpConfig = ''
@ -119,7 +75,7 @@ in
} }
upstream gogs { upstream gogs {
server 127.0.0.1:${toString gogsPort}; server 127.0.0.1:${toString config.services.gogs.httpPort};
} }
''; '';
} }

@ -1,21 +0,0 @@
{ nixpkgs ? import <nixpkgs> {} }: 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/
'';
}