Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gogs: init module #19363

Merged
merged 1 commit into from Jan 21, 2017
Merged

gogs: init module #19363

merged 1 commit into from Jan 21, 2017

Conversation

schneefux
Copy link
Contributor

@schneefux schneefux commented Oct 8, 2016

Depends on #19361.
Implements a NixOS module for the Go Git Service. Based on @valeriangalliat's nixos-gogs.

Example usage:

services.gogs = {
  enable = true;
  stateDir = "/var/www/gogs";
  database = {
    type = "sqlite3";
    path = "/var/www/gogs/gogs.db";
  };
  appName = "gogs-test";
  repositoryRoot = "/var/www/git";
  domain = "test.net";
  rootUrl = "http://test.net:8080";
  httpPort = 8080;
  useWizard = false;
  extraConfig = ''
    [server]
    START_SSH_SERVER = true
    SSH_PORT = 3000
  '';
};

cc @valeriangalliat @kamilchm @yorickvP

@mention-bot
Copy link

@schneefux, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @joachifm and @offlinehacker to be potential reviewers.

type = mkOption {
type = types.str;
default = "sqlite3";
description = "Database engine to use. Either `mysql`, `postgres`or `sqlite3`.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is only a limited number of possible values you can use types.enum like for example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you.


buildGoPackage rec {
name = "gogs-${version}";
version = "v0.9.97";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the v from version

@LnL7
Copy link
Member

LnL7 commented Oct 9, 2016

This includes the changes from #19361.
Perhaps it's best to remove the changes for the package here or close the other pr in favor of this one, just to avoid confusion.

@schneefux
Copy link
Contributor Author

@LnL7 Updated, this pull request includes only the module now.


repositoryRoot = mkOption {
type = types.str;
default = "${cfg.stateDir}/repositories";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running without any options the service fails because this doesn't exist


# update all hooks' binary paths
HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 4 -type f -wholename "*git/hooks/*")
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gogs,${pkgs.gogs.bin}/bin/gogs,g' $HOOKS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails when no hooks are present. What's this for, looks a little strange to me?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these have to be absolute paths? Otherwise I would suggest this:

systemd.services.gogs.path = [ "${pkgs.gogs.bin}/bin" ];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LnL7 they do have a full path and it is no the gogs service who starts the hooks, but they are triggered from sshd for example, when somebody pushes commits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it a bit better now, can't think of a nicer solution either.

@schneefux
Copy link
Contributor Author

@LnL7 I fixed the issues. Can you test again?

The sed expression was the result of this discussion. gogs writes git hooks with absolute paths pointing to the gogs binary, and if the binary path changes, the hook scripts are not rewritten automatically.

@kamilchm
Copy link
Member

It may be also worth to take a look at https://github.com/go-gitea/gitea

@LnL7 LnL7 merged commit 1aa77d0 into NixOS:master Jan 21, 2017
@Mic92
Copy link
Member

Mic92 commented Jan 21, 2017

Gitea packaging should be also easier as they vendorize their dependencies better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants