Permalink
Browse files

Merge pull request #49814 from aanderse/gitea

nixos/gitea: fix mysql issue, add mysql socket auth, and add a nixos test
  • Loading branch information...
c0bw3b committed Nov 8, 2018
2 parents 66b8fe5 + 0dde47a commit 6399b103d84b1362cc0f69976d44c22f48de3419
Showing with 85 additions and 2 deletions.
  1. +10 −2 nixos/modules/services/misc/gitea.nix
  2. +1 −0 nixos/release.nix
  3. +74 −0 nixos/tests/gitea.nix
@@ -6,6 +6,7 @@ let
cfg = config.services.gitea;
gitea = cfg.package;
pg = config.services.postgresql;
useMysql = cfg.database.type == "mysql";
usePostgresql = cfg.database.type == "postgres";
configFile = pkgs.writeText "app.ini" ''
APP_NAME = ${cfg.appName}
@@ -14,7 +15,7 @@ let
[database]
DB_TYPE = ${cfg.database.type}
HOST = ${cfg.database.host}:${toString cfg.database.port}
HOST = ${if cfg.database.socket != null then cfg.database.socket else cfg.database.host + ":" + toString cfg.database.port}
NAME = ${cfg.database.name}
USER = ${cfg.database.user}
PASSWD = #dbpass#
@@ -148,6 +149,13 @@ in
'';
};
socket = mkOption {
type = types.nullOr types.path;
default = null;
example = "/run/mysqld/mysqld.sock";
description = "Path to the unix socket file to use for authentication.";
};
path = mkOption {
type = types.str;
default = "${cfg.stateDir}/data/gitea.db";
@@ -253,7 +261,7 @@ in
systemd.services.gitea = {
description = "gitea";
after = [ "network.target" "postgresql.service" ];
after = [ "network.target" ] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service";
wantedBy = [ "multi-user.target" ];
path = [ gitea.bin ];
@@ -304,6 +304,7 @@ in rec {
tests.fsck = callTest tests/fsck.nix {};
tests.fwupd = callTest tests/fwupd.nix {};
tests.gdk-pixbuf = callTest tests/gdk-pixbuf.nix {};
tests.gitea = callSubTests tests/gitea.nix {};
tests.gitlab = callTest tests/gitlab.nix {};
tests.gitolite = callTest tests/gitolite.nix {};
tests.gjs = callTest tests/gjs.nix {};
@@ -0,0 +1,74 @@
{ system ? builtins.currentSystem }:
with import ../lib/testing.nix { inherit system; };
with pkgs.lib;
{
mysql = makeTest {
name = "gitea-mysql";
meta.maintainers = [ maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.mysql.enable = true;
services.mysql.package = pkgs.mariadb;
services.mysql.ensureDatabases = [ "gitea" ];
services.mysql.ensureUsers = [
{ name = "gitea";
ensurePermissions = { "gitea.*" = "ALL PRIVILEGES"; };
}
];
services.gitea.enable = true;
services.gitea.database.type = "mysql";
services.gitea.database.socket = "/run/mysqld/mysqld.sock";
};
testScript = ''
startAll;
$machine->waitForUnit('gitea.service');
$machine->waitForOpenPort('3000');
$machine->succeed("curl --fail http://localhost:3000/");
'';
};
postgres = makeTest {
name = "gitea-postgres";
meta.maintainers = [ maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{
services.gitea.enable = true;
services.gitea.database.type = "postgres";
services.gitea.database.password = "secret";
};
testScript = ''
startAll;
$machine->waitForUnit('gitea.service');
$machine->waitForOpenPort('3000');
$machine->succeed("curl --fail http://localhost:3000/");
'';
};
sqlite = makeTest {
name = "gitea-sqlite";
meta.maintainers = [ maintainers.aanderse ];
machine =
{ config, pkgs, ... }:
{ services.gitea.enable = true;
};
testScript = ''
startAll;
$machine->waitForUnit('gitea.service');
$machine->waitForOpenPort('3000');
$machine->succeed("curl --fail http://localhost:3000/");
'';
};
}

0 comments on commit 6399b10

Please sign in to comment.