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"; users.extraUsers.git = { home = config.services.gogs.stateDir; extraGroups = [ "git" ]; };
users.extraGroups.git = { };
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
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] [picture]
DISABLE_GRAVATAR = false DISABLE_GRAVATAR = false
AVATAR_UPLOAD_PATH = ${gitHome}/data/avatars AVATAR_UPLOAD_PATH = ${stateDir}/data/avatars
[session]
PROVIDER = file
[log] [log]
ROOT_PATH = ${gitHome}/logs ROOT_PATH = ${stateDir}/logs
MODE = file MODE = file
LEVEL = Info LEVEL = Info
[security] [service]
INSTALL_LOCK = true DISABLE_REGISTRATION = true
''; '';
in
{
users.extraUsers.git = { home = gitHome; 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.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/
'';
}