my Nix configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gogs.nix 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. { config, pkgs, lib, ... }:
  2. let
  3. cfg = config.services.yorick.gogs;
  4. in
  5. {
  6. options.services.yorick.gogs = with lib; {
  7. enable = mkEnableOption "gogs";
  8. dir = mkOption { type = types.string; default = "/var/gogs"; };
  9. port = mkOption { type = types.int; default = 8001; };
  10. vhost = mkOption { type = types.string; };
  11. };
  12. config = lib.mkIf cfg.enable {
  13. users.extraUsers.git = { home = cfg.dir; extraGroups = [ "git" ]; useDefaultShell = true;};
  14. users.extraGroups.git = { };
  15. services.gogs = rec {
  16. enable = true;
  17. user = "git";
  18. group = "git";
  19. database.user = "root";
  20. stateDir = cfg.dir;
  21. repositoryRoot = "${stateDir}/gogs-repositories";
  22. rootUrl = "https://${cfg.vhost}/";
  23. httpAddress = "localhost";
  24. httpPort = cfg.port;
  25. extraConfig = ''
  26. [service]
  27. REGISTER_EMAIL_CONFIRM = false
  28. ENABLE_NOTIFY_MAIL = false
  29. DISABLE_REGISTRATION = true
  30. REQUIRE_SIGNIN_VIEW = false
  31. [picture]
  32. DISABLE_GRAVATAR = false
  33. AVATAR_UPLOAD_PATH = ${cfg.dir}/data/avatars
  34. [mailer]
  35. ENABLED = false
  36. '';
  37. domain = cfg.vhost;
  38. };
  39. users.extraUsers.gogs.createHome = lib.mkForce false;
  40. services.nginx.virtualHosts.${cfg.vhost} = {
  41. forceSSL = true;
  42. enableACME = true;
  43. locations."/" = {
  44. proxyPass = "http://127.0.0.1:${toString cfg.port}";
  45. extraConfig = ''
  46. proxy_buffering off;
  47. '';
  48. };
  49. };
  50. };
  51. }