1 diff --git a/nixos/lib/make-options-doc/options-to-docbook.xsl b/nixos/lib/make-options-doc/options-to-docbook.xsl
2 index 18d19fddaca..304698a51ad 100644
3 --- a/nixos/lib/make-options-doc/options-to-docbook.xsl
4 +++ b/nixos/lib/make-options-doc/options-to-docbook.xsl
6 <title>Configuration Options</title>
7 <variablelist xml:id="configuration-variable-list">
8 <xsl:for-each select="attrs">
9 - <xsl:variable name="id" select="concat('opt-', str:replace(str:replace(str:replace(attr[@name = 'name']/string/@value, '*', '_'), '<', '_'), '>', '_'))" />
10 + <xsl:variable name="id" select="concat('opt-', str:replace(str:replace(str:replace(str:replace(attr[@name = 'name']/string/@value, '*', '_'), '<', '_'), '>', '_'), ':', '_'))" />
12 <term xlink:href="#{$id}">
13 <xsl:attribute name="xml:id"><xsl:value-of select="$id"/></xsl:attribute>
14 diff --git a/nixos/modules/services/databases/redis.nix b/nixos/modules/services/databases/redis.nix
15 index 8873f6d00e0..e14bb89c75c 100644
16 --- a/nixos/modules/services/databases/redis.nix
17 +++ b/nixos/modules/services/databases/redis.nix
18 @@ -5,17 +5,18 @@ with lib;
20 cfg = config.services.redis;
22 - ulimitNofile = cfg.maxclients + 32;
24 mkValueString = value:
25 if value == true then "yes"
26 else if value == false then "no"
27 else generators.mkValueStringDefault { } value;
29 - redisConfig = pkgs.writeText "redis.conf" (generators.toKeyValue {
30 + redisConfig = settings: pkgs.writeText "redis.conf" (generators.toKeyValue {
31 listsAsDuplicateKeys = true;
32 mkKeyValue = generators.mkKeyValueDefault { inherit mkValueString; } " ";
36 + redisName = name: "redis" + optionalString (name != "") ("-"+name);
37 + enabledServers = filterAttrs (name: conf: conf.enable) config.services.redis.servers;
41 @@ -25,6 +26,27 @@ in {
42 (mkRemovedOptionModule [ "services" "redis" "appendOnlyFilename" ] "This option was never used.")
43 (mkRemovedOptionModule [ "services" "redis" "pidFile" ] "This option was removed.")
44 (mkRemovedOptionModule [ "services" "redis" "extraConfig" ] "Use services.redis.settings instead.")
45 + (mkRenamedOptionModule [ "services" "redis" "enable"] [ "services" "redis" "servers" "" "enable" ])
46 + (mkRenamedOptionModule [ "services" "redis" "port"] [ "services" "redis" "servers" "" "port" ])
47 + (mkRenamedOptionModule [ "services" "redis" "openFirewall"] [ "services" "redis" "servers" "" "openFirewall" ])
48 + (mkRenamedOptionModule [ "services" "redis" "bind"] [ "services" "redis" "servers" "" "bind" ])
49 + (mkRenamedOptionModule [ "services" "redis" "unixSocket"] [ "services" "redis" "servers" "" "unixSocket" ])
50 + (mkRenamedOptionModule [ "services" "redis" "unixSocketPerm"] [ "services" "redis" "servers" "" "unixSocketPerm" ])
51 + (mkRenamedOptionModule [ "services" "redis" "logLevel"] [ "services" "redis" "servers" "" "logLevel" ])
52 + (mkRenamedOptionModule [ "services" "redis" "logfile"] [ "services" "redis" "servers" "" "logfile" ])
53 + (mkRenamedOptionModule [ "services" "redis" "syslog"] [ "services" "redis" "servers" "" "syslog" ])
54 + (mkRenamedOptionModule [ "services" "redis" "databases"] [ "services" "redis" "servers" "" "databases" ])
55 + (mkRenamedOptionModule [ "services" "redis" "maxclients"] [ "services" "redis" "servers" "" "maxclients" ])
56 + (mkRenamedOptionModule [ "services" "redis" "save"] [ "services" "redis" "servers" "" "save" ])
57 + (mkRenamedOptionModule [ "services" "redis" "slaveOf"] [ "services" "redis" "servers" "" "slaveOf" ])
58 + (mkRenamedOptionModule [ "services" "redis" "masterAuth"] [ "services" "redis" "servers" "" "masterAuth" ])
59 + (mkRenamedOptionModule [ "services" "redis" "requirePass"] [ "services" "redis" "servers" "" "requirePass" ])
60 + (mkRenamedOptionModule [ "services" "redis" "requirePassFile"] [ "services" "redis" "servers" "" "requirePassFile" ])
61 + (mkRenamedOptionModule [ "services" "redis" "appendOnly"] [ "services" "redis" "servers" "" "appendOnly" ])
62 + (mkRenamedOptionModule [ "services" "redis" "appendFsync"] [ "services" "redis" "servers" "" "appendFsync" ])
63 + (mkRenamedOptionModule [ "services" "redis" "slowLogLogSlowerThan"] [ "services" "redis" "servers" "" "slowLogLogSlowerThan" ])
64 + (mkRenamedOptionModule [ "services" "redis" "slowLogMaxLen"] [ "services" "redis" "servers" "" "slowLogMaxLen" ])
65 + (mkRenamedOptionModule [ "services" "redis" "settings"] [ "services" "redis" "servers" "" "settings" ])
69 @@ -32,18 +54,6 @@ in {
78 - Whether to enable the Redis server. Note that the NixOS module for
79 - Redis disables kernel support for Transparent Huge Pages (THP),
80 - because this features causes major performance problems for Redis,
81 - e.g. (https://redis.io/topics/latency).
88 @@ -51,177 +61,227 @@ in {
89 description = "Which Redis derivation to use.";
95 - description = "The port for Redis to listen to.";
97 + vmOverCommit = mkEnableOption ''
98 + setting of vm.overcommit_memory to 1
99 + (Suggested for Background Saving: http://redis.io/topics/faq)
102 - vmOverCommit = mkOption {
106 - Set vm.overcommit_memory to 1 (Suggested for Background Saving: http://redis.io/topics/faq)
110 - openFirewall = mkOption {
114 - Whether to open ports in the firewall for the server.
119 - type = with types; nullOr str;
120 - default = "127.0.0.1";
122 - The IP interface to bind to.
123 - <literal>null</literal> means "all interfaces".
125 - example = "192.0.2.1";
128 - unixSocket = mkOption {
129 - type = with types; nullOr path;
131 - description = "The path to the socket to bind to.";
132 - example = "/run/redis/redis.sock";
135 - unixSocketPerm = mkOption {
138 - description = "Change permissions for the socket";
142 - logLevel = mkOption {
144 - default = "notice"; # debug, verbose, notice, warning
146 - description = "Specify the server verbosity level, options: debug, verbose, notice, warning.";
149 - logfile = mkOption {
151 - default = "/dev/null";
152 - description = "Specify the log file name. Also 'stdout' can be used to force Redis to log on the standard output.";
153 - example = "/var/log/redis.log";
156 - syslog = mkOption {
159 - description = "Enable logging to the system logger.";
162 - databases = mkOption {
165 - description = "Set the number of databases.";
168 - maxclients = mkOption {
171 - description = "Set the max number of connected clients at the same time.";
175 - type = with types; listOf (listOf int);
176 - default = [ [900 1] [300 10] [60 10000] ];
177 - description = "The schedule in which data is persisted to disk, represented as a list of lists where the first element represent the amount of seconds and the second the number of changes.";
178 - example = [ [900 1] [300 10] [60 10000] ];
181 - slaveOf = mkOption {
182 - type = with types; nullOr (submodule ({ ... }: {
183 + servers = mkOption {
184 + type = with types; attrsOf (submodule ({config, name, ...}@args: {
188 - description = "IP of the Redis master";
189 - example = "192.168.1.100";
190 + enable = mkEnableOption ''
193 + Note that the NixOS module for Redis disables kernel support
194 + for Transparent Huge Pages (THP),
195 + because this features causes major performance problems for Redis,
196 + e.g. (https://redis.io/topics/latency).
201 + default = redisName name;
202 + defaultText = "\"redis\" or \"redis-\${name}\" if name != \"\"";
203 + description = "The username and groupname for redis-server.";
208 - description = "port of the Redis master";
211 + description = "The port for Redis to listen to.";
214 + openFirewall = mkOption {
218 + Whether to open ports in the firewall for the server.
223 + type = with types; nullOr str;
224 + default = if name == "" then "127.0.0.1" else null;
225 + defaultText = "127.0.0.1 or null if name != \"\"";
227 + The IP interface to bind to.
228 + <literal>null</literal> means "all interfaces".
230 + example = "192.0.2.1";
233 + unixSocket = mkOption {
234 + type = with types; nullOr path;
235 + default = "/run/${redisName name}/redis.sock";
236 + defaultText = "\"/run/redis/redis.sock\" or \"/run/redis-\${name}/redis.sock\" if name != \"\"";
237 + description = "The path to the socket to bind to.";
240 + unixSocketPerm = mkOption {
243 + description = "Change permissions for the socket";
247 + logLevel = mkOption {
249 + default = "notice"; # debug, verbose, notice, warning
251 + description = "Specify the server verbosity level, options: debug, verbose, notice, warning.";
254 + logfile = mkOption {
256 + default = "/dev/null";
257 + description = "Specify the log file name. Also 'stdout' can be used to force Redis to log on the standard output.";
258 + example = "/var/log/redis.log";
261 + syslog = mkOption {
264 + description = "Enable logging to the system logger.";
267 + databases = mkOption {
270 + description = "Set the number of databases.";
273 + maxclients = mkOption {
276 + description = "Set the max number of connected clients at the same time.";
280 + type = with types; listOf (listOf int);
281 + default = [ [900 1] [300 10] [60 10000] ];
282 + description = "The schedule in which data is persisted to disk, represented as a list of lists where the first element represent the amount of seconds and the second the number of changes.";
283 + example = [ [900 1] [300 10] [60 10000] ];
286 + slaveOf = mkOption {
287 + type = with types; nullOr (submodule ({ ... }: {
291 + description = "IP of the Redis master";
292 + example = "192.168.1.100";
297 + description = "port of the Redis master";
304 + description = "IP and port to which this redis instance acts as a slave.";
305 + example = { ip = "192.168.1.100"; port = 6379; };
308 + masterAuth = mkOption {
309 + type = with types; nullOr str;
311 + description = ''If the master is password protected (using the requirePass configuration)
312 + it is possible to tell the slave to authenticate before starting the replication synchronization
313 + process, otherwise the master will refuse the slave request.
314 + (STORED PLAIN TEXT, WORLD-READABLE IN NIX STORE)'';
317 + requirePass = mkOption {
318 + type = with types; nullOr str;
321 + Password for database (STORED PLAIN TEXT, WORLD-READABLE IN NIX STORE).
322 + Use requirePassFile to store it outside of the nix store in a dedicated file.
324 + example = "letmein!";
327 + requirePassFile = mkOption {
328 + type = with types; nullOr path;
330 + description = "File with password for the database.";
331 + example = "/run/keys/redis-password";
334 + appendOnly = mkOption {
337 + description = "By default data is only periodically persisted to disk, enable this option to use an append-only file for improved persistence.";
340 + appendFsync = mkOption {
342 + default = "everysec"; # no, always, everysec
343 + description = "How often to fsync the append-only log, options: no, always, everysec.";
346 + slowLogLogSlowerThan = mkOption {
349 + description = "Log queries whose execution take longer than X in milliseconds.";
353 + slowLogMaxLen = mkOption {
356 + description = "Maximum number of items to keep in slow log.";
359 + settings = mkOption {
360 + # TODO: this should be converted to freeformType
361 + type = with types; attrsOf (oneOf [ bool int str (listOf str) ]);
364 + Redis configuration. Refer to
365 + <link xlink:href="https://redis.io/topics/config"/>
366 + for details on supported values.
368 + example = literalExample ''
370 + loadmodule = [ "/path/to/my_module.so" "/path/to/other_module.so" ];
375 + config.settings = mkMerge [
377 + port = config.port;
379 + supervised = "systemd";
380 + loglevel = config.logLevel;
381 + logfile = config.logfile;
382 + syslog-enabled = config.syslog;
383 + databases = config.databases;
384 + maxclients = config.maxclients;
385 + save = map (d: "${toString (builtins.elemAt d 0)} ${toString (builtins.elemAt d 1)}") config.save;
386 + dbfilename = "dump.rdb";
387 + dir = "/var/lib/${redisName name}";
388 + appendOnly = config.appendOnly;
389 + appendfsync = config.appendFsync;
390 + slowlog-log-slower-than = config.slowLogLogSlowerThan;
391 + slowlog-max-len = config.slowLogMaxLen;
393 + (mkIf (config.bind != null) { bind = config.bind; })
394 + (mkIf (config.unixSocket != null) {
395 + unixsocket = config.unixSocket;
396 + unixsocketperm = toString config.unixSocketPerm;
398 + (mkIf (config.slaveOf != null) { slaveof = "${config.slaveOf.ip} ${toString config.slaveOf.port}"; })
399 + (mkIf (config.masterAuth != null) { masterauth = config.masterAuth; })
400 + (mkIf (config.requirePass != null) { requirepass = config.requirePass; })
405 - description = "IP and port to which this redis instance acts as a slave.";
406 - example = { ip = "192.168.1.100"; port = 6379; };
409 - masterAuth = mkOption {
410 - type = with types; nullOr str;
412 - description = ''If the master is password protected (using the requirePass configuration)
413 - it is possible to tell the slave to authenticate before starting the replication synchronization
414 - process, otherwise the master will refuse the slave request.
415 - (STORED PLAIN TEXT, WORLD-READABLE IN NIX STORE)'';
418 - requirePass = mkOption {
419 - type = with types; nullOr str;
422 - Password for database (STORED PLAIN TEXT, WORLD-READABLE IN NIX STORE).
423 - Use requirePassFile to store it outside of the nix store in a dedicated file.
425 - example = "letmein!";
428 - requirePassFile = mkOption {
429 - type = with types; nullOr path;
431 - description = "File with password for the database.";
432 - example = "/run/keys/redis-password";
435 - appendOnly = mkOption {
438 - description = "By default data is only periodically persisted to disk, enable this option to use an append-only file for improved persistence.";
441 - appendFsync = mkOption {
443 - default = "everysec"; # no, always, everysec
444 - description = "How often to fsync the append-only log, options: no, always, everysec.";
447 - slowLogLogSlowerThan = mkOption {
450 - description = "Log queries whose execution take longer than X in milliseconds.";
454 - slowLogMaxLen = mkOption {
457 - description = "Maximum number of items to keep in slow log.";
460 - settings = mkOption {
461 - type = with types; attrsOf (oneOf [ bool int str (listOf str) ]);
462 + description = "Configuration of multiple <literal>redis-server</literal> instances.";
465 - Redis configuration. Refer to
466 - <link xlink:href="https://redis.io/topics/config"/>
467 - for details on supported values.
469 - example = literalExample ''
471 - loadmodule = [ "/path/to/my_module.so" "/path/to/other_module.so" ];
477 @@ -230,77 +290,60 @@ in {
479 ###### implementation
481 - config = mkIf config.services.redis.enable {
483 - assertion = cfg.requirePass != null -> cfg.requirePassFile == null;
484 - message = "You can only set one services.redis.requirePass or services.redis.requirePassFile";
486 - boot.kernel.sysctl = (mkMerge [
487 + config = mkIf (enabledServers != {}) {
489 + assertions = attrValues (mapAttrs (name: conf: {
490 + assertion = conf.requirePass != null -> conf.requirePassFile == null;
492 + You can only set one services.redis.servers.${name}.requirePass
493 + or services.redis.servers.${name}.requirePassFile
495 + }) enabledServers);
497 + boot.kernel.sysctl = mkMerge [
498 { "vm.nr_hugepages" = "0"; }
499 ( mkIf cfg.vmOverCommit { "vm.overcommit_memory" = "1"; } )
503 - networking.firewall = mkIf cfg.openFirewall {
504 - allowedTCPPorts = [ cfg.port ];
507 - users.users.redis = {
508 - description = "Redis database user";
509 - isSystemUser = true;
511 - users.groups.redis = {};
512 + networking.firewall.allowedTCPPorts = concatMap (conf:
513 + optional conf.openFirewall conf.port
514 + ) (attrValues enabledServers);
516 environment.systemPackages = [ cfg.package ];
518 - services.redis.settings = mkMerge [
522 - supervised = "systemd";
523 - loglevel = cfg.logLevel;
524 - logfile = cfg.logfile;
525 - syslog-enabled = cfg.syslog;
526 - databases = cfg.databases;
527 - maxclients = cfg.maxclients;
528 - save = map (d: "${toString (builtins.elemAt d 0)} ${toString (builtins.elemAt d 1)}") cfg.save;
529 - dbfilename = "dump.rdb";
530 - dir = "/var/lib/redis";
531 - appendOnly = cfg.appendOnly;
532 - appendfsync = cfg.appendFsync;
533 - slowlog-log-slower-than = cfg.slowLogLogSlowerThan;
534 - slowlog-max-len = cfg.slowLogMaxLen;
536 - (mkIf (cfg.bind != null) { bind = cfg.bind; })
537 - (mkIf (cfg.unixSocket != null) { unixsocket = cfg.unixSocket; unixsocketperm = "${toString cfg.unixSocketPerm}"; })
538 - (mkIf (cfg.slaveOf != null) { slaveof = "${cfg.slaveOf.ip} ${toString cfg.slaveOf.port}"; })
539 - (mkIf (cfg.masterAuth != null) { masterauth = cfg.masterAuth; })
540 - (mkIf (cfg.requirePass != null) { requirepass = cfg.requirePass; })
542 + users.users = mapAttrs' (name: conf: nameValuePair (redisName name) {
543 + description = "System user for the redis-server instance ${name}";
544 + isSystemUser = true;
546 + users.groups = mapAttrs' (name: conf: nameValuePair (redisName name) {
549 - systemd.services.redis = {
550 - description = "Redis Server";
551 + systemd.services = mapAttrs' (name: conf: nameValuePair (redisName name) {
552 + description = "Redis Server - ${redisName name}";
554 wantedBy = [ "multi-user.target" ];
555 after = [ "network.target" ];
558 - install -m 600 ${redisConfig} /run/redis/redis.conf
559 - '' + optionalString (cfg.requirePassFile != null) ''
560 - password=$(cat ${escapeShellArg cfg.requirePassFile})
561 - echo "requirePass $password" >> /run/redis/redis.conf
565 - ExecStart = "${cfg.package}/bin/redis-server /run/redis/redis.conf";
566 + ExecStart = "${cfg.package}/bin/redis-server /run/${redisName name}/redis.conf";
567 + ExecStartPre = [("+"+pkgs.writeShellScript "${redisName name}-credentials" (''
568 + install -o '${conf.user}' -m 600 ${redisConfig conf.settings} /run/${redisName name}/redis.conf
569 + '' + optionalString (conf.requirePassFile != null) ''
571 + printf requirePass' '
572 + cat ${escapeShellArg conf.requirePassFile}
573 + } >>/run/${redisName name}/redis.conf
582 # Runtime directory and mode
583 - RuntimeDirectory = "redis";
584 + RuntimeDirectory = redisName name;
585 RuntimeDirectoryMode = "0750";
586 # State directory and mode
587 - StateDirectory = "redis";
588 + StateDirectory = redisName name;
589 StateDirectoryMode = "0700";
590 # Access write directories
592 @@ -309,7 +352,7 @@ in {
594 NoNewPrivileges = true;
596 - LimitNOFILE = "${toString ulimitNofile}";
597 + LimitNOFILE = mkDefault "${toString (conf.maxclients + 32)}";
599 ProtectSystem = "strict";
601 @@ -322,7 +365,9 @@ in {
602 ProtectKernelModules = true;
603 ProtectKernelTunables = true;
604 ProtectControlGroups = true;
605 - RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
606 + RestrictAddressFamilies =
607 + optionals (conf.bind != null) ["AF_INET" "AF_INET6"] ++
608 + optional (conf.unixSocket != null) "AF_UNIX";
609 RestrictNamespaces = true;
610 LockPersonality = true;
611 MemoryDenyWriteExecute = true;
612 @@ -333,6 +378,7 @@ in {
613 SystemCallArchitectures = "native";
614 SystemCallFilter = "~@cpu-emulation @debug @keyring @memlock @mount @obsolete @privileged @resources @setuid";
621 diff --git a/nixos/modules/services/misc/sourcehut/builds.nix b/nixos/modules/services/misc/sourcehut/builds.nix
622 deleted file mode 100644
623 index e446f08284f..00000000000
624 --- a/nixos/modules/services/misc/sourcehut/builds.nix
627 -{ config, lib, pkgs, ... }:
631 - cfg = config.services.sourcehut;
633 - rcfg = config.services.redis;
634 - iniKey = "builds.sr.ht";
636 - drv = pkgs.sourcehut.buildsrht;
639 - options.services.sourcehut.builds = {
642 - default = "buildsrht";
644 - User for builds.sr.ht.
652 - Port on which the "builds" module should listen.
656 - database = mkOption {
658 - default = "builds.sr.ht";
660 - PostgreSQL database name for builds.sr.ht.
664 - statePath = mkOption {
666 - default = "${cfg.statePath}/buildsrht";
668 - State path for builds.sr.ht.
672 - enableWorker = mkOption {
676 - Run workers for builds.sr.ht.
680 - images = mkOption {
681 - type = types.attrsOf (types.attrsOf (types.attrsOf types.package));
683 - example = lib.literalExample ''(let
684 - # Pinning unstable to allow usage with flakes and limit rebuilds.
685 - pkgs_unstable = builtins.fetchGit {
686 - url = "https://github.com/NixOS/nixpkgs";
687 - rev = "ff96a0fa5635770390b184ae74debea75c3fd534";
688 - ref = "nixos-unstable";
690 - image_from_nixpkgs = pkgs_unstable: (import ("${pkgs.sourcehut.buildsrht}/lib/images/nixos/image.nix") {
691 - pkgs = (import pkgs_unstable {});
695 - nixos.unstable.x86_64 = image_from_nixpkgs pkgs_unstable;
699 - Images for builds.sr.ht. Each package should be distro.release.arch and point to a /nix/store/package/root.img.qcow2.
705 - config = with scfg; let
706 - image_dirs = lib.lists.flatten (
707 - lib.attrsets.mapAttrsToList
709 - lib.attrsets.mapAttrsToList
711 - lib.attrsets.mapAttrsToList
713 - pkgs.runCommand "buildsrht-images" { } ''
714 - mkdir -p $out/${distro}/${rev}/${arch}
715 - ln -s ${image}/*.qcow2 $out/${distro}/${rev}/${arch}/root.img.qcow2
720 - image_dir_pre = pkgs.symlinkJoin {
721 - name = "builds.sr.ht-worker-images-pre";
722 - paths = image_dirs ++ [
723 - "${pkgs.sourcehut.buildsrht}/lib/images"
726 - image_dir = pkgs.runCommand "builds.sr.ht-worker-images" { } ''
727 - mkdir -p $out/images
728 - cp -Lr ${image_dir_pre}/* $out/images
731 - lib.mkIf (cfg.enable && elem "builds" cfg.services) {
735 - isSystemUser = true;
737 - extraGroups = lib.optionals cfg.builds.enableWorker [ "docker" ];
738 - description = "builds.sr.ht user";
747 - services.postgresql = {
748 - authentication = ''
749 - local ${database} ${user} trust
751 - ensureDatabases = [ database ];
755 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
762 - "d ${statePath} 0755 ${user} ${user} -"
763 - ] ++ (lib.optionals cfg.builds.enableWorker
764 - [ "d ${statePath}/logs 0775 ${user} ${user} - -" ]
768 - buildsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey
770 - after = [ "postgresql.service" "network.target" ];
771 - requires = [ "postgresql.service" ];
772 - wantedBy = [ "multi-user.target" ];
774 - description = "builds.sr.ht website service";
776 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
778 - # Hack to bypass this hack: https://git.sr.ht/~sircmpwn/core.sr.ht/tree/master/item/srht-update-profiles#L6
779 - } // { preStart = " "; };
781 - buildsrht-worker = {
782 - enable = scfg.enableWorker;
783 - after = [ "postgresql.service" "network.target" ];
784 - requires = [ "postgresql.service" ];
785 - wantedBy = [ "multi-user.target" ];
786 - partOf = [ "buildsrht.service" ];
787 - description = "builds.sr.ht worker service";
788 - path = [ pkgs.openssh pkgs.docker ];
789 - preStart = let qemuPackage = pkgs.qemu_kvm;
791 - if [[ "$(docker images -q qemu:latest 2> /dev/null)" == "" || "$(cat ${statePath}/docker-image-qemu 2> /dev/null || true)" != "${qemuPackage.version}" ]]; then
792 - # Create and import qemu:latest image for docker
794 - pkgs.dockerTools.streamLayeredImage {
797 - contents = [ qemuPackage ];
800 - # Mark down current package version
801 - printf "%s" "${qemuPackage.version}" > ${statePath}/docker-image-qemu
808 - Restart = "always";
810 - serviceConfig.ExecStart = "${pkgs.sourcehut.buildsrht}/bin/builds.sr.ht-worker";
815 - services.sourcehut.settings = {
816 - # URL builds.sr.ht is being served at (protocol://domain)
817 - "builds.sr.ht".origin = mkDefault "http://builds.${cfg.originBase}";
818 - # Address and port to bind the debug server to
819 - "builds.sr.ht".debug-host = mkDefault "0.0.0.0";
820 - "builds.sr.ht".debug-port = mkDefault port;
821 - # Configures the SQLAlchemy connection string for the database.
822 - "builds.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
823 - # Set to "yes" to automatically run migrations on package upgrade.
824 - "builds.sr.ht".migrate-on-upgrade = mkDefault "yes";
825 - # builds.sr.ht's OAuth client ID and secret for meta.sr.ht
826 - # Register your client at meta.example.org/oauth
827 - "builds.sr.ht".oauth-client-id = mkDefault null;
828 - "builds.sr.ht".oauth-client-secret = mkDefault null;
829 - # The redis connection used for the celery worker
830 - "builds.sr.ht".redis = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/3";
831 - # The shell used for ssh
832 - "builds.sr.ht".shell = mkDefault "runner-shell";
833 - # Register the builds.sr.ht dispatcher
834 - "git.sr.ht::dispatch".${builtins.unsafeDiscardStringContext "${pkgs.sourcehut.buildsrht}/bin/buildsrht-keys"} = mkDefault "${user}:${user}";
836 - # Location for build logs, images, and control command
837 - } // lib.attrsets.optionalAttrs scfg.enableWorker {
838 - # Default worker stores logs that are accessible via this address:port
839 - "builds.sr.ht::worker".name = mkDefault "127.0.0.1:5020";
840 - "builds.sr.ht::worker".buildlogs = mkDefault "${scfg.statePath}/logs";
841 - "builds.sr.ht::worker".images = mkDefault "${image_dir}/images";
842 - "builds.sr.ht::worker".controlcmd = mkDefault "${image_dir}/images/control";
843 - "builds.sr.ht::worker".timeout = mkDefault "3m";
846 - services.nginx.virtualHosts."logs.${cfg.originBase}" =
847 - if scfg.enableWorker then {
848 - listen = with builtins; let address = split ":" cfg.settings."builds.sr.ht::worker".name;
849 - in [{ addr = elemAt address 0; port = lib.toInt (elemAt address 2); }];
850 - locations."/logs".root = "${scfg.statePath}";
853 - services.nginx.virtualHosts."builds.${cfg.originBase}" = {
855 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
856 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
857 - locations."/static".root = "${pkgs.sourcehut.buildsrht}/${pkgs.sourcehut.python.sitePackages}/buildsrht";
861 diff --git a/nixos/modules/services/misc/sourcehut/default.nix b/nixos/modules/services/misc/sourcehut/default.nix
862 index 9c812d6b043..c6c70e6ae2b 100644
863 --- a/nixos/modules/services/misc/sourcehut/default.nix
864 +++ b/nixos/modules/services/misc/sourcehut/default.nix
866 { config, pkgs, lib, ... }:
870 + inherit (config.services) nginx postfix postgresql redis;
871 + inherit (config.users) users groups;
872 cfg = config.services.sourcehut;
873 - cfgIni = cfg.settings;
874 - settingsFormat = pkgs.formats.ini { };
875 + domain = cfg.settings."sr.ht".global-domain;
876 + settingsFormat = pkgs.formats.ini {
877 + listToValue = concatMapStringsSep "," (generators.mkValueStringDefault {});
879 + if v == null then ""
880 + else generators.mkKeyValueDefault {
882 + if v == true then "yes"
883 + else if v == false then "no"
884 + else generators.mkValueStringDefault {} v;
887 + configIniOfService = srv: settingsFormat.generate "sourcehut-${srv}-config.ini"
888 + # Each service needs access to only a subset of sections (and secrets).
889 + (filterAttrs (k: v: v != null)
890 + (mapAttrs (section: v:
891 + let srvMatch = builtins.match "^([a-z]*)\\.sr\\.ht(::.*)?$" section; in
892 + if srvMatch == null # Include sections shared by all services
893 + || head srvMatch == srv # Include sections for the service being configured
895 + # Enable Web links and integrations between services.
896 + else if tail srvMatch == [ null ] && elem (head srvMatch) cfg.services
898 + inherit (v) origin;
899 + # mansrht crashes without it
900 + oauth-client-id = v.oauth-client-id or null;
902 + # Drop sub-sections of other services
904 + (recursiveUpdate cfg.settings {
905 + # Those paths are mounted using BindPaths= or BindReadOnlyPaths=
906 + # for services needing access to them.
907 + "builds.sr.ht::worker".buildlogs = "/var/log/sourcehut/buildsrht/logs";
908 + "git.sr.ht".post-update-script = "/var/lib/sourcehut/gitsrht/bin/post-update-script";
909 + "git.sr.ht".repos = "/var/lib/sourcehut/gitsrht/repos";
910 + "hg.sr.ht".changegroup-script = "/var/lib/sourcehut/hgsrht/bin/changegroup-script";
911 + "hg.sr.ht".repos = "/var/lib/sourcehut/hgsrht/repos";
912 + # Making this a per service option despite being in a global section,
913 + # so that it uses the redis-server used by the service.
914 + "sr.ht".redis-host = cfg.${srv}.redis.host;
916 + commonServiceSettings = srv: {
917 + origin = mkOption {
918 + description = "URL ${srv}.sr.ht is being served at (protocol://domain)";
920 + default = "https://${srv}.${domain}";
921 + defaultText = "https://${srv}.example.com";
923 + debug-host = mkOption {
924 + description = "Address to bind the debug server to.";
925 + type = with types; nullOr str;
928 + debug-port = mkOption {
929 + description = "Port to bind the debug server to.";
930 + type = with types; nullOr str;
933 + connection-string = mkOption {
934 + description = "SQLAlchemy connection string for the database.";
936 + default = "postgresql:///localhost?user=${srv}srht&host=/run/postgresql";
938 + migrate-on-upgrade = mkEnableOption "automatic migrations on package upgrade" // { default = true; };
939 + oauth-client-id = mkOption {
940 + description = "${srv}.sr.ht's OAuth client id for meta.sr.ht.";
943 + oauth-client-secret = mkOption {
944 + description = "${srv}.sr.ht's OAuth client secret for meta.sr.ht.";
946 + apply = s: "<" + toString s;
950 # Specialized python containing all the modules
951 python = pkgs.sourcehut.python.withPackages (ps: with ps; [
954 + # For monitoring Celery: sudo -u listssrht celery --app listssrht.process -b redis+socket:///run/redis-sourcehut/redis.sock?virtual_host=5 flower
959 @@ -19,69 +95,37 @@ let
963 + # Not a python package
968 + mkOptionNullOrStr = description: mkOption {
969 + inherit description;
970 + type = with types; nullOr str;
987 - (mkRemovedOptionModule [ "services" "sourcehut" "nginx" "enable" ] ''
988 - The sourcehut module supports `nginx` as a local reverse-proxy by default and doesn't
989 - support other reverse-proxies officially.
991 - However it's possible to use an alternative reverse-proxy by
994 - * adjusting the relevant settings for server addresses and ports directly
996 - Further details about this can be found in the `Sourcehut`-section of the NixOS-manual.
1000 options.services.sourcehut = {
1001 - enable = mkOption {
1002 - type = types.bool;
1005 - Enable sourcehut - git hosting, continuous integration, mailing list, ticket tracking,
1006 - task dispatching, wiki and account management services
1009 + enable = mkEnableOption ''
1010 + sourcehut - git hosting, continuous integration, mailing list, ticket tracking,
1011 + task dispatching, wiki and account management services
1014 services = mkOption {
1015 - type = types.nonEmptyListOf (types.enum [ "builds" "dispatch" "git" "hub" "hg" "lists" "man" "meta" "paste" "todo" ]);
1016 - default = [ "man" "meta" "paste" ];
1017 - example = [ "builds" "dispatch" "git" "hub" "hg" "lists" "man" "meta" "paste" "todo" ];
1018 + type = with types; listOf (enum
1019 + [ "builds" "dispatch" "git" "hg" "hub" "lists" "man" "meta" "pages" "paste" "todo" ]);
1020 + defaultText = "locally enabled services";
1022 - Services to enable on the sourcehut network.
1023 + Services that may be displayed as links in the title bar of the Web interface.
1027 - originBase = mkOption {
1028 + listenAddress = mkOption {
1030 - default = with config.networking; hostName + lib.optionalString (domain != null) ".${domain}";
1032 - Host name used by reverse-proxy and for default settings. Will host services at git."''${originBase}". For example: git.sr.ht
1036 - address = mkOption {
1038 - default = "127.0.0.1";
1040 - Address to bind to.
1042 + default = "localhost";
1043 + description = "Address to bind to.";
1047 @@ -94,105 +138,1222 @@ in
1051 - statePath = mkOption {
1052 - type = types.path;
1053 - default = "/var/lib/sourcehut";
1055 - Root state path for the sourcehut network. If left as the default value
1056 - this directory will automatically be created before the sourcehut server
1057 - starts, otherwise the sysadmin is responsible for ensuring the
1058 - directory exists with appropriate ownership and permissions.
1061 + enable = mkEnableOption ''local minio integration'';
1065 + enable = mkEnableOption ''local nginx integration'';
1066 + virtualHost = mkOption {
1067 + type = types.attrs;
1069 + description = "Virtual-host configuration merged with all Sourcehut's virtual-hosts.";
1074 + enable = mkEnableOption ''local postfix integration'';
1078 + enable = mkEnableOption ''local postgresql integration'';
1082 + enable = mkEnableOption ''local redis integration in a dedicated redis-server'';
1085 settings = mkOption {
1086 type = lib.types.submodule {
1087 freeformType = settingsFormat.type;
1088 + options."sr.ht" = {
1089 + global-domain = mkOption {
1090 + description = "Global domain name.";
1092 + example = "example.com";
1094 + environment = mkOption {
1095 + description = "Values other than \"production\" adds a banner to each page.";
1096 + type = types.enum [ "development" "production" ];
1097 + default = "development";
1099 + network-key = mkOption {
1101 + An absolute file path (which should be outside the Nix-store)
1102 + to a secret key to encrypt internal messages with. Use <code>srht-keygen network</code> to
1103 + generate this key. It must be consistent between all services and nodes.
1105 + type = types.path;
1106 + apply = s: "<" + toString s;
1108 + owner-email = mkOption {
1109 + description = "Owner's email.";
1111 + default = "contact@example.com";
1113 + owner-name = mkOption {
1114 + description = "Owner's name.";
1116 + default = "John Doe";
1118 + site-blurb = mkOption {
1119 + description = "Blurb for your site.";
1121 + default = "the hacker's forge";
1123 + site-info = mkOption {
1124 + description = "The top-level info page for your site.";
1126 + default = "https://sourcehut.org";
1128 + service-key = mkOption {
1130 + An absolute file path (which should be outside the Nix-store)
1131 + to a key used for encrypting session cookies. Use <code>srht-keygen service</code> to
1132 + generate the service key. This must be shared between each node of the same
1133 + service (e.g. git1.sr.ht and git2.sr.ht), but different services may use
1134 + different keys. If you configure all of your services with the same
1135 + config.ini, you may use the same service-key for all of them.
1137 + type = types.path;
1138 + apply = s: "<" + toString s;
1140 + site-name = mkOption {
1141 + description = "The name of your network of sr.ht-based sites.";
1143 + default = "sourcehut";
1145 + source-url = mkOption {
1146 + description = "The source code for your fork of sr.ht.";
1148 + default = "https://git.sr.ht/~sircmpwn/srht";
1152 + smtp-host = mkOptionNullOrStr "Outgoing SMTP host.";
1153 + smtp-port = mkOption {
1154 + description = "Outgoing SMTP port.";
1155 + type = with types; nullOr port;
1158 + smtp-user = mkOptionNullOrStr "Outgoing SMTP user.";
1159 + smtp-password = mkOptionNullOrStr "Outgoing SMTP password.";
1160 + smtp-from = mkOptionNullOrStr "Outgoing SMTP FROM.";
1161 + error-to = mkOptionNullOrStr "Address receiving application exceptions";
1162 + error-from = mkOptionNullOrStr "Address sending application exceptions";
1163 + pgp-privkey = mkOptionNullOrStr ''
1164 + An absolute file path (which should be outside the Nix-store)
1165 + to an OpenPGP private key.
1167 + Your PGP key information (DO NOT mix up pub and priv here)
1168 + You must remove the password from your secret key, if present.
1169 + You can do this with <code>gpg --edit-key [key-id]</code>,
1170 + then use the <code>passwd</code> command and do not enter a new password.
1172 + pgp-pubkey = mkOptionNullOrStr "OpenPGP public key.";
1173 + pgp-key-id = mkOptionNullOrStr "OpenPGP key identifier.";
1175 + options.objects = {
1176 + s3-upstream = mkOption {
1177 + description = "Configure the S3-compatible object storage service.";
1178 + type = with types; nullOr str;
1181 + s3-access-key = mkOption {
1182 + description = "Access key to the S3-compatible object storage service";
1183 + type = with types; nullOr str;
1186 + s3-secret-key = mkOption {
1188 + An absolute file path (which should be outside the Nix-store)
1189 + to the secret key of the S3-compatible object storage service.
1191 + type = with types; nullOr path;
1193 + apply = mapNullable (s: "<" + toString s);
1196 + options.webhooks = {
1197 + private-key = mkOption {
1199 + An absolute file path (which should be outside the Nix-store)
1200 + to a base64-encoded Ed25519 key for signing webhook payloads.
1201 + This should be consistent for all *.sr.ht sites,
1202 + as this key will be used to verify signatures
1203 + from other sites in your network.
1204 + Use the <code>srht-keygen webhook</code> command to generate a key.
1206 + type = types.path;
1207 + apply = s: "<" + toString s;
1211 + options."dispatch.sr.ht" = commonServiceSettings "dispatch" // {
1213 + options."dispatch.sr.ht::github" = {
1214 + oauth-client-id = mkOptionNullOrStr "OAuth client id.";
1215 + oauth-client-secret = mkOptionNullOrStr "OAuth client secret.";
1217 + options."dispatch.sr.ht::gitlab" = {
1218 + enabled = mkEnableOption "GitLab integration";
1219 + canonical-upstream = mkOption {
1221 + description = "Canonical upstream.";
1222 + default = "gitlab.com";
1224 + repo-cache = mkOption {
1226 + description = "Repository cache directory.";
1227 + default = "./repo-cache";
1229 + "gitlab.com" = mkOption {
1230 + type = with types; nullOr str;
1231 + description = "GitLab id and secret.";
1233 + example = "GitLab:application id:secret";
1237 + options."builds.sr.ht" = commonServiceSettings "builds" // {
1238 + allow-free = mkEnableOption "nonpaying users to submit builds";
1239 + redis = mkOption {
1240 + description = "The Redis connection used for the Celery worker.";
1242 + default = "unix+socket:/run/redis-sourcehut-buildsrht/redis.sock?virtual_host=2";
1244 + shell = mkOption {
1246 + Scripts used to launch on SSH connection.
1247 + <literal>/usr/bin/master-shell</literal> on master,
1248 + <literal>/usr/bin/runner-shell</literal> on runner.
1249 + If master and worker are on the same system
1250 + set to <literal>/usr/bin/runner-shell</literal>.
1252 + type = types.enum ["/usr/bin/master-shell" "/usr/bin/runner-shell"];
1253 + default = "/usr/bin/master-shell";
1256 + options."builds.sr.ht::worker" = {
1257 + bind-address = mkOption {
1259 + HTTP bind address for serving local build information/monitoring.
1262 + default = "localhost:8080";
1264 + buildlogs = mkOption {
1265 + description = "Path to write build logs.";
1267 + default = "/var/log/sourcehut/buildsrht";
1271 + Listening address and listening port
1272 + of the build runner (with HTTP port if not 80).
1275 + default = "localhost:5020";
1277 + timeout = mkOption {
1279 + Max build duration.
1280 + See <link xlink:href="https://golang.org/pkg/time/#ParseDuration"/>.
1287 + options."git.sr.ht" = commonServiceSettings "git" // {
1288 + outgoing-domain = mkOption {
1289 + description = "Outgoing domain.";
1291 + default = "https://git.localhost.localdomain";
1293 + post-update-script = mkOption {
1295 + A post-update script which is installed in every git repo.
1296 + This setting is propagated to newer and existing repositories.
1298 + type = types.path;
1299 + default = "${pkgs.sourcehut.gitsrht}/bin/gitsrht-update-hook";
1300 + defaultText = "\${pkgs.sourcehut.gitsrht}/bin/gitsrht-update-hook";
1301 + # Git hooks are run relative to their repository's directory,
1302 + # but gitsrht-update-hook looks up ../config.ini
1303 + apply = p: pkgs.writeShellScript "update-hook-wrapper" ''
1304 + test -e "''${PWD%/*}"/config.ini ||
1305 + ln -s ${users."sshsrht".home}/../config.ini "''${PWD%/*}"/config.ini
1306 + exec -a "$0" '${p}' "$@"
1309 + repos = mkOption {
1311 + Path to git repositories on disk.
1312 + If changing the default, you must ensure that
1313 + the gitsrht's user as read and write access to it.
1316 + default = "/var/lib/sourcehut/gitsrht/repos";
1318 + webhooks = mkOption {
1319 + description = "The Redis connection used for the webhooks worker.";
1321 + default = "unix+socket:/run/redis-sourcehut-gitsrht/redis.sock?virtual_host=1";
1324 + options."git.sr.ht::api" = {
1325 + internal-ipnet = mkOption {
1327 + Set of IP subnets which are permitted to utilize internal API
1328 + authentication. This should be limited to the subnets
1329 + from which your *.sr.ht services are running.
1330 + See <xref linkend="opt-services.sourcehut.listenAddress"/>.
1332 + type = with types; listOf str;
1333 + default = [ "127.0.0.0/8" "::1/128" ];
1337 + options."hg.sr.ht" = commonServiceSettings "hg" // {
1338 + changegroup-script = mkOption {
1340 + A changegroup script which is installed in every mercurial repo.
1341 + This setting is propagated to newer and existing repositories.
1344 + default = "${cfg.python}/bin/hgsrht-hook-changegroup";
1345 + defaultText = "\${cfg.python}/bin/hgsrht-hook-changegroup";
1346 + # Mercurial's changegroup hooks are run relative to their repository's directory,
1347 + # but hgsrht-hook-changegroup looks up ./config.ini
1348 + apply = p: pkgs.writeShellScript "hook-changegroup-wrapper" ''
1349 + test -e "''$PWD"/config.ini ||
1350 + ln -s ${users."sshsrht".home}/../config.ini "''$PWD"/config.ini
1351 + exec -a "$0" '${p}' "$@"
1354 + repos = mkOption {
1356 + Path to mercurial repositories on disk.
1357 + If changing the default, you must ensure that
1358 + the hgsrht's user as read and write access to it.
1361 + default = "/var/lib/sourcehut/hgsrht/repos";
1363 + srhtext = mkOptionNullOrStr ''
1364 + Path to the srht mercurial extension
1365 + (defaults to where the hgsrht code is)
1367 + clone_bundle_threshold = mkOption {
1368 + description = ".hg/store size (in MB) past which the nightly job generates clone bundles.";
1369 + type = types.ints.unsigned;
1372 + hg_ssh = mkOption {
1373 + description = "Path to hg-ssh (if not in $PATH).";
1375 + default = "${pkgs.mercurial}/bin/hg-ssh";
1376 + defaultText = "\${pkgs.mercurial}/bin/hg-ssh";
1378 + webhooks = mkOption {
1379 + description = "The Redis connection used for the webhooks worker.";
1381 + default = "unix+socket:/run/redis-sourcehut-hgsrht/redis.sock?virtual_host=1";
1385 + options."hub.sr.ht" = commonServiceSettings "hub" // {
1388 + options."lists.sr.ht" = commonServiceSettings "lists" // {
1389 + allow-new-lists = mkEnableOption "Allow creation of new lists.";
1390 + notify-from = mkOption {
1391 + description = "Outgoing email for notifications generated by users.";
1393 + default = "lists-notify@localhost.localdomain";
1395 + posting-domain = mkOption {
1396 + description = "Posting domain.";
1398 + default = "lists.localhost.localdomain";
1400 + redis = mkOption {
1401 + description = "The Redis connection used for the Celery worker.";
1403 + default = "unix+socket:/run/redis-sourcehut-listssrht/redis.sock?virtual_host=2";
1405 + webhooks = mkOption {
1406 + description = "The Redis connection used for the webhooks worker.";
1408 + default = "unix+socket:/run/redis-sourcehut-listssrht/redis.sock?virtual_host=1";
1411 + options."lists.sr.ht::worker" = {
1412 + reject-mimetypes = mkOption {
1414 + Comma-delimited list of Content-Types to reject. Messages with Content-Types
1415 + included in this list are rejected. Multipart messages are always supported,
1416 + and each part is checked against this list.
1418 + Uses fnmatch for wildcard expansion.
1420 + type = with types; listOf str;
1421 + default = ["text/html"];
1423 + reject-url = mkOption {
1424 + description = "Reject URL.";
1426 + default = "https://man.sr.ht/lists.sr.ht/etiquette.md";
1430 + Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
1431 + Alternatively, specify IP:PORT and an SMTP server will be run instead.
1434 + default = "/tmp/lists.sr.ht-lmtp.sock";
1436 + sock-group = mkOption {
1438 + The lmtp daemon will make the unix socket group-read/write
1439 + for users in this group.
1442 + default = "postfix";
1446 + options."man.sr.ht" = commonServiceSettings "man" // {
1449 + options."meta.sr.ht" =
1450 + removeAttrs (commonServiceSettings "meta")
1451 + ["oauth-client-id" "oauth-client-secret"] // {
1452 + api-origin = mkOption {
1453 + description = "Origin URL for API, 100 more than web.";
1455 + default = "http://${cfg.listenAddress}:${toString (cfg.meta.port + 100)}";
1456 + defaultText = ''http://<xref linkend="opt-services.sourcehut.listenAddress"/>:''${toString (<xref linkend="opt-services.sourcehut.meta.port"/> + 100)}'';
1458 + webhooks = mkOption {
1459 + description = "The Redis connection used for the webhooks worker.";
1461 + default = "unix+socket:/run/redis-sourcehut-metasrht/redis.sock?virtual_host=1";
1463 + welcome-emails = mkEnableOption "sending stock sourcehut welcome emails after signup";
1465 + options."meta.sr.ht::api" = {
1466 + internal-ipnet = mkOption {
1468 + Set of IP subnets which are permitted to utilize internal API
1469 + authentication. This should be limited to the subnets
1470 + from which your *.sr.ht services are running.
1471 + See <xref linkend="opt-services.sourcehut.listenAddress"/>.
1473 + type = with types; listOf str;
1474 + default = [ "127.0.0.0/8" "::1/128" ];
1477 + options."meta.sr.ht::aliases" = mkOption {
1478 + description = "Aliases for the client IDs of commonly used OAuth clients.";
1479 + type = with types; attrsOf int;
1481 + example = { "git.sr.ht" = 12345; };
1483 + options."meta.sr.ht::billing" = {
1484 + enabled = mkEnableOption "the billing system";
1485 + stripe-public-key = mkOptionNullOrStr "Public key for Stripe. Get your keys at https://dashboard.stripe.com/account/apikeys";
1486 + stripe-secret-key = mkOptionNullOrStr ''
1487 + An absolute file path (which should be outside the Nix-store)
1488 + to a secret key for Stripe. Get your keys at https://dashboard.stripe.com/account/apikeys
1490 + apply = mapNullable (s: "<" + toString s);
1493 + options."meta.sr.ht::settings" = {
1494 + registration = mkEnableOption "public registration";
1495 + onboarding-redirect = mkOption {
1496 + description = "Where to redirect new users upon registration.";
1498 + default = "https://meta.localhost.localdomain";
1500 + user-invites = mkOption {
1502 + How many invites each user is issued upon registration
1503 + (only applicable if open registration is disabled).
1505 + type = types.ints.unsigned;
1510 + options."pages.sr.ht" = commonServiceSettings "pages" // {
1511 + gemini-certs = mkOption {
1513 + An absolute file path (which should be outside the Nix-store)
1514 + to Gemini certificates.
1516 + type = with types; nullOr path;
1519 + max-site-size = mkOption {
1520 + description = "Maximum size of any given site (post-gunzip), in MiB.";
1524 + user-domain = mkOption {
1526 + Configures the user domain, if enabled.
1527 + All users are given <username>.this.domain.
1529 + type = with types; nullOr str;
1533 + options."pages.sr.ht::api" = {
1534 + internal-ipnet = mkOption {
1536 + Set of IP subnets which are permitted to utilize internal API
1537 + authentication. This should be limited to the subnets
1538 + from which your *.sr.ht services are running.
1539 + See <xref linkend="opt-services.sourcehut.listenAddress"/>.
1541 + type = with types; listOf str;
1542 + default = [ "127.0.0.0/8" "::1/128" ];
1546 + options."paste.sr.ht" = commonServiceSettings "paste" // {
1549 + options."todo.sr.ht" = commonServiceSettings "todo" // {
1550 + notify-from = mkOption {
1551 + description = "Outgoing email for notifications generated by users.";
1553 + default = "todo-notify@localhost.localdomain";
1555 + webhooks = mkOption {
1556 + description = "The Redis connection used for the webhooks worker.";
1558 + default = "unix+socket:/run/redis-sourcehut-todosrht/redis.sock?virtual_host=1";
1561 + options."todo.sr.ht::mail" = {
1562 + posting-domain = mkOption {
1563 + description = "Posting domain.";
1565 + default = "todo.localhost.localdomain";
1569 + Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
1570 + Alternatively, specify IP:PORT and an SMTP server will be run instead.
1573 + default = "/tmp/todo.sr.ht-lmtp.sock";
1575 + sock-group = mkOption {
1577 + The lmtp daemon will make the unix socket group-read/write
1578 + for users in this group.
1581 + default = "postfix";
1587 The configuration for the sourcehut network.
1592 - config = mkIf cfg.enable {
1596 - assertion = with cfgIni.webhooks; private-key != null && stringLength private-key == 44;
1597 - message = "The webhook's private key must be defined and of a 44 byte length.";
1600 + enableWorker = mkEnableOption "worker for builds.sr.ht";
1603 - assertion = hasAttrByPath [ "meta.sr.ht" "origin" ] cfgIni && cfgIni."meta.sr.ht".origin != null;
1604 - message = "meta.sr.ht's origin must be defined.";
1607 + images = mkOption {
1608 + type = with types; attrsOf (attrsOf (attrsOf package));
1610 + example = lib.literalExample ''(let
1611 + # Pinning unstable to allow usage with flakes and limit rebuilds.
1612 + pkgs_unstable = builtins.fetchGit {
1613 + url = "https://github.com/NixOS/nixpkgs";
1614 + rev = "ff96a0fa5635770390b184ae74debea75c3fd534";
1615 + ref = "nixos-unstable";
1617 + image_from_nixpkgs = (import ("${pkgs.sourcehut.buildsrht}/lib/images/nixos/image.nix") {
1618 + pkgs = (import pkgs_unstable {});
1622 + nixos.unstable.x86_64 = image_from_nixpkgs;
1626 + Images for builds.sr.ht. Each package should be distro.release.arch and point to a /nix/store/package/root.img.qcow2.
1631 - virtualisation.docker.enable = true;
1632 - environment.etc."sr.ht/config.ini".source =
1633 - settingsFormat.generate "sourcehut-config.ini" (mapAttrsRecursive
1635 - path: v: if v == null then "" else v
1639 + package = mkOption {
1640 + type = types.package;
1641 + default = pkgs.git;
1642 + example = literalExample "pkgs.gitFull";
1644 + Git package for git.sr.ht. This can help silence collisions.
1647 + fcgiwrap.preforkProcess = mkOption {
1648 + description = "Number of fcgiwrap processes to prefork.";
1654 - environment.systemPackages = [ pkgs.sourcehut.coresrht ];
1656 + package = mkOption {
1657 + type = types.package;
1658 + default = pkgs.mercurial;
1660 + Mercurial package for hg.sr.ht. This can help silence collisions.
1663 + cloneBundles = mkOption {
1664 + type = types.bool;
1667 + Generate clonebundles (which require more disk space but dramatically speed up cloning large repositories).
1672 - # PostgreSQL server
1673 - services.postgresql.enable = mkOverride 999 true;
1675 - services.postfix.enable = mkOverride 999 true;
1677 - services.cron.enable = mkOverride 999 true;
1679 - services.redis.enable = mkOverride 999 true;
1680 - services.redis.bind = mkOverride 999 "127.0.0.1";
1682 - services.sourcehut.settings = {
1683 - # The name of your network of sr.ht-based sites
1684 - "sr.ht".site-name = mkDefault "sourcehut";
1685 - # The top-level info page for your site
1686 - "sr.ht".site-info = mkDefault "https://sourcehut.org";
1687 - # {{ site-name }}, {{ site-blurb }}
1688 - "sr.ht".site-blurb = mkDefault "the hacker's forge";
1689 - # If this != production, we add a banner to each page
1690 - "sr.ht".environment = mkDefault "development";
1691 - # Contact information for the site owners
1692 - "sr.ht".owner-name = mkDefault "Drew DeVault";
1693 - "sr.ht".owner-email = mkDefault "sir@cmpwn.com";
1694 - # The source code for your fork of sr.ht
1695 - "sr.ht".source-url = mkDefault "https://git.sr.ht/~sircmpwn/srht";
1696 - # A secret key to encrypt session cookies with
1697 - "sr.ht".secret-key = mkDefault null;
1698 - "sr.ht".global-domain = mkDefault null;
1700 - # Outgoing SMTP settings
1701 - mail.smtp-host = mkDefault null;
1702 - mail.smtp-port = mkDefault null;
1703 - mail.smtp-user = mkDefault null;
1704 - mail.smtp-password = mkDefault null;
1705 - mail.smtp-from = mkDefault null;
1706 - # Application exceptions are emailed to this address
1707 - mail.error-to = mkDefault null;
1708 - mail.error-from = mkDefault null;
1709 - # Your PGP key information (DO NOT mix up pub and priv here)
1710 - # You must remove the password from your secret key, if present.
1711 - # You can do this with gpg --edit-key [key-id], then use the passwd
1712 - # command and do not enter a new password.
1713 - mail.pgp-privkey = mkDefault null;
1714 - mail.pgp-pubkey = mkDefault null;
1715 - mail.pgp-key-id = mkDefault null;
1717 - # base64-encoded Ed25519 key for signing webhook payloads. This should be
1718 - # consistent for all *.sr.ht sites, as we'll use this key to verify signatures
1719 - # from other sites in your network.
1721 - # Use the srht-webhook-keygen command to generate a key.
1722 - webhooks.private-key = mkDefault null;
1725 + extraArgs = mkOption {
1726 + type = with types; listOf str;
1727 + default = [ "--loglevel DEBUG" "--pool eventlet" "--without-heartbeat" ];
1728 + description = "Extra arguments passed to the Celery responsible for processing mails.";
1730 + celeryConfig = mkOption {
1731 + type = types.lines;
1733 + description = "Content of the <literal>celeryconfig.py</literal> used by the Celery of <literal>listssrht-process</literal>.";
1739 + config = mkIf cfg.enable (mkMerge [
1741 + environment.systemPackages = [ pkgs.sourcehut.coresrht ];
1743 + services.sourcehut.settings = {
1744 + "git.sr.ht".outgoing-domain = mkDefault "https://git.${domain}";
1745 + "lists.sr.ht".notify-from = mkDefault "lists-notify@${domain}";
1746 + "lists.sr.ht".posting-domain = mkDefault "lists.${domain}";
1747 + "meta.sr.ht::settings".onboarding-redirect = mkDefault "https://meta.${domain}";
1748 + "todo.sr.ht".notify-from = mkDefault "todo-notify@${domain}";
1749 + "todo.sr.ht::mail".posting-domain = mkDefault "todo.${domain}";
1752 + (mkIf cfg.postgresql.enable {
1754 + { assertion = postgresql.enable;
1755 + message = "postgresql must be enabled and configured";
1759 + (mkIf cfg.postfix.enable {
1761 + { assertion = postfix.enable;
1762 + message = "postfix must be enabled and configured";
1765 + # Needed for sharing the LMTP sockets with JoinsNamespaceOf=
1766 + systemd.services.postfix.serviceConfig.PrivateTmp = true;
1768 + (mkIf cfg.redis.enable {
1769 + services.redis.vmOverCommit = mkDefault true;
1771 + (mkIf cfg.nginx.enable {
1773 + { assertion = nginx.enable;
1774 + message = "nginx must be enabled and configured";
1777 + # For proxyPass= in virtual-hosts for Sourcehut services.
1778 + services.nginx.recommendedProxySettings = mkDefault true;
1780 + (mkIf (cfg.builds.enable || cfg.git.enable || cfg.hg.enable) {
1781 + services.openssh = {
1782 + # Note that sshd will continue to honor AuthorizedKeysFile
1783 + # sshsrht-dispatch needs to read ${users."sshsrht".home}/../config.ini,
1784 + # Note that you may want automatically rotate
1785 + # or link to /dev/null the following log files:
1786 + # - /var/log/gitsrht-dispatch
1787 + # - /var/log/{build,git,hg}srht-keys
1788 + # - /var/log/{git,hg}srht-shell
1789 + # - /var/log/gitsrht-update-hook
1790 + authorizedKeysCommand = ''/etc/ssh/srht-dispatch "%u" "%h" "%t" "%k"'';
1791 + # srht-dispatch will setuid/setgid according to [git.sr.ht::dispatch]
1792 + authorizedKeysCommandUser = "root";
1794 + PermitUserEnvironment SRHT_*
1797 + environment.etc."ssh/srht-dispatch" = {
1798 + # sshd_config(5): The program must be owned by root, not writable by group or others
1800 + source = pkgs.writeShellScript "srht-dispatch" ''
1802 + cd ${users."sshsrht".home}
1803 + ${cfg.python}/bin/gitsrht-dispatch "$@"
1806 + systemd.services.sshd = let
1807 + # TODO: use a filtered config.ini containing only [git.sr.ht::dispatch]
1808 + configIni = settingsFormat.generate "sourcehut-dispatch-config.ini"
1809 + # Each service needs access to only a subset of sections (and secrets).
1810 + (filterAttrs (k: v: k == "git.sr.ht::dispatch")
1813 + #path = optional cfg.git.enable [ cfg.git.package ];
1814 + restartTriggers = [ configIni ];
1816 + RuntimeDirectory = [ "sourcehut/sshsrht/subdir" ];
1817 + BindReadOnlyPaths =
1818 + # Note that those /usr/bin/* paths are hardcoded in multiple places in *.sr.ht,
1819 + # for instance to get the user from the [git.sr.ht::dispatch] settings.
1820 + # *srht-keys needs to:
1821 + # - access a redis-server in [sr.ht] redis-host,
1822 + # - access the PostgreSQL server in [*.sr.ht] connection-string,
1823 + # - query metasrht-api (through the HTTP API).
1824 + optionals cfg.builds.enable [
1825 + "${pkgs.writeShellScript "buildsrht-keys-wrapper" ''
1827 + cd /run/sourcehut/buildsrht/subdir
1828 + exec ${pkgs.sourcehut.buildsrht}/bin/buildsrht-keys "$@"
1829 + ''}:/usr/bin/buildsrht-keys"
1830 + "${pkgs.sourcehut.buildsrht}/bin/master-shell:/usr/bin/master-shell"
1831 + "${pkgs.sourcehut.buildsrht}/bin/runner-shell:/usr/bin/runner-shell"
1833 + optionals cfg.git.enable [
1834 + "${pkgs.writeShellScript "gitsrht-keys-wrapper" ''
1836 + cd /run/sourcehut/gitsrht/subdir
1837 + exec ${pkgs.sourcehut.gitsrht}/bin/gitsrht-keys "$@"
1838 + ''}:/usr/bin/gitsrht-keys"
1839 + "${pkgs.sourcehut.gitsrht}/bin/gitsrht-shell:/usr/bin/gitsrht-shell"
1841 + optionals cfg.hg.enable [
1842 + "${pkgs.writeShellScript "hgsrht-keys-wrapper" ''
1844 + cd /run/sourcehut/hgsrht/subdir
1845 + exec ${pkgs.sourcehut.hgsrht}/bin/hgsrht-keys "$@"
1846 + ''}:/usr/bin/hgsrht-keys"
1847 + "${pkgs.sourcehut.hgsrht}/bin/hgsrht-shell:/usr/bin/hgsrht-shell"
1849 + ExecStartPre = mkBefore [("+"+pkgs.writeShellScript "sshsrht-credentials" ''
1850 + # Replace values begining with a '<' by the content of the file whose name is after.
1851 + ${pkgs.gawk}/bin/gawk '{ if (match($0,/^([^=]+=)<(.+)/,m)) { getline f < m[2]; print m[1] f } else print $0 }' ${configIni} |
1852 + install -o ${users."sshsrht".name} -g ${groups."sshsrht".name} -m 440 \
1853 + /dev/stdin ${users."sshsrht".home}/../config.ini
1858 + users."sshsrht" = {
1859 + isSystemUser = true;
1860 + # srht-dispatch, *srht-keys, and *srht-shell
1861 + # look up in ../config.ini from this directory;
1862 + # that config.ini being set in *srht.service's ExecStartPre=
1863 + home = "/run/sourcehut/sshsrht/subdir";
1864 + group = groups.nogroup.name;
1865 + description = "sourcehut user for sshd's AuthorizedKeysCommandUser";
1867 + groups."sshsrht" = {};
1874 + (import ./service.nix "builds" {
1875 + inherit configIniOfService;
1876 + srvsrht = "buildsrht";
1878 + # TODO: a celery worker on the master and worker are apparently needed
1879 + extraServices.buildsrht-worker = let
1880 + qemuPackage = pkgs.qemu_kvm;
1881 + serviceName = "buildsrht-worker";
1882 + statePath = "/var/lib/sourcehut/${serviceName}";
1883 + in mkIf cfg.builds.enableWorker {
1884 + path = [ pkgs.openssh pkgs.docker ];
1887 + if test -z "$(docker images -q qemu:latest 2>/dev/null)" \
1888 + || test "$(cat ${statePath}/docker-image-qemu)" != "${qemuPackage.version}"
1890 + # Create and import qemu:latest image for docker
1891 + ${pkgs.dockerTools.streamLayeredImage {
1894 + contents = [ qemuPackage ];
1896 + # Mark down current package version
1897 + echo '${qemuPackage.version}' >${statePath}/docker-image-qemu
1901 + ExecStart = "${pkgs.sourcehut.buildsrht}/bin/builds.sr.ht-worker";
1902 + RuntimeDirectory = [ "sourcehut/${serviceName}/subdir" ];
1903 + # builds.sr.ht-worker looks up ../config.ini
1904 + LogsDirectory = [ "sourcehut/${serviceName}" ];
1905 + StateDirectory = [ "sourcehut/${serviceName}" ];
1906 + WorkingDirectory = "-"+"/run/sourcehut/${serviceName}/subdir";
1910 + image_dirs = flatten (
1911 + mapAttrsToList (distro: revs:
1912 + mapAttrsToList (rev: archs:
1913 + mapAttrsToList (arch: image:
1914 + pkgs.runCommand "buildsrht-images" { } ''
1915 + mkdir -p $out/${distro}/${rev}/${arch}
1916 + ln -s ${image}/*.qcow2 $out/${distro}/${rev}/${arch}/root.img.qcow2
1920 + ) cfg.builds.images
1922 + image_dir_pre = pkgs.symlinkJoin {
1923 + name = "builds.sr.ht-worker-images-pre";
1924 + paths = image_dirs;
1925 + # FIXME: not working, apparently because ubuntu/latest is a broken link
1926 + # ++ [ "${pkgs.sourcehut.buildsrht}/lib/images" ];
1928 + image_dir = pkgs.runCommand "builds.sr.ht-worker-images" { } ''
1929 + mkdir -p $out/images
1930 + cp -Lr ${image_dir_pre}/* $out/images
1934 + users.users.${cfg.builds.user} = {
1935 + shell = pkgs.bash;
1936 + # Allow reading of ${users."sshsrht".home}/../config.ini
1937 + extraGroups = [ groups."sshsrht".name ];
1940 + virtualisation.docker.enable = true;
1942 + services.sourcehut.settings = mkMerge [
1943 + { # Note that git.sr.ht::dispatch is not a typo,
1944 + # gitsrht-dispatch always use this section
1945 + "git.sr.ht::dispatch"."/usr/bin/buildsrht-keys" =
1946 + mkDefault "${cfg.builds.user}:${cfg.builds.group}";
1948 + (mkIf cfg.builds.enableWorker {
1949 + "builds.sr.ht::worker".shell = "/usr/bin/runner-shell";
1950 + "builds.sr.ht::worker".images = mkDefault "${image_dir}/images";
1951 + "builds.sr.ht::worker".controlcmd = mkDefault "${image_dir}/images/control";
1955 + (mkIf cfg.builds.enableWorker {
1957 + docker.members = [ cfg.builds.user ];
1960 + (mkIf (cfg.builds.enableWorker && cfg.nginx.enable) {
1961 + # Allow nginx access to buildlogs
1962 + users.users.${nginx.user}.extraGroups = [ cfg.builds.group ];
1963 + systemd.services.nginx = {
1964 + serviceConfig.BindReadOnlyPaths = [ "${cfg.settings."builds.sr.ht::worker".buildlogs}:/var/log/nginx/buildsrht/logs" ];
1966 + services.nginx.virtualHosts."logs.${domain}" = mkMerge [ {
1967 + /* FIXME: is a listen needed?
1968 + listen = with builtins;
1969 + # FIXME: not compatible with IPv6
1970 + let address = split ":" cfg.settings."builds.sr.ht::worker".name; in
1971 + [{ addr = elemAt address 0; port = lib.toInt (elemAt address 2); }];
1973 + locations."/logs/".alias = "/var/log/nginx/buildsrht/logs/";
1974 + } cfg.nginx.virtualHost ];
1979 + (import ./service.nix "dispatch" {
1980 + inherit configIniOfService;
1984 + (import ./service.nix "git" (let
1986 + path = [ cfg.git.package ];
1987 + serviceConfig.BindPaths = [ "${cfg.settings."git.sr.ht".repos}:/var/lib/sourcehut/gitsrht/repos" ];
1988 + serviceConfig.BindReadOnlyPaths = [ "${cfg.settings."git.sr.ht".post-update-script}:/var/lib/sourcehut/gitsrht/bin/post-update-script" ];
1991 + inherit configIniOfService;
1992 + mainService = mkMerge [ baseService {
1993 + serviceConfig.StateDirectory = [ "sourcehut/gitsrht" "sourcehut/gitsrht/repos" ];
1997 + extraTimers.gitsrht-periodic = {
1998 + service = baseService;
1999 + timerConfig.OnCalendar = ["20min"];
2001 + extraConfig = mkMerge [
2003 + users.users.${cfg.git.user} = {
2004 + # https://stackoverflow.com/questions/22314298/git-push-results-in-fatal-protocol-error-bad-line-length-character-this
2005 + # Probably could use gitsrht-shell if output is restricted to just parameters...
2006 + shell = pkgs.bash;
2007 + # Allow reading of ${users."sshsrht".home}/../config.ini
2008 + extraGroups = [ groups."sshsrht".name ];
2009 + home = users.sshsrht.home;
2011 + services.sourcehut.settings = {
2012 + "git.sr.ht::dispatch"."/usr/bin/gitsrht-keys" =
2013 + mkDefault "${cfg.git.user}:${cfg.git.group}";
2015 + systemd.services.sshd = baseService;
2017 + (mkIf cfg.nginx.enable {
2018 + services.nginx.virtualHosts."git.${domain}" = {
2019 + locations."/authorize" = {
2020 + proxyPass = "http://${cfg.listenAddress}:${toString cfg.git.port}";
2022 + proxy_pass_request_body off;
2023 + proxy_set_header Content-Length "";
2024 + proxy_set_header X-Original-URI $request_uri;
2027 + locations."~ ^/([^/]+)/([^/]+)/(HEAD|info/refs|objects/info/.*|git-upload-pack).*$" = {
2028 + root = "/var/lib/sourcehut/gitsrht/repos";
2030 + GIT_HTTP_EXPORT_ALL = "";
2031 + GIT_PROJECT_ROOT = "$document_root";
2032 + PATH_INFO = "$uri";
2033 + SCRIPT_FILENAME = "${cfg.git.package}/bin/git-http-backend";
2036 + auth_request /authorize;
2037 + fastcgi_read_timeout 500s;
2038 + fastcgi_pass unix:/run/gitsrht-fcgiwrap.sock;
2043 + systemd.sockets.gitsrht-fcgiwrap = {
2044 + before = [ "nginx.service" ];
2045 + wantedBy = [ "sockets.target" "gitsrht.service" ];
2046 + # This path remains accessible to nginx.service, which has no RootDirectory=
2047 + socketConfig.ListenStream = "/run/gitsrht-fcgiwrap.sock";
2048 + socketConfig.SocketUser = nginx.user;
2049 + socketConfig.SocketMode = "600";
2053 + extraServices.gitsrht-fcgiwrap = mkIf cfg.nginx.enable {
2055 + # Socket is passed by gitsrht-fcgiwrap.socket
2056 + ExecStart = "${pkgs.fcgiwrap}/sbin/fcgiwrap -c ${toString cfg.git.fcgiwrap.preforkProcess}";
2057 + # No need for config.ini
2058 + ExecStartPre = mkForce [];
2060 + DynamicUser = true;
2061 + BindReadOnlyPaths = [ "${cfg.settings."git.sr.ht".repos}:/var/lib/sourcehut/gitsrht/repos" ];
2062 + IPAddressDeny = "any";
2063 + InaccessiblePaths = [ "-+/run/postgresql" "-+/run/redis-sourcehut" ];
2064 + PrivateNetwork = true;
2065 + RestrictAddressFamilies = mkForce [ "none" ];
2066 + SystemCallFilter = mkForce [
2068 + "~@aio" "~@keyring" "~@memlock" "~@privileged" "~@resources" "~@setuid"
2069 + # @timer is needed for alarm()
2075 + (import ./service.nix "hg" (let
2077 + path = [ cfg.hg.package ];
2078 + serviceConfig.BindPaths = [ "${cfg.settings."hg.sr.ht".repos}:/var/lib/sourcehut/hgsrht/repos" ];
2079 + serviceConfig.BindReadOnlyPaths = [ "${cfg.settings."ht.sr.ht".changegroup-script}:/var/lib/sourcehut/hgsrht/bin/changegroup-script" ];
2082 + inherit configIniOfService;
2083 + mainService = mkMerge [ baseService {
2084 + serviceConfig.StateDirectory = [ "sourcehut/hgsrht" "sourcehut/hgsrht/repos" ];
2088 + extraTimers.hgsrht-periodic = {
2089 + service = baseService;
2090 + timerConfig.OnCalendar = ["20min"];
2092 + extraTimers.hgsrht-clonebundles = mkIf cfg.hg.cloneBundles {
2093 + service = baseService;
2094 + timerConfig.OnCalendar = ["daily"];
2095 + timerConfig.AccuracySec = "1h";
2097 + extraConfig = mkMerge [
2099 + users.users.${cfg.hg.user} = {
2100 + shell = pkgs.bash;
2101 + # Allow reading of ${users."sshsrht".home}/../config.ini
2102 + extraGroups = [ groups."sshsrht".name ];
2104 + services.sourcehut.settings = {
2105 + # Note that git.sr.ht::dispatch is not a typo,
2106 + # gitsrht-dispatch always uses this section.
2107 + "git.sr.ht::dispatch"."/usr/bin/hgsrht-keys" =
2108 + mkDefault "${cfg.hg.user}:${cfg.hg.group}";
2110 + systemd.services.sshd = baseService;
2112 + (mkIf cfg.nginx.enable {
2113 + # Allow nginx access to repositories
2114 + users.users.${nginx.user}.extraGroups = [ cfg.hg.group ];
2115 + services.nginx.virtualHosts."hg.${domain}" = {
2116 + locations."/authorize" = {
2117 + proxyPass = "http://${cfg.listenAddress}:${toString cfg.hg.port}";
2119 + proxy_pass_request_body off;
2120 + proxy_set_header Content-Length "";
2121 + proxy_set_header X-Original-URI $request_uri;
2124 + # Let clients reach pull bundles. We don't really need to lock this down even for
2125 + # private repos because the bundles are named after the revision hashes...
2126 + # so someone would need to know or guess a SHA value to download anything.
2127 + # TODO: proxyPass to an hg serve service?
2128 + locations."~ ^/[~^][a-z0-9_]+/[a-zA-Z0-9_.-]+/\\.hg/bundles/.*$" = {
2129 + root = "/var/lib/nginx/hgsrht/repos";
2131 + auth_request /authorize;
2136 + systemd.services.nginx = {
2137 + serviceConfig.BindReadOnlyPaths = [ "${cfg.settings."hg.sr.ht".repos}:/var/lib/nginx/hgsrht/repos" ];
2143 + (import ./service.nix "hub" {
2144 + inherit configIniOfService;
2147 + services.nginx = mkIf cfg.nginx.enable {
2148 + virtualHosts."hub.${domain}" = mkMerge [ {
2149 + serverAliases = [ domain ];
2150 + } cfg.nginx.virtualHost ];
2155 + (import ./service.nix "lists" (let
2156 + srvsrht = "listssrht";
2158 + inherit configIniOfService;
2161 + # Receive the mail from Postfix and enqueue them into Redis and PostgreSQL
2162 + extraServices.listssrht-lmtp = {
2163 + wants = [ "postfix.service" ];
2164 + unitConfig.JoinsNamespaceOf = optional cfg.postfix.enable "postfix.service";
2165 + serviceConfig.ExecStart = "${cfg.python}/bin/listssrht-lmtp";
2166 + # Avoid crashing: os.chown(sock, os.getuid(), sock_gid)
2167 + serviceConfig.PrivateUsers = mkForce false;
2169 + # Dequeue the mails from Redis and dispatch them
2170 + extraServices.listssrht-process = {
2173 + cp ${pkgs.writeText "${srvsrht}-webhooks-celeryconfig.py" cfg.lists.process.celeryConfig} \
2174 + /run/sourcehut/${srvsrht}-webhooks/celeryconfig.py
2176 + ExecStart = "${cfg.python}/bin/celery --app listssrht.process worker --hostname listssrht-process@%%h " + concatStringsSep " " cfg.lists.process.extraArgs;
2177 + # Avoid crashing: os.getloadavg()
2178 + ProcSubset = mkForce "all";
2181 + extraConfig = mkIf cfg.postfix.enable {
2182 + users.groups.${postfix.group}.members = [ cfg.lists.user ];
2183 + services.sourcehut.settings."lists.sr.ht::mail".sock-group = postfix.group;
2184 + services.postfix = {
2185 + destination = [ "lists.${domain}" ];
2186 + # FIXME: an accurate recipient list should be queried
2187 + # from the lists.sr.ht PostgreSQL database to avoid backscattering.
2188 + # But usernames are unfortunately not in that database but in meta.sr.ht.
2189 + # Note that two syntaxes are allowed:
2190 + # - ~username/list-name@lists.${domain}
2191 + # - u.username.list-name@lists.${domain}
2192 + localRecipients = [ "@lists.${domain}" ];
2194 + lists.${domain} lmtp:unix:${cfg.settings."lists.sr.ht::worker".sock}
2200 + (import ./service.nix "man" {
2201 + inherit configIniOfService;
2205 + (import ./service.nix "meta" {
2206 + inherit configIniOfService;
2209 + extraServices.metasrht-api = {
2210 + serviceConfig.Restart = "always";
2211 + serviceConfig.RestartSec = "2s";
2212 + preStart = "set -x\n" + concatStringsSep "\n\n" (attrValues (mapAttrs (k: s:
2213 + let srvMatch = builtins.match "^([a-z]*)\\.sr\\.ht$" k;
2214 + srv = head srvMatch;
2216 + # Configure client(s) as "preauthorized"
2217 + optionalString (srvMatch != null && cfg.${srv}.enable && ((s.oauth-client-id or null) != null)) ''
2218 + # Configure ${srv}'s OAuth client as "preauthorized"
2219 + ${postgresql.package}/bin/psql '${cfg.settings."meta.sr.ht".connection-string}' \
2220 + -c "UPDATE oauthclient SET preauthorized = true WHERE client_id = '${s.oauth-client-id}'"
2223 + serviceConfig.ExecStart = "${pkgs.sourcehut.metasrht}/bin/metasrht-api -b ${cfg.listenAddress}:${toString (cfg.meta.port + 100)}";
2225 + extraTimers.metasrht-daily.timerConfig = {
2226 + OnCalendar = ["daily"];
2227 + AccuracySec = "1h";
2229 + extraConfig = mkMerge [
2232 + { assertion = let s = cfg.settings."meta.sr.ht::billing"; in
2233 + s.enabled == "yes" -> (s.stripe-public-key != null && s.stripe-secret-key != null);
2234 + message = "If meta.sr.ht::billing is enabled, the keys must be defined.";
2237 + environment.systemPackages = optional cfg.meta.enable
2238 + (pkgs.writeShellScriptBin "metasrht-manageuser" ''
2240 + if test "$(${pkgs.coreutils}/bin/id -n -u)" != '${cfg.meta.user}'
2241 + then exec sudo -u '${cfg.meta.user}' "$0" "$@"
2243 + # In order to load config.ini
2244 + if cd /run/sourcehut/metasrht
2245 + then exec ${cfg.python}/bin/metasrht-manageuser "$@"
2247 + Please run: sudo systemctl start metasrht
2254 + (mkIf cfg.nginx.enable {
2255 + services.nginx.virtualHosts."meta.${domain}" = {
2256 + locations."/query" = {
2257 + proxyPass = cfg.settings."meta.sr.ht".api-origin;
2259 + if ($request_method = 'OPTIONS') {
2260 + add_header 'Access-Control-Allow-Origin' '*';
2261 + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
2262 + add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
2263 + add_header 'Access-Control-Max-Age' 1728000;
2264 + add_header 'Content-Type' 'text/plain; charset=utf-8';
2265 + add_header 'Content-Length' 0;
2269 + add_header 'Access-Control-Allow-Origin' '*';
2270 + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
2271 + add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
2272 + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
2280 + (import ./service.nix "pages" {
2281 + inherit configIniOfService;
2284 + srvsrht = "pagessrht";
2285 + version = pkgs.sourcehut.${srvsrht}.version;
2286 + stateDir = "/var/lib/sourcehut/${srvsrht}";
2287 + iniKey = "pages.sr.ht";
2289 + preStart = mkBefore ''
2291 + # Use the /run/sourcehut/${srvsrht}/config.ini
2292 + # installed by a previous ExecStartPre= in baseService
2293 + cd /run/sourcehut/${srvsrht}
2295 + if test ! -e ${stateDir}/db; then
2296 + ${postgresql.package}/bin/psql '${cfg.settings.${iniKey}.connection-string}' -f ${pkgs.sourcehut.pagessrht}/share/sql/schema.sql
2297 + echo ${version} >${stateDir}/db
2300 + ${optionalString cfg.settings.${iniKey}.migrate-on-upgrade ''
2301 + # Just try all the migrations because they're not linked to the version
2302 + for sql in ${pkgs.sourcehut.pagessrht}/share/sql/migrations/*.sql; do
2303 + ${postgresql.package}/bin/psql '${cfg.settings.${iniKey}.connection-string}' -f "$sql" || true
2308 + touch ${stateDir}/webhook
2311 + ExecStart = mkForce "${pkgs.sourcehut.pagessrht}/bin/pages.sr.ht -b ${cfg.listenAddress}:${toString cfg.pages.port}";
2316 + (import ./service.nix "paste" {
2317 + inherit configIniOfService;
2321 + (import ./service.nix "todo" {
2322 + inherit configIniOfService;
2325 + extraServices.todosrht-lmtp = {
2326 + wants = [ "postfix.service" ];
2327 + unitConfig.JoinsNamespaceOf = optional cfg.postfix.enable "postfix.service";
2328 + serviceConfig.ExecStart = "${cfg.python}/bin/todosrht-lmtp";
2329 + # Avoid crashing: os.chown(sock, os.getuid(), sock_gid)
2330 + serviceConfig.PrivateUsers = mkForce false;
2332 + extraConfig = mkIf cfg.postfix.enable {
2333 + users.groups.${postfix.group}.members = [ cfg.todo.user ];
2334 + services.sourcehut.settings."todo.sr.ht::mail".sock-group = postfix.group;
2335 + services.postfix.transport = ''
2336 + todo.${domain} lmtp:unix:${cfg.settings."todo.sr.ht::mail".sock}
2341 + (mkRenamedOptionModule [ "services" "sourcehut" "originBase" ]
2342 + [ "services" "sourcehut" "settings" "sr.ht" "global-domain" ])
2343 + (mkRenamedOptionModule [ "services" "sourcehut" "address" ]
2344 + [ "services" "sourcehut" "listenAddress" ])
2348 meta.doc = ./sourcehut.xml;
2349 - meta.maintainers = with maintainers; [ tomberek ];
2350 + meta.maintainers = with maintainers; [ julm tomberek ];
2352 diff --git a/nixos/modules/services/misc/sourcehut/dispatch.nix b/nixos/modules/services/misc/sourcehut/dispatch.nix
2353 deleted file mode 100644
2354 index a9db17bebe8..00000000000
2355 --- a/nixos/modules/services/misc/sourcehut/dispatch.nix
2358 -{ config, lib, pkgs, ... }:
2362 - cfg = config.services.sourcehut;
2363 - cfgIni = cfg.settings;
2364 - scfg = cfg.dispatch;
2365 - iniKey = "dispatch.sr.ht";
2367 - drv = pkgs.sourcehut.dispatchsrht;
2370 - options.services.sourcehut.dispatch = {
2373 - default = "dispatchsrht";
2375 - User for dispatch.sr.ht.
2380 - type = types.port;
2383 - Port on which the "dispatch" module should listen.
2387 - database = mkOption {
2389 - default = "dispatch.sr.ht";
2391 - PostgreSQL database name for dispatch.sr.ht.
2395 - statePath = mkOption {
2396 - type = types.path;
2397 - default = "${cfg.statePath}/dispatchsrht";
2399 - State path for dispatch.sr.ht.
2404 - config = with scfg; lib.mkIf (cfg.enable && elem "dispatch" cfg.services) {
2409 - isSystemUser = true;
2411 - description = "dispatch.sr.ht user";
2420 - services.postgresql = {
2421 - authentication = ''
2422 - local ${database} ${user} trust
2424 - ensureDatabases = [ database ];
2428 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
2434 - tmpfiles.rules = [
2435 - "d ${statePath} 0750 ${user} ${user} -"
2438 - services.dispatchsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
2439 - after = [ "postgresql.service" "network.target" ];
2440 - requires = [ "postgresql.service" ];
2441 - wantedBy = [ "multi-user.target" ];
2443 - description = "dispatch.sr.ht website service";
2445 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
2449 - services.sourcehut.settings = {
2450 - # URL dispatch.sr.ht is being served at (protocol://domain)
2451 - "dispatch.sr.ht".origin = mkDefault "http://dispatch.${cfg.originBase}";
2452 - # Address and port to bind the debug server to
2453 - "dispatch.sr.ht".debug-host = mkDefault "0.0.0.0";
2454 - "dispatch.sr.ht".debug-port = mkDefault port;
2455 - # Configures the SQLAlchemy connection string for the database.
2456 - "dispatch.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
2457 - # Set to "yes" to automatically run migrations on package upgrade.
2458 - "dispatch.sr.ht".migrate-on-upgrade = mkDefault "yes";
2459 - # dispatch.sr.ht's OAuth client ID and secret for meta.sr.ht
2460 - # Register your client at meta.example.org/oauth
2461 - "dispatch.sr.ht".oauth-client-id = mkDefault null;
2462 - "dispatch.sr.ht".oauth-client-secret = mkDefault null;
2464 - # Github Integration
2465 - "dispatch.sr.ht::github".oauth-client-id = mkDefault null;
2466 - "dispatch.sr.ht::github".oauth-client-secret = mkDefault null;
2468 - # Gitlab Integration
2469 - "dispatch.sr.ht::gitlab".enabled = mkDefault null;
2470 - "dispatch.sr.ht::gitlab".canonical-upstream = mkDefault "gitlab.com";
2471 - "dispatch.sr.ht::gitlab".repo-cache = mkDefault "./repo-cache";
2472 - # "dispatch.sr.ht::gitlab"."gitlab.com" = mkDefault "GitLab:application id:secret";
2475 - services.nginx.virtualHosts."dispatch.${cfg.originBase}" = {
2477 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
2478 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
2479 - locations."/static".root = "${pkgs.sourcehut.dispatchsrht}/${pkgs.sourcehut.python.sitePackages}/dispatchsrht";
2483 diff --git a/nixos/modules/services/misc/sourcehut/git.nix b/nixos/modules/services/misc/sourcehut/git.nix
2484 deleted file mode 100644
2485 index 99b9aec0612..00000000000
2486 --- a/nixos/modules/services/misc/sourcehut/git.nix
2489 -{ config, lib, pkgs, ... }:
2493 - cfg = config.services.sourcehut;
2495 - iniKey = "git.sr.ht";
2497 - rcfg = config.services.redis;
2498 - drv = pkgs.sourcehut.gitsrht;
2501 - options.services.sourcehut.git = {
2509 - User for git.sr.ht.
2514 - type = types.port;
2517 - Port on which the "git" module should listen.
2521 - database = mkOption {
2523 - default = "git.sr.ht";
2525 - PostgreSQL database name for git.sr.ht.
2529 - statePath = mkOption {
2530 - type = types.path;
2531 - default = "${cfg.statePath}/gitsrht";
2533 - State path for git.sr.ht.
2537 - package = mkOption {
2538 - type = types.package;
2539 - default = pkgs.git;
2540 - example = literalExample "pkgs.gitFull";
2542 - Git package for git.sr.ht. This can help silence collisions.
2547 - config = with scfg; lib.mkIf (cfg.enable && elem "git" cfg.services) {
2548 - # sshd refuses to run with `Unsafe AuthorizedKeysCommand ... bad ownership or modes for directory /nix/store`
2549 - environment.etc."ssh/gitsrht-dispatch" = {
2552 - #! ${pkgs.stdenv.shell}
2553 - ${cfg.python}/bin/gitsrht-dispatch "$@"
2557 - # Needs this in the $PATH when sshing into the server
2558 - environment.systemPackages = [ cfg.git.package ];
2563 - isSystemUser = true;
2565 - # https://stackoverflow.com/questions/22314298/git-push-results-in-fatal-protocol-error-bad-line-length-character-this
2566 - # Probably could use gitsrht-shell if output is restricted to just parameters...
2567 - shell = pkgs.bash;
2568 - description = "git.sr.ht user";
2578 - cron.systemCronJobs = [ "*/20 * * * * ${cfg.python}/bin/gitsrht-periodic" ];
2579 - fcgiwrap.enable = true;
2581 - openssh.authorizedKeysCommand = ''/etc/ssh/gitsrht-dispatch "%u" "%h" "%t" "%k"'';
2582 - openssh.authorizedKeysCommandUser = "root";
2583 - openssh.extraConfig = ''
2584 - PermitUserEnvironment SRHT_*
2588 - authentication = ''
2589 - local ${database} ${user} trust
2591 - ensureDatabases = [ database ];
2595 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
2602 - tmpfiles.rules = [
2603 - # /var/log is owned by root
2604 - "f /var/log/git-srht-shell 0644 ${user} ${user} -"
2606 - "d ${statePath} 0750 ${user} ${user} -"
2607 - "d ${cfg.settings."${iniKey}".repos} 2755 ${user} ${user} -"
2611 - gitsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
2612 - after = [ "redis.service" "postgresql.service" "network.target" ];
2613 - requires = [ "redis.service" "postgresql.service" ];
2614 - wantedBy = [ "multi-user.target" ];
2616 - # Needs internally to create repos at the very least
2617 - path = [ pkgs.git ];
2618 - description = "git.sr.ht website service";
2620 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
2623 - gitsrht-webhooks = {
2624 - after = [ "postgresql.service" "network.target" ];
2625 - requires = [ "postgresql.service" ];
2626 - wantedBy = [ "multi-user.target" ];
2628 - description = "git.sr.ht webhooks service";
2632 - Restart = "always";
2635 - serviceConfig.ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel=info";
2640 - services.sourcehut.settings = {
2641 - # URL git.sr.ht is being served at (protocol://domain)
2642 - "git.sr.ht".origin = mkDefault "http://git.${cfg.originBase}";
2643 - # Address and port to bind the debug server to
2644 - "git.sr.ht".debug-host = mkDefault "0.0.0.0";
2645 - "git.sr.ht".debug-port = mkDefault port;
2646 - # Configures the SQLAlchemy connection string for the database.
2647 - "git.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
2648 - # Set to "yes" to automatically run migrations on package upgrade.
2649 - "git.sr.ht".migrate-on-upgrade = mkDefault "yes";
2650 - # The redis connection used for the webhooks worker
2651 - "git.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/1";
2653 - # A post-update script which is installed in every git repo.
2654 - "git.sr.ht".post-update-script = mkDefault "${pkgs.sourcehut.gitsrht}/bin/gitsrht-update-hook";
2656 - # git.sr.ht's OAuth client ID and secret for meta.sr.ht
2657 - # Register your client at meta.example.org/oauth
2658 - "git.sr.ht".oauth-client-id = mkDefault null;
2659 - "git.sr.ht".oauth-client-secret = mkDefault null;
2660 - # Path to git repositories on disk
2661 - "git.sr.ht".repos = mkDefault "/var/lib/git";
2663 - "git.sr.ht".outgoing-domain = mkDefault "http://git.${cfg.originBase}";
2665 - # The authorized keys hook uses this to dispatch to various handlers
2666 - # The format is a program to exec into as the key, and the user to match as the
2667 - # value. When someone tries to log in as this user, this program is executed
2668 - # and is expected to omit an AuthorizedKeys file.
2670 - # Discard of the string context is in order to allow derivation-derived strings.
2671 - # This is safe if the relevant package is installed which will be the case if the setting is utilized.
2672 - "git.sr.ht::dispatch".${builtins.unsafeDiscardStringContext "${pkgs.sourcehut.gitsrht}/bin/gitsrht-keys"} = mkDefault "${user}:${user}";
2675 - services.nginx.virtualHosts."git.${cfg.originBase}" = {
2677 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
2678 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
2679 - locations."/static".root = "${pkgs.sourcehut.gitsrht}/${pkgs.sourcehut.python.sitePackages}/gitsrht";
2681 - location = /authorize {
2682 - proxy_pass http://${cfg.address}:${toString port};
2683 - proxy_pass_request_body off;
2684 - proxy_set_header Content-Length "";
2685 - proxy_set_header X-Original-URI $request_uri;
2687 - location ~ ^/([^/]+)/([^/]+)/(HEAD|info/refs|objects/info/.*|git-upload-pack).*$ {
2688 - auth_request /authorize;
2689 - root /var/lib/git;
2690 - fastcgi_pass unix:/run/fcgiwrap.sock;
2691 - fastcgi_param SCRIPT_FILENAME ${pkgs.git}/bin/git-http-backend;
2692 - fastcgi_param PATH_INFO $uri;
2693 - fastcgi_param GIT_PROJECT_ROOT $document_root;
2694 - fastcgi_read_timeout 500s;
2695 - include ${pkgs.nginx}/conf/fastcgi_params;
2703 diff --git a/nixos/modules/services/misc/sourcehut/hg.nix b/nixos/modules/services/misc/sourcehut/hg.nix
2704 deleted file mode 100644
2705 index 5cd36bb0455..00000000000
2706 --- a/nixos/modules/services/misc/sourcehut/hg.nix
2709 -{ config, lib, pkgs, ... }:
2713 - cfg = config.services.sourcehut;
2715 - iniKey = "hg.sr.ht";
2717 - rcfg = config.services.redis;
2718 - drv = pkgs.sourcehut.hgsrht;
2721 - options.services.sourcehut.hg = {
2728 - User for hg.sr.ht.
2733 - type = types.port;
2736 - Port on which the "hg" module should listen.
2740 - database = mkOption {
2742 - default = "hg.sr.ht";
2744 - PostgreSQL database name for hg.sr.ht.
2748 - statePath = mkOption {
2749 - type = types.path;
2750 - default = "${cfg.statePath}/hgsrht";
2752 - State path for hg.sr.ht.
2756 - cloneBundles = mkOption {
2757 - type = types.bool;
2760 - Generate clonebundles (which require more disk space but dramatically speed up cloning large repositories).
2765 - config = with scfg; lib.mkIf (cfg.enable && elem "hg" cfg.services) {
2766 - # In case it ever comes into being
2767 - environment.etc."ssh/hgsrht-dispatch" = {
2770 - #! ${pkgs.stdenv.shell}
2771 - ${cfg.python}/bin/gitsrht-dispatch $@
2775 - environment.systemPackages = [ pkgs.mercurial ];
2780 - isSystemUser = true;
2782 - # Assuming hg.sr.ht needs this too
2783 - shell = pkgs.bash;
2784 - description = "hg.sr.ht user";
2794 - cron.systemCronJobs = [ "*/20 * * * * ${cfg.python}/bin/hgsrht-periodic" ]
2795 - ++ optional cloneBundles "0 * * * * ${cfg.python}/bin/hgsrht-clonebundles";
2797 - openssh.authorizedKeysCommand = ''/etc/ssh/hgsrht-dispatch "%u" "%h" "%t" "%k"'';
2798 - openssh.authorizedKeysCommandUser = "root";
2799 - openssh.extraConfig = ''
2800 - PermitUserEnvironment SRHT_*
2804 - authentication = ''
2805 - local ${database} ${user} trust
2807 - ensureDatabases = [ database ];
2811 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
2818 - tmpfiles.rules = [
2819 - # /var/log is owned by root
2820 - "f /var/log/hg-srht-shell 0644 ${user} ${user} -"
2822 - "d ${statePath} 0750 ${user} ${user} -"
2823 - "d ${cfg.settings."${iniKey}".repos} 2755 ${user} ${user} -"
2826 - services.hgsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
2827 - after = [ "redis.service" "postgresql.service" "network.target" ];
2828 - requires = [ "redis.service" "postgresql.service" ];
2829 - wantedBy = [ "multi-user.target" ];
2831 - path = [ pkgs.mercurial ];
2832 - description = "hg.sr.ht website service";
2834 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
2838 - services.sourcehut.settings = {
2839 - # URL hg.sr.ht is being served at (protocol://domain)
2840 - "hg.sr.ht".origin = mkDefault "http://hg.${cfg.originBase}";
2841 - # Address and port to bind the debug server to
2842 - "hg.sr.ht".debug-host = mkDefault "0.0.0.0";
2843 - "hg.sr.ht".debug-port = mkDefault port;
2844 - # Configures the SQLAlchemy connection string for the database.
2845 - "hg.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
2846 - # The redis connection used for the webhooks worker
2847 - "hg.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/1";
2848 - # A post-update script which is installed in every mercurial repo.
2849 - "hg.sr.ht".changegroup-script = mkDefault "${cfg.python}/bin/hgsrht-hook-changegroup";
2850 - # hg.sr.ht's OAuth client ID and secret for meta.sr.ht
2851 - # Register your client at meta.example.org/oauth
2852 - "hg.sr.ht".oauth-client-id = mkDefault null;
2853 - "hg.sr.ht".oauth-client-secret = mkDefault null;
2854 - # Path to mercurial repositories on disk
2855 - "hg.sr.ht".repos = mkDefault "/var/lib/hg";
2856 - # Path to the srht mercurial extension
2857 - # (defaults to where the hgsrht code is)
2858 - # "hg.sr.ht".srhtext = mkDefault null;
2859 - # .hg/store size (in MB) past which the nightly job generates clone bundles.
2860 - # "hg.sr.ht".clone_bundle_threshold = mkDefault 50;
2861 - # Path to hg-ssh (if not in $PATH)
2862 - # "hg.sr.ht".hg_ssh = mkDefault /path/to/hg-ssh;
2864 - # The authorized keys hook uses this to dispatch to various handlers
2865 - # The format is a program to exec into as the key, and the user to match as the
2866 - # value. When someone tries to log in as this user, this program is executed
2867 - # and is expected to omit an AuthorizedKeys file.
2869 - # Uncomment the relevant lines to enable the various sr.ht dispatchers.
2870 - "hg.sr.ht::dispatch"."/run/current-system/sw/bin/hgsrht-keys" = mkDefault "${user}:${user}";
2873 - # TODO: requires testing and addition of hg-specific requirements
2874 - services.nginx.virtualHosts."hg.${cfg.originBase}" = {
2876 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
2877 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
2878 - locations."/static".root = "${pkgs.sourcehut.hgsrht}/${pkgs.sourcehut.python.sitePackages}/hgsrht";
2882 diff --git a/nixos/modules/services/misc/sourcehut/hub.nix b/nixos/modules/services/misc/sourcehut/hub.nix
2883 deleted file mode 100644
2884 index be3ea21011c..00000000000
2885 --- a/nixos/modules/services/misc/sourcehut/hub.nix
2888 -{ config, lib, pkgs, ... }:
2892 - cfg = config.services.sourcehut;
2893 - cfgIni = cfg.settings;
2895 - iniKey = "hub.sr.ht";
2897 - drv = pkgs.sourcehut.hubsrht;
2900 - options.services.sourcehut.hub = {
2903 - default = "hubsrht";
2905 - User for hub.sr.ht.
2910 - type = types.port;
2913 - Port on which the "hub" module should listen.
2917 - database = mkOption {
2919 - default = "hub.sr.ht";
2921 - PostgreSQL database name for hub.sr.ht.
2925 - statePath = mkOption {
2926 - type = types.path;
2927 - default = "${cfg.statePath}/hubsrht";
2929 - State path for hub.sr.ht.
2934 - config = with scfg; lib.mkIf (cfg.enable && elem "hub" cfg.services) {
2938 - isSystemUser = true;
2940 - description = "hub.sr.ht user";
2949 - services.postgresql = {
2950 - authentication = ''
2951 - local ${database} ${user} trust
2953 - ensureDatabases = [ database ];
2957 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
2963 - tmpfiles.rules = [
2964 - "d ${statePath} 0750 ${user} ${user} -"
2967 - services.hubsrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
2968 - after = [ "postgresql.service" "network.target" ];
2969 - requires = [ "postgresql.service" ];
2970 - wantedBy = [ "multi-user.target" ];
2972 - description = "hub.sr.ht website service";
2974 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
2978 - services.sourcehut.settings = {
2979 - # URL hub.sr.ht is being served at (protocol://domain)
2980 - "hub.sr.ht".origin = mkDefault "http://hub.${cfg.originBase}";
2981 - # Address and port to bind the debug server to
2982 - "hub.sr.ht".debug-host = mkDefault "0.0.0.0";
2983 - "hub.sr.ht".debug-port = mkDefault port;
2984 - # Configures the SQLAlchemy connection string for the database.
2985 - "hub.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
2986 - # Set to "yes" to automatically run migrations on package upgrade.
2987 - "hub.sr.ht".migrate-on-upgrade = mkDefault "yes";
2988 - # hub.sr.ht's OAuth client ID and secret for meta.sr.ht
2989 - # Register your client at meta.example.org/oauth
2990 - "hub.sr.ht".oauth-client-id = mkDefault null;
2991 - "hub.sr.ht".oauth-client-secret = mkDefault null;
2994 - services.nginx.virtualHosts."${cfg.originBase}" = {
2996 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
2997 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
2998 - locations."/static".root = "${pkgs.sourcehut.hubsrht}/${pkgs.sourcehut.python.sitePackages}/hubsrht";
3000 - services.nginx.virtualHosts."hub.${cfg.originBase}" = {
3001 - globalRedirect = "${cfg.originBase}";
3006 diff --git a/nixos/modules/services/misc/sourcehut/lists.nix b/nixos/modules/services/misc/sourcehut/lists.nix
3007 deleted file mode 100644
3008 index 7b1fe9fd463..00000000000
3009 --- a/nixos/modules/services/misc/sourcehut/lists.nix
3012 -# Email setup is fairly involved, useful references:
3013 -# https://drewdevault.com/2018/08/05/Local-mail-server.html
3015 -{ config, lib, pkgs, ... }:
3019 - cfg = config.services.sourcehut;
3020 - cfgIni = cfg.settings;
3022 - iniKey = "lists.sr.ht";
3024 - rcfg = config.services.redis;
3025 - drv = pkgs.sourcehut.listssrht;
3028 - options.services.sourcehut.lists = {
3031 - default = "listssrht";
3033 - User for lists.sr.ht.
3038 - type = types.port;
3041 - Port on which the "lists" module should listen.
3045 - database = mkOption {
3047 - default = "lists.sr.ht";
3049 - PostgreSQL database name for lists.sr.ht.
3053 - statePath = mkOption {
3054 - type = types.path;
3055 - default = "${cfg.statePath}/listssrht";
3057 - State path for lists.sr.ht.
3062 - config = with scfg; lib.mkIf (cfg.enable && elem "lists" cfg.services) {
3066 - isSystemUser = true;
3068 - extraGroups = [ "postfix" ];
3069 - description = "lists.sr.ht user";
3077 - services.postgresql = {
3078 - authentication = ''
3079 - local ${database} ${user} trust
3081 - ensureDatabases = [ database ];
3085 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
3091 - tmpfiles.rules = [
3092 - "d ${statePath} 0750 ${user} ${user} -"
3096 - listssrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
3097 - after = [ "postgresql.service" "network.target" ];
3098 - requires = [ "postgresql.service" ];
3099 - wantedBy = [ "multi-user.target" ];
3101 - description = "lists.sr.ht website service";
3103 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
3106 - listssrht-process = {
3107 - after = [ "postgresql.service" "network.target" ];
3108 - requires = [ "postgresql.service" ];
3109 - wantedBy = [ "multi-user.target" ];
3111 - description = "lists.sr.ht process service";
3115 - Restart = "always";
3116 - ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.process worker --loglevel=info";
3120 - listssrht-lmtp = {
3121 - after = [ "postgresql.service" "network.target" ];
3122 - requires = [ "postgresql.service" ];
3123 - wantedBy = [ "multi-user.target" ];
3125 - description = "lists.sr.ht process service";
3129 - Restart = "always";
3130 - ExecStart = "${cfg.python}/bin/listssrht-lmtp";
3135 - listssrht-webhooks = {
3136 - after = [ "postgresql.service" "network.target" ];
3137 - requires = [ "postgresql.service" ];
3138 - wantedBy = [ "multi-user.target" ];
3140 - description = "lists.sr.ht webhooks service";
3144 - Restart = "always";
3145 - ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel=info";
3151 - services.sourcehut.settings = {
3152 - # URL lists.sr.ht is being served at (protocol://domain)
3153 - "lists.sr.ht".origin = mkDefault "http://lists.${cfg.originBase}";
3154 - # Address and port to bind the debug server to
3155 - "lists.sr.ht".debug-host = mkDefault "0.0.0.0";
3156 - "lists.sr.ht".debug-port = mkDefault port;
3157 - # Configures the SQLAlchemy connection string for the database.
3158 - "lists.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
3159 - # Set to "yes" to automatically run migrations on package upgrade.
3160 - "lists.sr.ht".migrate-on-upgrade = mkDefault "yes";
3161 - # lists.sr.ht's OAuth client ID and secret for meta.sr.ht
3162 - # Register your client at meta.example.org/oauth
3163 - "lists.sr.ht".oauth-client-id = mkDefault null;
3164 - "lists.sr.ht".oauth-client-secret = mkDefault null;
3165 - # Outgoing email for notifications generated by users
3166 - "lists.sr.ht".notify-from = mkDefault "CHANGEME@example.org";
3167 - # The redis connection used for the webhooks worker
3168 - "lists.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/2";
3169 - # The redis connection used for the celery worker
3170 - "lists.sr.ht".redis = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/4";
3172 - "lists.sr.ht".network-key = mkDefault null;
3174 - "lists.sr.ht".allow-new-lists = mkDefault "no";
3176 - "lists.sr.ht".posting-domain = mkDefault "lists.${cfg.originBase}";
3178 - # Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
3179 - # Alternatively, specify IP:PORT and an SMTP server will be run instead.
3180 - "lists.sr.ht::worker".sock = mkDefault "/tmp/lists.sr.ht-lmtp.sock";
3181 - # The lmtp daemon will make the unix socket group-read/write for users in this
3183 - "lists.sr.ht::worker".sock-group = mkDefault "postfix";
3184 - "lists.sr.ht::worker".reject-url = mkDefault "https://man.sr.ht/lists.sr.ht/etiquette.md";
3185 - "lists.sr.ht::worker".reject-mimetypes = mkDefault "text/html";
3189 - services.nginx.virtualHosts."lists.${cfg.originBase}" = {
3191 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
3192 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
3193 - locations."/static".root = "${pkgs.sourcehut.listssrht}/${pkgs.sourcehut.python.sitePackages}/listssrht";
3197 diff --git a/nixos/modules/services/misc/sourcehut/man.nix b/nixos/modules/services/misc/sourcehut/man.nix
3198 deleted file mode 100644
3199 index 7693396d187..00000000000
3200 --- a/nixos/modules/services/misc/sourcehut/man.nix
3203 -{ config, lib, pkgs, ... }:
3207 - cfg = config.services.sourcehut;
3208 - cfgIni = cfg.settings;
3210 - iniKey = "man.sr.ht";
3212 - drv = pkgs.sourcehut.mansrht;
3215 - options.services.sourcehut.man = {
3218 - default = "mansrht";
3220 - User for man.sr.ht.
3225 - type = types.port;
3228 - Port on which the "man" module should listen.
3232 - database = mkOption {
3234 - default = "man.sr.ht";
3236 - PostgreSQL database name for man.sr.ht.
3240 - statePath = mkOption {
3241 - type = types.path;
3242 - default = "${cfg.statePath}/mansrht";
3244 - State path for man.sr.ht.
3249 - config = with scfg; lib.mkIf (cfg.enable && elem "man" cfg.services) {
3253 - assertion = hasAttrByPath [ "git.sr.ht" "oauth-client-id" ] cfgIni;
3254 - message = "man.sr.ht needs access to git.sr.ht.";
3261 - isSystemUser = true;
3263 - description = "man.sr.ht user";
3272 - services.postgresql = {
3273 - authentication = ''
3274 - local ${database} ${user} trust
3276 - ensureDatabases = [ database ];
3280 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
3286 - tmpfiles.rules = [
3287 - "d ${statePath} 0750 ${user} ${user} -"
3290 - services.mansrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
3291 - after = [ "postgresql.service" "network.target" ];
3292 - requires = [ "postgresql.service" ];
3293 - wantedBy = [ "multi-user.target" ];
3295 - description = "man.sr.ht website service";
3297 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
3301 - services.sourcehut.settings = {
3302 - # URL man.sr.ht is being served at (protocol://domain)
3303 - "man.sr.ht".origin = mkDefault "http://man.${cfg.originBase}";
3304 - # Address and port to bind the debug server to
3305 - "man.sr.ht".debug-host = mkDefault "0.0.0.0";
3306 - "man.sr.ht".debug-port = mkDefault port;
3307 - # Configures the SQLAlchemy connection string for the database.
3308 - "man.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
3309 - # Set to "yes" to automatically run migrations on package upgrade.
3310 - "man.sr.ht".migrate-on-upgrade = mkDefault "yes";
3311 - # man.sr.ht's OAuth client ID and secret for meta.sr.ht
3312 - # Register your client at meta.example.org/oauth
3313 - "man.sr.ht".oauth-client-id = mkDefault null;
3314 - "man.sr.ht".oauth-client-secret = mkDefault null;
3317 - services.nginx.virtualHosts."man.${cfg.originBase}" = {
3319 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
3320 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
3321 - locations."/static".root = "${pkgs.sourcehut.mansrht}/${pkgs.sourcehut.python.sitePackages}/mansrht";
3325 diff --git a/nixos/modules/services/misc/sourcehut/meta.nix b/nixos/modules/services/misc/sourcehut/meta.nix
3326 deleted file mode 100644
3327 index 56127a824eb..00000000000
3328 --- a/nixos/modules/services/misc/sourcehut/meta.nix
3331 -{ config, lib, pkgs, ... }:
3335 - cfg = config.services.sourcehut;
3336 - cfgIni = cfg.settings;
3338 - iniKey = "meta.sr.ht";
3340 - rcfg = config.services.redis;
3341 - drv = pkgs.sourcehut.metasrht;
3344 - options.services.sourcehut.meta = {
3347 - default = "metasrht";
3349 - User for meta.sr.ht.
3354 - type = types.port;
3357 - Port on which the "meta" module should listen.
3361 - database = mkOption {
3363 - default = "meta.sr.ht";
3365 - PostgreSQL database name for meta.sr.ht.
3369 - statePath = mkOption {
3370 - type = types.path;
3371 - default = "${cfg.statePath}/metasrht";
3373 - State path for meta.sr.ht.
3378 - config = with scfg; lib.mkIf (cfg.enable && elem "meta" cfg.services) {
3382 - assertion = with cfgIni."meta.sr.ht::billing"; enabled == "yes" -> (stripe-public-key != null && stripe-secret-key != null);
3383 - message = "If meta.sr.ht::billing is enabled, the keys should be defined.";
3390 - isSystemUser = true;
3392 - description = "meta.sr.ht user";
3401 - services.cron.systemCronJobs = [ "0 0 * * * ${cfg.python}/bin/metasrht-daily" ];
3402 - services.postgresql = {
3403 - authentication = ''
3404 - local ${database} ${user} trust
3406 - ensureDatabases = [ database ];
3410 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
3416 - tmpfiles.rules = [
3417 - "d ${statePath} 0750 ${user} ${user} -"
3421 - metasrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
3422 - after = [ "postgresql.service" "network.target" ];
3423 - requires = [ "postgresql.service" ];
3424 - wantedBy = [ "multi-user.target" ];
3426 - description = "meta.sr.ht website service";
3429 - # Configure client(s) as "preauthorized"
3430 - ${concatMapStringsSep "\n\n"
3432 - if ! test -e "${statePath}/${attr}.oauth" || [ "$(cat ${statePath}/${attr}.oauth)" != "${cfgIni."${attr}".oauth-client-id}" ]; then
3433 - # Configure ${attr}'s OAuth client as "preauthorized"
3434 - psql ${database} \
3435 - -c "UPDATE oauthclient SET preauthorized = true WHERE client_id = '${cfgIni."${attr}".oauth-client-id}'"
3437 - printf "%s" "${cfgIni."${attr}".oauth-client-id}" > "${statePath}/${attr}.oauth"
3440 - (builtins.attrNames (filterAttrs
3441 - (k: v: !(hasInfix "::" k) && builtins.hasAttr "oauth-client-id" v && v.oauth-client-id != null)
3445 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
3448 - metasrht-api = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
3449 - after = [ "postgresql.service" "network.target" ];
3450 - requires = [ "postgresql.service" ];
3451 - wantedBy = [ "multi-user.target" ];
3453 - description = "meta.sr.ht api service";
3456 - # Configure client(s) as "preauthorized"
3457 - ${concatMapStringsSep "\n\n"
3459 - if ! test -e "${statePath}/${attr}.oauth" || [ "$(cat ${statePath}/${attr}.oauth)" != "${cfgIni."${attr}".oauth-client-id}" ]; then
3460 - # Configure ${attr}'s OAuth client as "preauthorized"
3461 - psql ${database} \
3462 - -c "UPDATE oauthclient SET preauthorized = true WHERE client_id = '${cfgIni."${attr}".oauth-client-id}'"
3464 - printf "%s" "${cfgIni."${attr}".oauth-client-id}" > "${statePath}/${attr}.oauth"
3467 - (builtins.attrNames (filterAttrs
3468 - (k: v: !(hasInfix "::" k) && builtins.hasAttr "oauth-client-id" v && v.oauth-client-id != null)
3472 - serviceConfig.ExecStart = "${pkgs.sourcehut.metasrht}/bin/metasrht-api -b :${toString (port + 100)}";
3475 - metasrht-webhooks = {
3476 - after = [ "postgresql.service" "network.target" ];
3477 - requires = [ "postgresql.service" ];
3478 - wantedBy = [ "multi-user.target" ];
3480 - description = "meta.sr.ht webhooks service";
3484 - Restart = "always";
3485 - ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel=info";
3492 - services.sourcehut.settings = {
3493 - # URL meta.sr.ht is being served at (protocol://domain)
3494 - "meta.sr.ht".origin = mkDefault "https://meta.${cfg.originBase}";
3495 - # Address and port to bind the debug server to
3496 - "meta.sr.ht".debug-host = mkDefault "0.0.0.0";
3497 - "meta.sr.ht".debug-port = mkDefault port;
3498 - # Configures the SQLAlchemy connection string for the database.
3499 - "meta.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
3500 - # Set to "yes" to automatically run migrations on package upgrade.
3501 - "meta.sr.ht".migrate-on-upgrade = mkDefault "yes";
3502 - # If "yes", the user will be sent the stock sourcehut welcome emails after
3503 - # signup (requires cron to be configured properly). These are specific to the
3504 - # sr.ht instance so you probably want to patch these before enabling this.
3505 - "meta.sr.ht".welcome-emails = mkDefault "no";
3507 - # The redis connection used for the webhooks worker
3508 - "meta.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/6";
3510 - # If "no", public registration will not be permitted.
3511 - "meta.sr.ht::settings".registration = mkDefault "no";
3512 - # Where to redirect new users upon registration
3513 - "meta.sr.ht::settings".onboarding-redirect = mkDefault "https://meta.${cfg.originBase}";
3514 - # How many invites each user is issued upon registration (only applicable if
3515 - # open registration is disabled)
3516 - "meta.sr.ht::settings".user-invites = mkDefault 5;
3518 - # Origin URL for API, 100 more than web
3519 - "meta.sr.ht".api-origin = mkDefault "http://localhost:5100";
3521 - # You can add aliases for the client IDs of commonly used OAuth clients here.
3524 - "meta.sr.ht::aliases" = mkDefault { };
3525 - # "meta.sr.ht::aliases"."git.sr.ht" = 12345;
3527 - # "yes" to enable the billing system
3528 - "meta.sr.ht::billing".enabled = mkDefault "no";
3529 - # Get your keys at https://dashboard.stripe.com/account/apikeys
3530 - "meta.sr.ht::billing".stripe-public-key = mkDefault null;
3531 - "meta.sr.ht::billing".stripe-secret-key = mkDefault null;
3534 - services.nginx.virtualHosts."meta.${cfg.originBase}" = {
3536 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
3537 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
3538 - locations."/static".root = "${pkgs.sourcehut.metasrht}/${pkgs.sourcehut.python.sitePackages}/metasrht";
3542 diff --git a/nixos/modules/services/misc/sourcehut/paste.nix b/nixos/modules/services/misc/sourcehut/paste.nix
3543 deleted file mode 100644
3544 index b2d5151969e..00000000000
3545 --- a/nixos/modules/services/misc/sourcehut/paste.nix
3548 -{ config, lib, pkgs, ... }:
3552 - cfg = config.services.sourcehut;
3553 - cfgIni = cfg.settings;
3555 - iniKey = "paste.sr.ht";
3557 - rcfg = config.services.redis;
3558 - drv = pkgs.sourcehut.pastesrht;
3561 - options.services.sourcehut.paste = {
3564 - default = "pastesrht";
3566 - User for paste.sr.ht.
3571 - type = types.port;
3574 - Port on which the "paste" module should listen.
3578 - database = mkOption {
3580 - default = "paste.sr.ht";
3582 - PostgreSQL database name for paste.sr.ht.
3586 - statePath = mkOption {
3587 - type = types.path;
3588 - default = "${cfg.statePath}/pastesrht";
3590 - State path for pastesrht.sr.ht.
3595 - config = with scfg; lib.mkIf (cfg.enable && elem "paste" cfg.services) {
3599 - isSystemUser = true;
3601 - description = "paste.sr.ht user";
3610 - services.postgresql = {
3611 - authentication = ''
3612 - local ${database} ${user} trust
3614 - ensureDatabases = [ database ];
3618 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
3624 - tmpfiles.rules = [
3625 - "d ${statePath} 0750 ${user} ${user} -"
3629 - pastesrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
3630 - after = [ "postgresql.service" "network.target" ];
3631 - requires = [ "postgresql.service" ];
3632 - wantedBy = [ "multi-user.target" ];
3634 - description = "paste.sr.ht website service";
3636 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
3639 - pastesrht-webhooks = {
3640 - after = [ "postgresql.service" "network.target" ];
3641 - requires = [ "postgresql.service" ];
3642 - wantedBy = [ "multi-user.target" ];
3644 - description = "paste.sr.ht webhooks service";
3648 - Restart = "always";
3649 - ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel=info";
3656 - services.sourcehut.settings = {
3657 - # URL paste.sr.ht is being served at (protocol://domain)
3658 - "paste.sr.ht".origin = mkDefault "http://paste.${cfg.originBase}";
3659 - # Address and port to bind the debug server to
3660 - "paste.sr.ht".debug-host = mkDefault "0.0.0.0";
3661 - "paste.sr.ht".debug-port = mkDefault port;
3662 - # Configures the SQLAlchemy connection string for the database.
3663 - "paste.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
3664 - # Set to "yes" to automatically run migrations on package upgrade.
3665 - "paste.sr.ht".migrate-on-upgrade = mkDefault "yes";
3666 - # paste.sr.ht's OAuth client ID and secret for meta.sr.ht
3667 - # Register your client at meta.example.org/oauth
3668 - "paste.sr.ht".oauth-client-id = mkDefault null;
3669 - "paste.sr.ht".oauth-client-secret = mkDefault null;
3670 - "paste.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/5";
3673 - services.nginx.virtualHosts."paste.${cfg.originBase}" = {
3675 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
3676 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
3677 - locations."/static".root = "${pkgs.sourcehut.pastesrht}/${pkgs.sourcehut.python.sitePackages}/pastesrht";
3681 diff --git a/nixos/modules/services/misc/sourcehut/service.nix b/nixos/modules/services/misc/sourcehut/service.nix
3682 index 65b4ad020f9..b3c0efc07dd 100644
3683 --- a/nixos/modules/services/misc/sourcehut/service.nix
3684 +++ b/nixos/modules/services/misc/sourcehut/service.nix
3686 -{ config, pkgs, lib }:
3687 -serviceCfg: serviceDrv: iniKey: attrs:
3689 +{ configIniOfService
3690 +, srvsrht ? "${srv}srht" # Because "buildsrht" does not follow that pattern (missing an "s").
3691 +, iniKey ? "${srv}.sr.ht"
3695 +, extraServices ? {}
3699 +{ config, lib, pkgs, ... }:
3703 + inherit (config.services) postgresql;
3704 + redis = config.services.redis.servers."sourcehut-${srvsrht}";
3705 + inherit (config.users) users;
3706 cfg = config.services.sourcehut;
3707 - cfgIni = cfg.settings."${iniKey}";
3708 - pgSuperUser = config.services.postgresql.superUser;
3710 - setupDB = pkgs.writeScript "${serviceDrv.pname}-gen-db" ''
3711 - #! ${cfg.python}/bin/python
3712 - from ${serviceDrv.pname}.app import db
3715 + configIni = configIniOfService srv;
3716 + srvCfg = cfg.${srv};
3717 + baseService = serviceName: { allowStripe ? false }: extraService: let
3718 + runDir = "/run/sourcehut/${serviceName}";
3719 + rootDir = "/run/sourcehut/chroots/${serviceName}";
3721 + mkMerge [ extraService {
3722 + after = [ "network.target" ] ++
3723 + optional cfg.postgresql.enable "postgresql.service" ++
3724 + optional cfg.redis.enable "redis-sourcehut-${srvsrht}.service";
3726 + optional cfg.postgresql.enable "postgresql.service" ++
3727 + optional cfg.redis.enable "redis-sourcehut-${srvsrht}.service";
3728 + path = [ pkgs.gawk ];
3729 + environment.HOME = runDir;
3731 + User = mkDefault srvCfg.user;
3732 + Group = mkDefault srvCfg.group;
3733 + RuntimeDirectory = [
3734 + "sourcehut/${serviceName}"
3735 + # Used by *srht-keys which reads ../config.ini
3736 + "sourcehut/${serviceName}/subdir"
3737 + "sourcehut/chroots/${serviceName}"
3739 + RuntimeDirectoryMode = "2750";
3740 + # No need for the chroot path once inside the chroot
3741 + InaccessiblePaths = [ "-+${rootDir}" ];
3742 + # g+rx is for group members (eg. fcgiwrap or nginx)
3743 + # to read Git/Mercurial repositories, buildlogs, etc.
3744 + # o+x is for intermediate directories created by BindPaths= and like,
3745 + # as they're owned by root:root.
3747 + RootDirectory = rootDir;
3748 + RootDirectoryStartOnly = true;
3749 + PrivateTmp = true;
3750 + MountAPIVFS = true;
3751 + # config.ini is looked up in there, before /etc/srht/config.ini
3752 + # Note that it fails to be set in ExecStartPre=
3753 + WorkingDirectory = mkDefault ("-"+runDir);
3754 + BindReadOnlyPaths = [
3757 + "/run/booted-system"
3758 + "/run/current-system"
3761 + optional cfg.postgresql.enable "/run/postgresql" ++
3762 + optional cfg.redis.enable "/run/redis-sourcehut-${srvsrht}";
3763 + # LoadCredential= are unfortunately not available in ExecStartPre=
3764 + # Hence this one is run as root (the +) with RootDirectoryStartOnly=
3765 + # to reach credentials wherever they are.
3766 + # Note that each systemd service gets its own ${runDir}/config.ini file.
3767 + ExecStartPre = mkBefore [("+"+pkgs.writeShellScript "${serviceName}-credentials" ''
3769 + # Replace values begining with a '<' by the content of the file whose name is after.
3770 + gawk '{ if (match($0,/^([^=]+=)<(.+)/,m)) { getline f < m[2]; print m[1] f } else print $0 }' ${configIni} |
3771 + ${optionalString (!allowStripe) "gawk '!/^stripe-secret-key=/' |"}
3772 + install -o ${srvCfg.user} -g root -m 400 /dev/stdin ${runDir}/config.ini
3774 + # The following options are only for optimizing:
3775 + # systemd-analyze security
3776 + AmbientCapabilities = "";
3777 + CapabilityBoundingSet = "";
3778 + # ProtectClock= adds DeviceAllow=char-rtc r
3780 + LockPersonality = true;
3781 + MemoryDenyWriteExecute = true;
3782 + NoNewPrivileges = true;
3783 + PrivateDevices = true;
3784 + PrivateMounts = true;
3785 + PrivateNetwork = mkDefault false;
3786 + PrivateUsers = true;
3787 + ProcSubset = "pid";
3788 + ProtectClock = true;
3789 + ProtectControlGroups = true;
3790 + ProtectHome = true;
3791 + ProtectHostname = true;
3792 + ProtectKernelLogs = true;
3793 + ProtectKernelModules = true;
3794 + ProtectKernelTunables = true;
3795 + ProtectProc = "invisible";
3796 + ProtectSystem = "strict";
3798 + RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
3799 + RestrictNamespaces = true;
3800 + RestrictRealtime = true;
3801 + RestrictSUIDSGID = true;
3802 + #SocketBindAllow = [ "tcp:${toString srvCfg.port}" "tcp:${toString srvCfg.prometheusPort}" ];
3803 + #SocketBindDeny = "any";
3804 + SystemCallFilter = [
3806 + "~@aio" "~@keyring" "~@memlock" "~@privileged" "~@resources" "~@timer"
3807 + "@chown" "@setuid"
3809 + SystemCallArchitectures = "native";
3813 -with serviceCfg; with lib; recursiveUpdate
3815 - environment.HOME = statePath;
3816 - path = [ config.services.postgresql.package ] ++ (attrs.path or [ ]);
3817 - restartTriggers = [ config.environment.etc."sr.ht/config.ini".source ];
3822 - Restart = "always";
3823 - WorkingDirectory = statePath;
3824 - } // (if (cfg.statePath == "/var/lib/sourcehut/${serviceDrv.pname}") then {
3825 - StateDirectory = [ "sourcehut/${serviceDrv.pname}" ];
3828 + options.services.sourcehut.${srv} = {
3829 + enable = mkEnableOption "${srv} service";
3832 - if ! test -e ${statePath}/db; then
3833 - # Setup the initial database
3837 + default = srvsrht;
3839 + User for ${srv}.sr.ht.
3843 - # Set the initial state of the database for future database upgrades
3844 - if test -e ${cfg.python}/bin/${serviceDrv.pname}-migrate; then
3845 - # Run alembic stamp head once to tell alembic the schema is up-to-date
3846 - ${cfg.python}/bin/${serviceDrv.pname}-migrate stamp head
3848 + group = mkOption {
3850 + default = srvsrht;
3852 + Group for ${srv}.sr.ht.
3853 + Membership grants access to the Git/Mercurial repositories by default,
3854 + but not to the config.ini file (where secrets are).
3858 - printf "%s" "${serviceDrv.version}" > ${statePath}/db
3861 + type = types.port;
3864 + Port on which the "${srv}" backend should listen.
3868 - # Update copy of each users' profile to the latest
3869 - # See https://lists.sr.ht/~sircmpwn/sr.ht-admins/<20190302181207.GA13778%40cirno.my.domain>
3870 - if ! test -e ${statePath}/webhook; then
3871 - # Update ${iniKey}'s users' profile copy to the latest
3872 - ${cfg.python}/bin/srht-update-profiles ${iniKey}
3876 + default = "unix:/run/redis-sourcehut-${srvsrht}/redis.sock?db=0";
3877 + example = "redis://shared.wireguard:6379/0";
3879 + The redis host URL. This is used for caching and temporary storage, and must
3880 + be shared between nodes (e.g. git1.sr.ht and git2.sr.ht), but need not be
3881 + shared between services. It may be shared between services, however, with no
3882 + ill effect, if this better suits your infrastructure.
3887 - touch ${statePath}/webhook
3890 + database = mkOption {
3892 + default = "${srv}.sr.ht";
3894 + PostgreSQL database name for the ${srv}.sr.ht service,
3895 + used if <xref linkend="opt-services.sourcehut.postgresql.enable"/> is <literal>true</literal>.
3900 - ${optionalString (builtins.hasAttr "migrate-on-upgrade" cfgIni && cfgIni.migrate-on-upgrade == "yes") ''
3901 - if [ "$(cat ${statePath}/db)" != "${serviceDrv.version}" ]; then
3902 - # Manage schema migrations using alembic
3903 - ${cfg.python}/bin/${serviceDrv.pname}-migrate -a upgrade head
3905 + extraArgs = mkOption {
3906 + type = with types; listOf str;
3907 + default = ["--timeout 120" "--workers 1" "--log-level=info"];
3908 + description = "Extra arguments passed to Gunicorn.";
3911 + } // optionalAttrs webhooks {
3913 + extraArgs = mkOption {
3914 + type = with types; listOf str;
3915 + default = ["--loglevel DEBUG" "--pool eventlet" "--without-heartbeat"];
3916 + description = "Extra arguments passed to the Celery responsible for webhooks.";
3918 + celeryConfig = mkOption {
3919 + type = types.lines;
3921 + description = "Content of the <literal>celeryconfig.py</literal> used by the Celery responsible for webhooks.";
3926 - # Mark down current package version
3927 - printf "%s" "${serviceDrv.version}" > ${statePath}/db
3930 + config = lib.mkIf (cfg.enable && srvCfg.enable) (mkMerge [ extraConfig {
3933 + "${srvCfg.user}" = {
3934 + isSystemUser = true;
3935 + group = mkDefault srvCfg.group;
3936 + description = mkDefault "sourcehut user for ${srv}.sr.ht";
3940 + "${srvCfg.group}" = { };
3941 + } // optionalAttrs (cfg.postgresql.enable
3942 + && hasSuffix "0" (postgresql.settings.unix_socket_permissions or "")) {
3943 + "postgres".members = [ srvCfg.user ];
3944 + } // optionalAttrs (cfg.redis.enable
3945 + && hasSuffix "0" (redis.settings.unixsocketperm or "")) {
3946 + "redis-sourcehut-${srvsrht}".members = [ srvCfg.user ];
3950 - ${attrs.preStart or ""}
3952 + services.nginx = mkIf cfg.nginx.enable {
3953 + virtualHosts."${srv}.${cfg.settings."sr.ht".global-domain}" = mkMerge [ {
3955 + locations."/".proxyPass = "http://${cfg.listenAddress}:${toString srvCfg.port}";
3956 + locations."/static" = {
3957 + root = "${pkgs.sourcehut.${srvsrht}}/${pkgs.sourcehut.python.sitePackages}/${srvsrht}";
3958 + extraConfig = mkDefault ''
3962 + } cfg.nginx.virtualHost ];
3965 + services.postgresql = mkIf cfg.postgresql.enable {
3966 + authentication = ''
3967 + local ${srvCfg.postgresql.database} ${srvCfg.user} trust
3969 + ensureDatabases = [ srvCfg.postgresql.database ];
3970 + ensureUsers = map (name: {
3972 + ensurePermissions = { "DATABASE \"${srvCfg.postgresql.database}\"" = "ALL PRIVILEGES"; };
3976 + services.sourcehut.services = mkDefault (filter (s: cfg.${s}.enable)
3977 + [ "builds" "dispatch" "git" "hg" "hub" "lists" "man" "meta" "pages" "paste" "todo" ]);
3979 + services.sourcehut.settings = mkMerge [
3981 + "${srv}.sr.ht".origin = mkDefault "https://${srv}.${cfg.settings."sr.ht".global-domain}";
3984 + (mkIf cfg.postgresql.enable {
3985 + "${srv}.sr.ht".connection-string = mkDefault "postgresql:///${srvCfg.postgresql.database}?user=${srvCfg.user}&host=/run/postgresql";
3989 + services.redis.servers."sourcehut-${srvsrht}" = mkIf cfg.redis.enable {
3993 + # TODO: set a more informed value
3994 + save = mkDefault [ [1800 10] [300 100] ];
3996 + # TODO: set a more informed value
3997 + maxmemory = "128MB";
3998 + maxmemory-policy = "volatile-ttl";
4002 + systemd.services = mkMerge [
4004 + "${srvsrht}" = baseService srvsrht { allowStripe = srv == "meta"; } (mkMerge [
4006 + description = "sourcehut ${srv}.sr.ht website service";
4007 + before = optional cfg.nginx.enable "nginx.service";
4008 + wants = optional cfg.nginx.enable "nginx.service";
4009 + wantedBy = [ "multi-user.target" ];
4010 + path = optional cfg.postgresql.enable postgresql.package;
4011 + # Beware: change in credentials' content will not trigger restart.
4012 + restartTriggers = [ configIni ];
4015 + Restart = mkDefault "always";
4016 + #RestartSec = mkDefault "2min";
4017 + StateDirectory = [ "sourcehut/${srvsrht}" ];
4018 + StateDirectoryMode = "2750";
4019 + ExecStart = "${cfg.python}/bin/gunicorn ${srvsrht}.app:app --name ${srvsrht} --bind ${cfg.listenAddress}:${toString srvCfg.port} " + concatStringsSep " " srvCfg.gunicorn.extraArgs;
4022 + version = pkgs.sourcehut.${srvsrht}.version;
4023 + stateDir = "/var/lib/sourcehut/${srvsrht}";
4026 + # Use the /run/sourcehut/${srvsrht}/config.ini
4027 + # installed by a previous ExecStartPre= in baseService
4028 + cd /run/sourcehut/${srvsrht}
4030 + if test ! -e ${stateDir}/db; then
4031 + # Setup the initial database.
4032 + # Note that it stamps the alembic head afterward
4033 + ${cfg.python}/bin/${srvsrht}-initdb
4034 + echo ${version} >${stateDir}/db
4037 + ${optionalString cfg.settings.${iniKey}.migrate-on-upgrade ''
4038 + if [ "$(cat ${stateDir}/db)" != "${version}" ]; then
4039 + # Manage schema migrations using alembic
4040 + ${cfg.python}/bin/${srvsrht}-migrate -a upgrade head
4041 + echo ${version} >${stateDir}/db
4045 + # Update copy of each users' profile to the latest
4046 + # See https://lists.sr.ht/~sircmpwn/sr.ht-admins/<20190302181207.GA13778%40cirno.my.domain>
4047 + if test ! -e ${stateDir}/webhook; then
4048 + # Update ${iniKey}'s users' profile copy to the latest
4049 + ${cfg.python}/bin/srht-update-profiles ${iniKey}
4050 + touch ${stateDir}/webhook
4057 + "${srvsrht}-webhooks" = baseService "${srvsrht}-webhooks" {}
4059 + description = "sourcehut ${srv}.sr.ht webhooks service";
4060 + after = [ "${srvsrht}.service" ];
4061 + wantedBy = [ "${srvsrht}.service" ];
4062 + partOf = [ "${srvsrht}.service" ];
4064 + cp ${pkgs.writeText "${srvsrht}-webhooks-celeryconfig.py" srvCfg.webhooks.celeryConfig} \
4065 + /run/sourcehut/${srvsrht}-webhooks/celeryconfig.py
4069 + Restart = "always";
4070 + ExecStart = "${cfg.python}/bin/celery --app ${srvsrht}.webhooks worker --hostname ${srvsrht}-webhooks@%%h " + concatStringsSep " " srvCfg.webhooks.extraArgs;
4071 + # Avoid crashing: os.getloadavg()
4072 + ProcSubset = mkForce "all";
4077 + (mapAttrs (timerName: timer: (baseService timerName {} (mkMerge [
4079 + description = "sourcehut ${timerName} service";
4080 + after = [ "network.target" "${srvsrht}.service" ];
4083 + ExecStart = "${cfg.python}/bin/${timerName}";
4086 + (timer.service or {})
4089 + (mapAttrs (serviceName: extraService: baseService serviceName {} (mkMerge [
4091 + description = "sourcehut ${serviceName} service";
4092 + # So that extraServices have the PostgreSQL database initialized.
4093 + after = [ "${srvsrht}.service" ];
4094 + wantedBy = [ "${srvsrht}.service" ];
4095 + partOf = [ "${srvsrht}.service" ];
4098 + Restart = mkDefault "always";
4102 + ])) extraServices)
4105 + systemd.timers = mapAttrs (timerName: timer:
4107 + description = "sourcehut timer for ${timerName}";
4108 + wantedBy = [ "timers.target" ];
4109 + inherit (timer) timerConfig;
4113 - (builtins.removeAttrs attrs [ "path" "preStart" ])
4114 diff --git a/nixos/modules/services/misc/sourcehut/sourcehut.xml b/nixos/modules/services/misc/sourcehut/sourcehut.xml
4115 index ab9a8c6cb4b..41094f65a94 100644
4116 --- a/nixos/modules/services/misc/sourcehut/sourcehut.xml
4117 +++ b/nixos/modules/services/misc/sourcehut/sourcehut.xml
4119 <title>Basic usage</title>
4121 Sourcehut is a Python and Go based set of applications.
4122 - <literal><link linkend="opt-services.sourcehut.enable">services.sourcehut</link></literal>
4123 - by default will use
4124 + This NixOS module also provides basic configuration integrating Sourcehut into locally running
4125 <literal><link linkend="opt-services.nginx.enable">services.nginx</link></literal>,
4126 - <literal><link linkend="opt-services.nginx.enable">services.redis</link></literal>,
4127 - <literal><link linkend="opt-services.nginx.enable">services.cron</link></literal>,
4128 + <literal><link linkend="opt-services.redis.servers">services.redis.servers.sourcehut</link></literal>,
4129 + <literal><link linkend="opt-services.postfix.enable">services.postfix</link></literal>
4131 - <literal><link linkend="opt-services.postgresql.enable">services.postgresql</link></literal>.
4132 + <literal><link linkend="opt-services.postgresql.enable">services.postgresql</link></literal> services.
4136 @@ -42,18 +41,23 @@ in {
4138 services.sourcehut = {
4139 <link linkend="opt-services.sourcehut.enable">enable</link> = true;
4140 - <link linkend="opt-services.sourcehut.originBase">originBase</link> = fqdn;
4141 - <link linkend="opt-services.sourcehut.services">services</link> = [ "meta" "man" "git" ];
4142 + <link linkend="opt-services.sourcehut.git.enable">git.enable</link> = true;
4143 + <link linkend="opt-services.sourcehut.man.enable">man.enable</link> = true;
4144 + <link linkend="opt-services.sourcehut.meta.enable">meta.enable</link> = true;
4145 + <link linkend="opt-services.sourcehut.nginx.enable">nginx.enable</link> = true;
4146 + <link linkend="opt-services.sourcehut.postfix.enable">postfix.enable</link> = true;
4147 + <link linkend="opt-services.sourcehut.postgresql.enable">postgresql.enable</link> = true;
4148 + <link linkend="opt-services.sourcehut.redis.enable">redis.enable</link> = true;
4149 <link linkend="opt-services.sourcehut.settings">settings</link> = {
4151 environment = "production";
4152 global-domain = fqdn;
4153 origin = "https://${fqdn}";
4154 # Produce keys with srht-keygen from <package>sourcehut.coresrht</package>.
4155 - network-key = "SECRET";
4156 - service-key = "SECRET";
4157 + network-key = "/run/keys/path/to/network-key";
4158 + service-key = "/run/keys/path/to/service-key";
4160 - webhooks.private-key= "SECRET";
4161 + webhooks.private-key= "/run/keys/path/to/webhook-key";
4165 diff --git a/nixos/modules/services/misc/sourcehut/todo.nix b/nixos/modules/services/misc/sourcehut/todo.nix
4166 deleted file mode 100644
4167 index aec773b0669..00000000000
4168 --- a/nixos/modules/services/misc/sourcehut/todo.nix
4171 -{ config, lib, pkgs, ... }:
4175 - cfg = config.services.sourcehut;
4176 - cfgIni = cfg.settings;
4178 - iniKey = "todo.sr.ht";
4180 - rcfg = config.services.redis;
4181 - drv = pkgs.sourcehut.todosrht;
4184 - options.services.sourcehut.todo = {
4187 - default = "todosrht";
4189 - User for todo.sr.ht.
4194 - type = types.port;
4197 - Port on which the "todo" module should listen.
4201 - database = mkOption {
4203 - default = "todo.sr.ht";
4205 - PostgreSQL database name for todo.sr.ht.
4209 - statePath = mkOption {
4210 - type = types.path;
4211 - default = "${cfg.statePath}/todosrht";
4213 - State path for todo.sr.ht.
4218 - config = with scfg; lib.mkIf (cfg.enable && elem "todo" cfg.services) {
4222 - isSystemUser = true;
4224 - extraGroups = [ "postfix" ];
4225 - description = "todo.sr.ht user";
4233 - services.postgresql = {
4234 - authentication = ''
4235 - local ${database} ${user} trust
4237 - ensureDatabases = [ database ];
4241 - ensurePermissions = { "DATABASE \"${database}\"" = "ALL PRIVILEGES"; };
4247 - tmpfiles.rules = [
4248 - "d ${statePath} 0750 ${user} ${user} -"
4252 - todosrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {
4253 - after = [ "postgresql.service" "network.target" ];
4254 - requires = [ "postgresql.service" ];
4255 - wantedBy = [ "multi-user.target" ];
4257 - description = "todo.sr.ht website service";
4259 - serviceConfig.ExecStart = "${cfg.python}/bin/gunicorn ${drv.pname}.app:app -b ${cfg.address}:${toString port}";
4263 - after = [ "postgresql.service" "network.target" ];
4264 - bindsTo = [ "postgresql.service" ];
4265 - wantedBy = [ "multi-user.target" ];
4267 - description = "todo.sr.ht process service";
4271 - Restart = "always";
4272 - ExecStart = "${cfg.python}/bin/todosrht-lmtp";
4276 - todosrht-webhooks = {
4277 - after = [ "postgresql.service" "network.target" ];
4278 - requires = [ "postgresql.service" ];
4279 - wantedBy = [ "multi-user.target" ];
4281 - description = "todo.sr.ht webhooks service";
4285 - Restart = "always";
4286 - ExecStart = "${cfg.python}/bin/celery -A ${drv.pname}.webhooks worker --loglevel=info";
4293 - services.sourcehut.settings = {
4294 - # URL todo.sr.ht is being served at (protocol://domain)
4295 - "todo.sr.ht".origin = mkDefault "http://todo.${cfg.originBase}";
4296 - # Address and port to bind the debug server to
4297 - "todo.sr.ht".debug-host = mkDefault "0.0.0.0";
4298 - "todo.sr.ht".debug-port = mkDefault port;
4299 - # Configures the SQLAlchemy connection string for the database.
4300 - "todo.sr.ht".connection-string = mkDefault "postgresql:///${database}?user=${user}&host=/var/run/postgresql";
4301 - # Set to "yes" to automatically run migrations on package upgrade.
4302 - "todo.sr.ht".migrate-on-upgrade = mkDefault "yes";
4303 - # todo.sr.ht's OAuth client ID and secret for meta.sr.ht
4304 - # Register your client at meta.example.org/oauth
4305 - "todo.sr.ht".oauth-client-id = mkDefault null;
4306 - "todo.sr.ht".oauth-client-secret = mkDefault null;
4307 - # Outgoing email for notifications generated by users
4308 - "todo.sr.ht".notify-from = mkDefault "CHANGEME@example.org";
4309 - # The redis connection used for the webhooks worker
4310 - "todo.sr.ht".webhooks = mkDefault "redis://${rcfg.bind}:${toString rcfg.port}/1";
4312 - "todo.sr.ht".network-key = mkDefault null;
4314 - # Path for the lmtp daemon's unix socket. Direct incoming mail to this socket.
4315 - # Alternatively, specify IP:PORT and an SMTP server will be run instead.
4316 - "todo.sr.ht::mail".sock = mkDefault "/tmp/todo.sr.ht-lmtp.sock";
4317 - # The lmtp daemon will make the unix socket group-read/write for users in this
4319 - "todo.sr.ht::mail".sock-group = mkDefault "postfix";
4321 - "todo.sr.ht::mail".posting-domain = mkDefault "todo.${cfg.originBase}";
4324 - services.nginx.virtualHosts."todo.${cfg.originBase}" = {
4326 - locations."/".proxyPass = "http://${cfg.address}:${toString port}";
4327 - locations."/query".proxyPass = "http://${cfg.address}:${toString (port + 100)}";
4328 - locations."/static".root = "${pkgs.sourcehut.todosrht}/${pkgs.sourcehut.python.sitePackages}/todosrht";
4332 diff --git a/pkgs/applications/version-management/sourcehut/builds.nix b/pkgs/applications/version-management/sourcehut/builds.nix
4333 index c8163caf8ea..374736e80f5 100644
4334 --- a/pkgs/applications/version-management/sourcehut/builds.nix
4335 +++ b/pkgs/applications/version-management/sourcehut/builds.nix
4340 - version = "0.66.7";
4341 + version = "0.71.0";
4343 buildWorker = src: buildGoModule {
4344 inherit src version;
4345 pname = "builds-sr-ht-worker";
4347 - vendorSha256 = "sha256-giOaldV46aBqXyFH/cQVsbUr6Rb4VMhbBO86o48tRZY=";
4348 + vendorSha256 = "sha256-ZEarWM/33t+pNXUEIpfd/DkBkhu3UUg17Hh8XXWOepA=";
4351 buildPythonPackage rec {
4352 @@ -28,7 +28,7 @@ buildPythonPackage rec {
4353 owner = "~sircmpwn";
4354 repo = "builds.sr.ht";
4356 - sha256 = "sha256-2MLs/DOXHjEYarXDVUcPZe3o0fmZbzVxn528SE72lhM=";
4357 + sha256 = "sha256-S3mMndUdVGi+YxAOI3wSNlSZrH3cwumxatXpErS2yQI=";
4360 nativeBuildInputs = srht.nativeBuildInputs;
4361 @@ -56,10 +56,12 @@ buildPythonPackage rec {
4362 cp ${buildWorker "${src}/worker"}/bin/worker $out/bin/builds.sr.ht-worker
4365 + pythonImportsCheck = [ "buildsrht" ];
4368 homepage = "https://git.sr.ht/~sircmpwn/builds.sr.ht";
4369 description = "Continuous integration service for the sr.ht network";
4370 - license = licenses.agpl3;
4371 + license = licenses.agpl3Only;
4372 maintainers = with maintainers; [ eadwu ];
4375 diff --git a/pkgs/applications/version-management/sourcehut/core.nix b/pkgs/applications/version-management/sourcehut/core.nix
4376 index d359d524eb2..939d9d7b750 100644
4377 --- a/pkgs/applications/version-management/sourcehut/core.nix
4378 +++ b/pkgs/applications/version-management/sourcehut/core.nix
4386 buildPythonPackage rec {
4388 - version = "0.67.4";
4389 + version = "0.67.18";
4392 url = "https://git.sr.ht/~sircmpwn/core.sr.ht";
4394 - sha256 = "sha256-XvzFfcBK5Mq8p7xEBAF/eupUE1kkUBh5k+ByM/WA9bc=";
4395 + sha256 = "sha256-lPPB1DRWHANGBBfWeu0pUn1xBkd37ZhyreozLlxX6cA=";
4396 fetchSubmodules = true;
4399 @@ -46,7 +45,12 @@ buildPythonPackage rec {
4403 - ./disable-npm-install.patch
4404 + # Disable check for npm
4405 + patches/disable-npm-install.patch
4406 + # Fix broken hack: removing dots from "builds.sr.ht" does not produce "buildsrht"
4407 + patches/srht-update-profiles/0001-fix-disgusting-hack-in-the-case-of-buildsrht.patch
4408 + # Add Unix socket support for redis-host=
4409 + patches/redis-socket/core/v2-0001-add-Unix-socket-support-for-redis-host.patch
4412 nativeBuildInputs = [
4413 @@ -87,6 +91,7 @@ buildPythonPackage rec {
4416 dontUseSetuptoolsCheck = true;
4417 + pythonImportsCheck = [ "srht" ];
4420 homepage = "https://git.sr.ht/~sircmpwn/srht";
4421 diff --git a/pkgs/applications/version-management/sourcehut/default.nix b/pkgs/applications/version-management/sourcehut/default.nix
4422 index 401a1437b7d..7dde841b543 100644
4423 --- a/pkgs/applications/version-management/sourcehut/default.nix
4424 +++ b/pkgs/applications/version-management/sourcehut/default.nix
4425 @@ -22,10 +22,12 @@ let
4426 listssrht = self.callPackage ./lists.nix { };
4427 mansrht = self.callPackage ./man.nix { };
4428 metasrht = self.callPackage ./meta.nix { };
4429 + pagessrht = self.callPackage ./pages.nix { };
4430 pastesrht = self.callPackage ./paste.nix { };
4431 todosrht = self.callPackage ./todo.nix { };
4433 scmsrht = self.callPackage ./scm.nix { };
4434 + srht-keys = self.scmsrht.srht-keys;
4438 @@ -40,6 +42,8 @@ with python.pkgs; recurseIntoAttrs {
4439 listssrht = toPythonApplication listssrht;
4440 mansrht = toPythonApplication mansrht;
4441 metasrht = toPythonApplication metasrht;
4442 + pagessrht = pagessrht;
4443 pastesrht = toPythonApplication pastesrht;
4444 todosrht = toPythonApplication todosrht;
4445 + srht-keys = scmsrht.srht-keys;
4447 diff --git a/pkgs/applications/version-management/sourcehut/dispatch.nix b/pkgs/applications/version-management/sourcehut/dispatch.nix
4448 index 637c6f9c1df..9456d0c998c 100644
4449 --- a/pkgs/applications/version-management/sourcehut/dispatch.nix
4450 +++ b/pkgs/applications/version-management/sourcehut/dispatch.nix
4453 buildPythonPackage rec {
4454 pname = "dispatchsrht";
4455 - version = "0.15.8";
4456 + version = "0.15.32";
4458 src = fetchFromSourcehut {
4459 owner = "~sircmpwn";
4460 repo = "dispatch.sr.ht";
4462 - sha256 = "sha256-zWCGPjIgMKHXHJUs9aciV7IFgo0rpahon6KXHDwcfss=";
4463 + sha256 = "sha256-4P4cXhjcZ8IBzpRfmYIJkzl9U4Plo36a48Pf/KjmhFY=";
4466 nativeBuildInputs = srht.nativeBuildInputs;
4467 @@ -31,10 +31,12 @@ buildPythonPackage rec {
4468 export SRHT_PATH=${srht}/${python.sitePackages}/srht
4471 + pythonImportsCheck = [ "dispatchsrht" ];
4474 homepage = "https://dispatch.sr.ht/~sircmpwn/dispatch.sr.ht";
4475 description = "Task dispatcher and service integration tool for the sr.ht network";
4476 - license = licenses.agpl3;
4477 + license = licenses.agpl3Only;
4478 maintainers = with maintainers; [ eadwu ];
4481 diff --git a/pkgs/applications/version-management/sourcehut/git.nix b/pkgs/applications/version-management/sourcehut/git.nix
4482 index e44fb9cd6c6..0a09530b14b 100644
4483 --- a/pkgs/applications/version-management/sourcehut/git.nix
4484 +++ b/pkgs/applications/version-management/sourcehut/git.nix
4492 - version = "0.72.8";
4493 + version = "0.72.44";
4495 src = fetchFromSourcehut {
4496 owner = "~sircmpwn";
4499 - sha256 = "sha256-AB2uzajO5PtcpJfbOOTfuDFM6is5K39v3AZJ1hShRNc=";
4500 + sha256 = "sha256-U+hJiQpAJIHBC//M/Lfw82DLhZF46qHhz8zZW1ZvJoo=";
4503 - buildShell = src: buildGoModule {
4504 + gitsrht-shell = buildGoModule {
4505 inherit src version;
4506 + sourceRoot = "source/gitsrht-shell";
4507 pname = "gitsrht-shell";
4508 vendorSha256 = "sha256-aqUFICp0C2reqb2p6JCPAUIRsxzSv0t9BHoNWrTYfqk=";
4511 - buildDispatcher = src: buildGoModule {
4512 + gitsrht-dispatch = buildGoModule {
4513 inherit src version;
4514 + sourceRoot = "source/gitsrht-dispatch";
4515 pname = "gitsrht-dispatcher";
4516 vendorSha256 = "sha256-qWXPHo86s6iuRBhRMtmD5jxnAWKdrWHtA/iSUkdw89M=";
4518 + # Add support for supplementary groups
4519 + patches/redis-socket/git/v2-0003-gitsrht-dispatch-add-support-for-supplementary-gr.patch
4521 + patchFlags = "-p2";
4524 - buildKeys = src: buildGoModule {
4525 + gitsrht-keys = buildGoModule rec {
4526 inherit src version;
4527 + sourceRoot = "source/gitsrht-keys";
4528 pname = "gitsrht-keys";
4529 - vendorSha256 = "1d94cqy7x0q0agwg515xxsbl70b3qrzxbzsyjhn1pbyj532brn7f";
4530 + vendorSha256 = "sha256-0Rnyo4IRQFhM4LFi0499+xJaboMiKEYOgoR5BumzRE8=";
4532 + # What follows is only to update go-redis
4533 + # go.{mod,sum} could be patched directly but that would be less resilient
4534 + # to changes from upstream, and thus harder to maintain the patching
4535 + # while it hasn't been merged upstream.
4537 + overrideModAttrs = old: {
4538 + inherit patches patchFlags;
4540 + # This is a fixed-output derivation so it is not allowed to reference other derivations,
4541 + # but here srht-keys will be copied to vendor/ by go mod vendor
4542 + ln -s ${srht-keys} srht-keys
4543 + go mod edit -replace git.sr.ht/~sircmpwn/scm.sr.ht/srht-keys=$PWD/srht-keys
4544 + go get github.com/go-redis/redis/v8
4545 + go get github.com/go-redis/redis@none
4548 + # Pass updated go.{mod,sum} from go-modules to gitsrht-keys' vendor/go.{mod,sum}
4550 + cp --reflink=auto go.* $out/
4555 + # Update go-redis to support Unix sockets
4556 + patches/redis-socket/git/v2-0001-gitsrht-keys-update-go-redis-to-support-Unix-sock.patch
4558 + patchFlags = "-p2";
4559 + postConfigure = ''
4560 + cp -v vendor/go.{mod,sum} .
4564 - buildUpdateHook = src: buildGoModule {
4565 + gitsrht-update-hook = buildGoModule rec {
4566 inherit src version;
4567 + sourceRoot = "source/gitsrht-update-hook";
4568 pname = "gitsrht-update-hook";
4569 - vendorSha256 = "0fwzqpjv8x5y3w3bfjd0x0cvqjjak23m0zj88hf32jpw49xmjkih";
4571 + vendorSha256 = "sha256-UoHxGVYEgTDqFzVQ2Dv6BRT4jVt+/QpNqEH3G2UWFjs=";
4573 - updateHook = buildUpdateHook "${src}/gitsrht-update-hook";
4574 + # What follows is only to update go-redis
4576 + overrideModAttrs = old: {
4577 + inherit patches patchFlags;
4579 + # This is a fixed-output derivation so it is not allowed to reference other derivations,
4580 + # but here srht-keys will be copied to vendor/ by go mod vendor
4581 + ln -s ${srht-keys} srht-keys
4582 + go mod edit -replace git.sr.ht/~sircmpwn/scm.sr.ht/srht-keys=$PWD/srht-keys
4583 + go get github.com/go-redis/redis/v8
4584 + go get github.com/go-redis/redis@none
4587 + # Pass updated go.{mod,sum} from go-modules to gitsrht-keys' vendor/go.{mod,sum}
4589 + cp --reflink=auto go.* $out/
4594 + # Update go-redis to support Unix sockets
4595 + patches/redis-socket/git/v2-0002-gitsrht-update-hook-update-go-redis-to-support-Un.patch
4597 + patchFlags = "-p2";
4598 + postConfigure = ''
4599 + cp -v vendor/go.{mod,sum} .
4604 buildPythonPackage rec {
4605 @@ -63,19 +130,21 @@ buildPythonPackage rec {
4609 - cp ${buildShell "${src}/gitsrht-shell"}/bin/gitsrht-shell $out/bin/gitsrht-shell
4610 - cp ${buildDispatcher "${src}/gitsrht-dispatch"}/bin/gitsrht-dispatch $out/bin/gitsrht-dispatch
4611 - cp ${buildKeys "${src}/gitsrht-keys"}/bin/gitsrht-keys $out/bin/gitsrht-keys
4612 - cp ${updateHook}/bin/gitsrht-update-hook $out/bin/gitsrht-update-hook
4613 + cp ${gitsrht-shell}/bin/gitsrht-shell $out/bin/gitsrht-shell
4614 + cp ${gitsrht-dispatch}/bin/gitsrht-dispatch $out/bin/gitsrht-dispatch
4615 + cp ${gitsrht-keys}/bin/gitsrht-keys $out/bin/gitsrht-keys
4616 + cp ${gitsrht-update-hook}/bin/gitsrht-update-hook $out/bin/gitsrht-update-hook
4619 - inherit updateHook;
4620 + inherit gitsrht-shell gitsrht-dispatch gitsrht-keys gitsrht-update-hook;
4623 + pythonImportsCheck = [ "gitsrht" ];
4626 homepage = "https://git.sr.ht/~sircmpwn/git.sr.ht";
4627 description = "Git repository hosting service for the sr.ht network";
4628 - license = licenses.agpl3;
4629 + license = licenses.agpl3Only;
4630 maintainers = with maintainers; [ eadwu ];
4633 diff --git a/pkgs/applications/version-management/sourcehut/hg.nix b/pkgs/applications/version-management/sourcehut/hg.nix
4634 index cddb76cabf2..1d6062d81cc 100644
4635 --- a/pkgs/applications/version-management/sourcehut/hg.nix
4636 +++ b/pkgs/applications/version-management/sourcehut/hg.nix
4639 buildPythonPackage rec {
4641 - version = "0.27.4";
4642 + version = "0.27.6";
4645 url = "https://hg.sr.ht/~sircmpwn/hg.sr.ht";
4647 - sha256 = "1c0qfi0gmbfngvds6917fy9ii2iglawn429757rh7b4bvzn7n6mr";
4648 + sha256 = "ibijvKjS4CiWTYrO6Qdh3RkD0EUE7BY8wjdPwrD6vkA=";
4651 nativeBuildInputs = srht.nativeBuildInputs;
4652 @@ -32,10 +32,12 @@ buildPythonPackage rec {
4653 export SRHT_PATH=${srht}/${python.sitePackages}/srht
4656 + pythonImportsCheck = [ "hgsrht" ];
4659 homepage = "https://git.sr.ht/~sircmpwn/hg.sr.ht";
4660 description = "Mercurial repository hosting service for the sr.ht network";
4661 - license = licenses.agpl3;
4662 + license = licenses.agpl3Only;
4663 maintainers = with maintainers; [ eadwu ];
4666 diff --git a/pkgs/applications/version-management/sourcehut/hub.nix b/pkgs/applications/version-management/sourcehut/hub.nix
4667 index 17cb3fe4b61..31191cba713 100644
4668 --- a/pkgs/applications/version-management/sourcehut/hub.nix
4669 +++ b/pkgs/applications/version-management/sourcehut/hub.nix
4672 buildPythonPackage rec {
4674 - version = "0.13.1";
4675 + version = "0.13.8";
4677 src = fetchFromSourcehut {
4678 owner = "~sircmpwn";
4681 - sha256 = "sha256-Kqzy4mh5Nn1emzHBco/LVuXro/tW3NX+OYqdEwBSQ/U=";
4682 + sha256 = "sha256-RsRJxwViEoQLh86o+8kQE5PBlLrOyIFM7hkSGjXhqdg=";
4685 nativeBuildInputs = srht.nativeBuildInputs;
4686 @@ -26,11 +26,12 @@ buildPythonPackage rec {
4689 dontUseSetuptoolsCheck = true;
4690 + pythonImportsCheck = [ "hubsrht" ];
4693 homepage = "https://git.sr.ht/~sircmpwn/hub.sr.ht";
4694 description = "Project hub service for the sr.ht network";
4695 - license = licenses.agpl3;
4696 + license = licenses.agpl3Only;
4697 maintainers = with maintainers; [ eadwu ];
4700 diff --git a/pkgs/applications/version-management/sourcehut/lists.nix b/pkgs/applications/version-management/sourcehut/lists.nix
4701 index b419b49f7b5..0882241401a 100644
4702 --- a/pkgs/applications/version-management/sourcehut/lists.nix
4703 +++ b/pkgs/applications/version-management/sourcehut/lists.nix
4706 buildPythonPackage rec {
4707 pname = "listssrht";
4708 - version = "0.48.19";
4709 + version = "0.49.3";
4711 src = fetchFromSourcehut {
4712 owner = "~sircmpwn";
4713 repo = "lists.sr.ht";
4715 - sha256 = "sha256-bsakEMyvWaxiE4/SGcAP4mlGG9jkdHfFxpt9H+TJn/8=";
4716 + sha256 = "sha256-kEzKgB8godIL7hEXMrqaxVte6RJAegjT4keZifXbOq0=";
4719 nativeBuildInputs = srht.nativeBuildInputs;
4720 @@ -37,10 +37,12 @@ buildPythonPackage rec {
4721 export SRHT_PATH=${srht}/${python.sitePackages}/srht
4724 + pythonImportsCheck = [ "listssrht" ];
4727 homepage = "https://git.sr.ht/~sircmpwn/lists.sr.ht";
4728 description = "Mailing list service for the sr.ht network";
4729 - license = licenses.agpl3;
4730 + license = licenses.agpl3Only;
4731 maintainers = with maintainers; [ eadwu ];
4734 diff --git a/pkgs/applications/version-management/sourcehut/man.nix b/pkgs/applications/version-management/sourcehut/man.nix
4735 index bd331f000a7..47c6bb0ac4f 100644
4736 --- a/pkgs/applications/version-management/sourcehut/man.nix
4737 +++ b/pkgs/applications/version-management/sourcehut/man.nix
4740 buildPythonPackage rec {
4742 - version = "0.15.12";
4743 + version = "0.15.20";
4745 src = fetchFromSourcehut {
4746 owner = "~sircmpwn";
4749 - sha256 = "sha256-MqH/8K9XRvEg6P7GHE6XXtWnhDP3wT8iGoNaFtYQbio=";
4750 + sha256 = "sha256-ulwdrVrw2bwdafgc3NrJ1J15evQ5btpHLTaiqsyA58U=";
4753 nativeBuildInputs = srht.nativeBuildInputs;
4754 @@ -29,10 +29,12 @@ buildPythonPackage rec {
4755 export SRHT_PATH=${srht}/${python.sitePackages}/srht
4758 + pythonImportsCheck = [ "mansrht" ];
4761 homepage = "https://git.sr.ht/~sircmpwn/man.sr.ht";
4762 description = "Wiki service for the sr.ht network";
4763 - license = licenses.agpl3;
4764 + license = licenses.agpl3Only;
4765 maintainers = with maintainers; [ eadwu ];
4768 diff --git a/pkgs/applications/version-management/sourcehut/meta.nix b/pkgs/applications/version-management/sourcehut/meta.nix
4769 index a285d484ed2..dbb0483c5bb 100644
4770 --- a/pkgs/applications/version-management/sourcehut/meta.nix
4771 +++ b/pkgs/applications/version-management/sourcehut/meta.nix
4776 - version = "0.53.14";
4777 + version = "0.54.4";
4779 src = fetchFromSourcehut {
4780 owner = "~sircmpwn";
4781 repo = "meta.sr.ht";
4783 - sha256 = "sha256-/+r/XLDkcSTW647xPMh5bcJmR2xZNNH74AJ5jemna2k=";
4784 + sha256 = "sha256-MleyF6aqFWbYtxRdMHXpy7HBgJKL9doBmDcYLLe8bW4=";
4787 buildApi = src: buildGoModule {
4788 inherit src version;
4789 pname = "metasrht-api";
4790 - vendorSha256 = "sha256-eZyDrr2VcNMxI++18qUy7LA1Q1YDlWCoRtl00L8lfR4=";
4791 + vendorSha256 = "sha256-gi+dGQPVzrZI+1s9SSa2M3bdgi8vwpR/ofaLG2ZX4kU=";
4795 @@ -66,10 +66,12 @@ buildPythonPackage rec {
4796 cp ${buildApi "${src}/api/"}/bin/api $out/bin/metasrht-api
4799 + pythonImportsCheck = [ "metasrht" ];
4802 homepage = "https://git.sr.ht/~sircmpwn/meta.sr.ht";
4803 description = "Account management service for the sr.ht network";
4804 - license = licenses.agpl3;
4805 + license = licenses.agpl3Only;
4806 maintainers = with maintainers; [ eadwu ];
4809 diff --git a/pkgs/applications/version-management/sourcehut/pages-fix-syntax-error-in-schema.sql.patch b/pkgs/applications/version-management/sourcehut/pages-fix-syntax-error-in-schema.sql.patch
4810 new file mode 100644
4811 index 00000000000..9b3f6fbc6fb
4813 +++ b/pkgs/applications/version-management/sourcehut/pages-fix-syntax-error-in-schema.sql.patch
4815 +From 3df160ad289b25574322f587095d00d6641f057c Mon Sep 17 00:00:00 2001
4816 +From: Juan Picca <juan.picca@jumapico.uy>
4817 +Date: Wed, 21 Jul 2021 08:26:56 -0300
4818 +Subject: [PATCH] Fix syntax error in schema.sql
4821 + schema.sql | 4 ++--
4822 + 1 file changed, 2 insertions(+), 2 deletions(-)
4824 +diff --git a/schema.sql b/schema.sql
4825 +index 168377f..2e473ea 100644
4828 +@@ -28,8 +28,8 @@ CREATE TABLE sites (
4829 + user_id integer NOT NULL references "user"(id),
4830 + domain varchar NOT NULL,
4831 + protocol protocol NOT NULL,
4832 +- version varchar NOT NULL
4833 +- UNIQUE (domain, protocol),
4834 ++ version varchar NOT NULL,
4835 ++ UNIQUE (domain, protocol)
4842 diff --git a/pkgs/applications/version-management/sourcehut/pages.nix b/pkgs/applications/version-management/sourcehut/pages.nix
4843 new file mode 100644
4844 index 00000000000..d04182251a7
4846 +++ b/pkgs/applications/version-management/sourcehut/pages.nix
4849 +, fetchFromSourcehut
4852 +buildGoModule rec {
4853 + pname = "pagessrht";
4854 + version = "0.4.8";
4856 + src = fetchFromSourcehut {
4857 + owner = "~sircmpwn";
4858 + repo = "pages.sr.ht";
4860 + sha256 = "sha256-z9w8v5e6LY6VUEczltyD55KEUUH7Gw1vUO00KPmT+D8=";
4863 + vendorSha256 = "sha256-xOd9i+PNlLxZrw/+z/C9V+AbOLEociW2YHY+x1K+mJI=";
4866 + # Upstream after 0.4.8
4867 + ./pages-fix-syntax-error-in-schema.sql.patch
4871 + mkdir -p $out/share/sql/
4872 + cp -r -t $out/share/sql/ schema.sql migrations
4875 + meta = with lib; {
4876 + homepage = "https://git.sr.ht/~sircmpwn/pages.sr.ht";
4877 + description = "Web hosting service for the sr.ht network";
4878 + license = licenses.agpl3Only;
4879 + maintainers = with maintainers; [ eadwu ];
4882 diff --git a/pkgs/applications/version-management/sourcehut/paste.nix b/pkgs/applications/version-management/sourcehut/paste.nix
4883 index 0d8c9135493..ecd31c25deb 100644
4884 --- a/pkgs/applications/version-management/sourcehut/paste.nix
4885 +++ b/pkgs/applications/version-management/sourcehut/paste.nix
4888 buildPythonPackage rec {
4889 pname = "pastesrht";
4890 - version = "0.12.1";
4891 + version = "0.12.4";
4893 src = fetchFromSourcehut {
4894 owner = "~sircmpwn";
4895 repo = "paste.sr.ht";
4897 - sha256 = "sha256-QQhd2LeH9BLmlHilhsv+9fZ+RPNmEMSmOpFA3dsMBFc=";
4898 + sha256 = "sha256-hFjWa7L7JiQoG3Hm9NyoP2FNypDiW+nGDmQ2DoZkAIw=";
4901 nativeBuildInputs = srht.nativeBuildInputs;
4902 @@ -29,10 +29,12 @@ buildPythonPackage rec {
4903 export SRHT_PATH=${srht}/${python.sitePackages}/srht
4906 + pythonImportsCheck = [ "pastesrht" ];
4909 homepage = "https://git.sr.ht/~sircmpwn/paste.sr.ht";
4910 description = "Ad-hoc text file hosting service for the sr.ht network";
4911 - license = licenses.agpl3;
4912 + license = licenses.agpl3Only;
4913 maintainers = with maintainers; [ eadwu ];
4916 diff --git a/pkgs/applications/version-management/sourcehut/disable-npm-install.patch b/pkgs/applications/version-management/sourcehut/patches/disable-npm-install.patch
4917 similarity index 100%
4918 rename from pkgs/applications/version-management/sourcehut/disable-npm-install.patch
4919 rename to pkgs/applications/version-management/sourcehut/patches/disable-npm-install.patch
4920 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/v2-0001-add-Unix-socket-support-for-redis-host.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/v2-0001-add-Unix-socket-support-for-redis-host.patch
4921 new file mode 100644
4922 index 00000000000..46241bc847f
4924 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/v2-0001-add-Unix-socket-support-for-redis-host.patch
4926 +From c0ccc8db051a2f8278edf59b41ed238fa71aa4c0 Mon Sep 17 00:00:00 2001
4927 +From: Julien Moutinho <julm+srht@sourcephile.fr>
4928 +Date: Mon, 23 Aug 2021 18:43:18 +0200
4929 +Subject: [PATCH core.sr.ht v2] add Unix socket support for redis-host=
4932 + srht/redis.py | 11 ++---------
4933 + 1 file changed, 2 insertions(+), 9 deletions(-)
4935 +diff --git a/srht/redis.py b/srht/redis.py
4936 +index 8a9347c..2e91c35 100644
4937 +--- a/srht/redis.py
4938 ++++ b/srht/redis.py
4940 +-from redis import Redis
4941 ++from redis import from_url
4942 + from srht.config import cfg
4943 +-from urllib.parse import urlparse
4945 +-url = cfg("sr.ht", "redis-host", "redis://localhost")
4946 +-url = urlparse(url)
4948 +-redis = Redis(host=url.hostname,
4949 +- port=(url.port or 6379),
4950 +- password=url.password,
4951 +- db=int(url.path[1:]) if url.path else 0)
4952 ++redis = from_url(cfg("sr.ht", "redis-host", "redis://localhost"))
4956 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0001-gitsrht-keys-update-go-redis-to-support-Unix-sock.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0001-gitsrht-keys-update-go-redis-to-support-Unix-sock.patch
4957 new file mode 100644
4958 index 00000000000..24fbc26399c
4960 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0001-gitsrht-keys-update-go-redis-to-support-Unix-sock.patch
4962 +From 466528eabef3123c715420472dc2cc15e8807bdf Mon Sep 17 00:00:00 2001
4963 +From: Julien Moutinho <julm+srht@sourcephile.fr>
4964 +Date: Fri, 27 Aug 2021 15:38:28 +0200
4965 +Subject: [PATCH git.sr.ht v2 1/5] gitsrht-keys: update go-redis to support
4969 + gitsrht-keys/main.go | 6 +++---
4970 + 1 file changed, 3 insertions(+), 3 deletions(-)
4972 +diff --git a/gitsrht-keys/main.go b/gitsrht-keys/main.go
4973 +index 0c1aea1..b4278c3 100644
4974 +--- a/gitsrht-keys/main.go
4975 ++++ b/gitsrht-keys/main.go
4976 +@@ -5,7 +5,7 @@ import (
4980 +- goredis "github.com/go-redis/redis"
4981 ++ goRedis "github.com/go-redis/redis/v8"
4982 + "github.com/vaughan0/go-ini"
4983 + "git.sr.ht/~sircmpwn/scm.sr.ht/srht-keys"
4985 +@@ -53,11 +53,11 @@ func main() {
4986 + if redisHost == "" {
4987 + redisHost = "redis://localhost:6379"
4989 +- ropts, err := goredis.ParseURL(redisHost)
4990 ++ ropts, err := goRedis.ParseURL(redisHost)
4992 + logger.Fatalf("Failed to parse redis host: %v", err)
4994 +- redis := goredis.NewClient(ropts)
4995 ++ redis := goRedis.NewClient(ropts)
4997 + keyType, b64key, prefix, err = srhtkeys.ParseArgs(logger)
5002 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0002-gitsrht-update-hook-update-go-redis-to-support-Un.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0002-gitsrht-update-hook-update-go-redis-to-support-Un.patch
5003 new file mode 100644
5004 index 00000000000..36566a6f7d9
5006 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0002-gitsrht-update-hook-update-go-redis-to-support-Un.patch
5008 +From 4f947b26e42d3bcab6d675718eed28ca2fdf4762 Mon Sep 17 00:00:00 2001
5009 +From: Julien Moutinho <julm+srht@sourcephile.fr>
5010 +Date: Fri, 27 Aug 2021 15:39:29 +0200
5011 +Subject: [PATCH git.sr.ht v2 2/5] gitsrht-update-hook: update go-redis to
5012 + support Unix sockets
5015 + gitsrht-update-hook/options.go | 16 +++++++++-------
5016 + gitsrht-update-hook/post-update.go | 8 ++++----
5017 + gitsrht-update-hook/update.go | 8 ++++----
5018 + 3 files changed, 17 insertions(+), 15 deletions(-)
5020 +diff --git a/gitsrht-update-hook/options.go b/gitsrht-update-hook/options.go
5021 +index 8efbb0a..4e9d294 100644
5022 +--- a/gitsrht-update-hook/options.go
5023 ++++ b/gitsrht-update-hook/options.go
5035 +- goredis "github.com/go-redis/redis"
5036 ++ goRedis "github.com/go-redis/redis/v8"
5039 ++var ctx = context.Background()
5040 + var options map[string]string
5042 + func loadOptions() {
5043 +@@ -26,19 +28,19 @@ func loadOptions() {
5045 + redisHost = "redis://localhost:6379"
5047 +- ropts, err := goredis.ParseURL(redisHost)
5048 ++ ropts, err := goRedis.ParseURL(redisHost)
5050 + logger.Fatalf("Failed to parse redis host: %v", err)
5052 +- redis := goredis.NewClient(ropts)
5053 ++ redis := goRedis.NewClient(ropts)
5056 + if nopts, ok := os.LookupEnv("GIT_PUSH_OPTION_COUNT"); ok {
5057 + n, _ = strconv.Atoi(nopts)
5058 +- redis.Set(fmt.Sprintf("git.sr.ht.options.%s", uuid),
5059 ++ redis.Set(ctx, fmt.Sprintf("git.sr.ht.options.%s", uuid),
5060 + nopts, 10*time.Minute)
5062 +- nopts, err := redis.Get(fmt.Sprintf(
5063 ++ nopts, err := redis.Get(ctx, fmt.Sprintf(
5064 + "git.sr.ht.options.%s", uuid)).Result()
5067 +@@ -51,12 +53,12 @@ func loadOptions() {
5068 + opt, ok := os.LookupEnv(fmt.Sprintf("GIT_PUSH_OPTION_%d", i))
5069 + optkey := fmt.Sprintf("git.sr.ht.options.%s.%d", uuid, i)
5071 +- opt, err = redis.Get(optkey).Result()
5072 ++ opt, err = redis.Get(ctx, optkey).Result()
5077 +- redis.Set(optkey, opt, 10*time.Minute)
5078 ++ redis.Set(ctx, optkey, opt, 10*time.Minute)
5080 + parts := strings.SplitN(opt, "=", 2)
5081 + if len(parts) == 1 {
5082 +diff --git a/gitsrht-update-hook/post-update.go b/gitsrht-update-hook/post-update.go
5083 +index d14d616..37c08b3 100644
5084 +--- a/gitsrht-update-hook/post-update.go
5085 ++++ b/gitsrht-update-hook/post-update.go
5086 +@@ -15,7 +15,7 @@ import (
5087 + "github.com/go-git/go-git/v5/plumbing"
5088 + "github.com/go-git/go-git/v5/plumbing/object"
5089 + "github.com/go-git/go-git/v5/plumbing/storer"
5090 +- goredis "github.com/go-redis/redis"
5091 ++ goRedis "github.com/go-redis/redis/v8"
5092 + _ "github.com/lib/pq"
5095 +@@ -210,17 +210,17 @@ func postUpdate() {
5097 + redisHost = "redis://localhost:6379"
5099 +- ropts, err := goredis.ParseURL(redisHost)
5100 ++ ropts, err := goRedis.ParseURL(redisHost)
5102 + logger.Fatalf("Failed to parse redis host: %v", err)
5105 +- redis := goredis.NewClient(ropts)
5106 ++ redis := goRedis.NewClient(ropts)
5107 + for i, refname := range refs {
5108 + var oldref, newref string
5109 + var oldobj, newobj object.Object
5110 + updateKey := fmt.Sprintf("update.%s.%s", pushUuid, refname)
5111 +- update, err := redis.Get(updateKey).Result()
5112 ++ update, err := redis.Get(ctx, updateKey).Result()
5113 + if update == "" || err != nil {
5114 + logger.Println("redis.Get: missing key")
5116 +diff --git a/gitsrht-update-hook/update.go b/gitsrht-update-hook/update.go
5117 +index 72c661a..0968cfb 100644
5118 +--- a/gitsrht-update-hook/update.go
5119 ++++ b/gitsrht-update-hook/update.go
5120 +@@ -5,7 +5,7 @@ import (
5124 +- goredis "github.com/go-redis/redis"
5125 ++ goRedis "github.com/go-redis/redis/v8"
5128 + // XXX: This is run once for every single ref that's pushed. If someone pushes
5129 +@@ -26,11 +26,11 @@ func update() {
5131 + redisHost = "redis://localhost:6379"
5133 +- ropts, err := goredis.ParseURL(redisHost)
5134 ++ ropts, err := goRedis.ParseURL(redisHost)
5136 + logger.Fatalf("Failed to parse redis host: %v", err)
5138 +- redis := goredis.NewClient(ropts)
5139 +- redis.Set(fmt.Sprintf("update.%s.%s", pushUuid, refname),
5140 ++ redis := goRedis.NewClient(ropts)
5141 ++ redis.Set(ctx, fmt.Sprintf("update.%s.%s", pushUuid, refname),
5142 + fmt.Sprintf("%s:%s", oldref, newref), 10*time.Minute)
5147 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0003-gitsrht-dispatch-add-support-for-supplementary-gr.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0003-gitsrht-dispatch-add-support-for-supplementary-gr.patch
5148 new file mode 100644
5149 index 00000000000..a96f6430b56
5151 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/git/v2-0003-gitsrht-dispatch-add-support-for-supplementary-gr.patch
5153 +From ef02ce68925888b2bca77713c6321cb33023e026 Mon Sep 17 00:00:00 2001
5154 +From: Julien Moutinho <julm+srht@sourcephile.fr>
5155 +Date: Fri, 27 Aug 2021 17:42:33 +0200
5156 +Subject: [PATCH git.sr.ht v2 3/5] gitsrht-dispatch: add support for
5157 + supplementary groups
5160 + gitsrht-dispatch/main.go | 17 ++++++++++++++---
5161 + 1 file changed, 14 insertions(+), 3 deletions(-)
5163 +diff --git a/gitsrht-dispatch/main.go b/gitsrht-dispatch/main.go
5164 +index d7aee14..5f17b75 100644
5165 +--- a/gitsrht-dispatch/main.go
5166 ++++ b/gitsrht-dispatch/main.go
5167 +@@ -17,6 +17,7 @@ type Dispatcher struct {
5175 +@@ -70,11 +71,20 @@ AuthorizedKeysUser=root`, os.Args[0])
5177 + logger.Fatalf("Error looking up group %s: %v", spec[1], err)
5179 ++ groups, err := user.GroupIds()
5181 ++ logger.Fatalf("Error looking up supplementary groups of user %s: %v", spec[0], err)
5183 ++ gids := make([]int, len(groups))
5184 ++ for i, grp := range groups {
5185 ++ sgid, _ := strconv.Atoi(grp)
5188 + uid, _ := strconv.Atoi(user.Uid)
5189 + gid, _ := strconv.Atoi(group.Gid)
5190 +- dispatchers[uid] = Dispatcher{cmd, uid, gid}
5191 +- logger.Printf("Registered dispatcher for %s(%d):%s(%d): %s",
5192 +- spec[0], uid, spec[1], gid, cmd)
5193 ++ dispatchers[uid] = Dispatcher{cmd, uid, gid, gids}
5194 ++ logger.Printf("Registered dispatcher for %s(%d):%s(%d):(%s): %s",
5195 ++ spec[0], uid, spec[1], gid, strings.Join(groups, ","), cmd)
5198 + var user *osuser.User
5199 +@@ -93,6 +103,7 @@ AuthorizedKeysUser=root`, os.Args[0])
5201 + if dispatcher, ok := dispatchers[uid]; ok {
5202 + logger.Printf("Dispatching to %s", dispatcher.cmd)
5203 ++ syscall.Setgroups(dispatcher.gids)
5204 + syscall.Setgid(dispatcher.gid)
5205 + syscall.Setuid(dispatcher.uid)
5206 + if err := syscall.Exec(dispatcher.cmd, append([]string{
5210 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0001-srht-keys-update-go-redis-to-support-Unix-sockets.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0001-srht-keys-update-go-redis-to-support-Unix-sockets.patch
5211 new file mode 100644
5212 index 00000000000..389cd71751a
5214 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0001-srht-keys-update-go-redis-to-support-Unix-sockets.patch
5216 +From 538ff956141f5b56b77233664d4d4ea5eff8ad08 Mon Sep 17 00:00:00 2001
5217 +From: Julien Moutinho <julm+srht@sourcephile.fr>
5218 +Date: Fri, 27 Aug 2021 12:48:56 +0200
5219 +Subject: [PATCH v2 1/2] srht-keys: update go-redis to support Unix sockets
5222 + srht-keys/srhtkeys.go | 13 ++++++++-----
5223 + 1 file changed, 8 insertions(+), 5 deletions(-)
5225 +diff --git a/srht-keys/srhtkeys.go b/srht-keys/srhtkeys.go
5226 +index be925ed..4cc144c 100644
5227 +--- a/srht-keys/srhtkeys.go
5228 ++++ b/srht-keys/srhtkeys.go
5237 +@@ -12,7 +13,7 @@ import (
5241 +- goredis "github.com/go-redis/redis"
5242 ++ goRedis "github.com/go-redis/redis/v8"
5243 + "github.com/google/uuid"
5244 + _ "github.com/lib/pq"
5245 + "github.com/vaughan0/go-ini"
5246 +@@ -37,6 +38,8 @@ type MetaSSHKey struct {
5247 + Owner MetaUser `json:"owner"`
5250 ++var ctx = context.Background()
5252 + // Stores the SSH key in the database and returns the user's ID.
5253 + func storeKey(logger *log.Logger, db *sql.DB, key *MetaSSHKey) (int, error) {
5254 + logger.Println("Storing meta.sr.ht key in database")
5255 +@@ -84,7 +87,7 @@ func storeKey(logger *log.Logger, db *sql.DB, key *MetaSSHKey) (int, error) {
5258 + func fetchKeysFromMeta(logger *log.Logger, config ini.File,
5259 +- redis *goredis.Client, service string, b64key string) (string, int) {
5260 ++ redis *goRedis.Client, service string, b64key string) (string, int) {
5262 + meta, ok := config.Get("meta.sr.ht", "internal-origin")
5264 +@@ -145,7 +148,7 @@ func fetchKeysFromMeta(logger *log.Logger, config ini.File,
5266 + logger.Printf("Caching SSH key in redis failed: %v", err)
5268 +- redis.Set(cacheKey, cacheBytes, 7*24*time.Hour)
5269 ++ redis.Set(ctx, cacheKey, cacheBytes, 7*24*time.Hour)
5272 + return key.Owner.Username, userId
5273 +@@ -164,11 +167,11 @@ func ParseArgs(logger *log.Logger) (string, string, string, error) {
5276 + func UserFromKey(logger *log.Logger, config ini.File,
5277 +- redis *goredis.Client, service string, b64key string) (string, int) {
5278 ++ redis *goRedis.Client, service string, b64key string) (string, int) {
5280 + cacheKey := fmt.Sprintf("%s.ssh-keys.%s", service, b64key)
5281 + logger.Printf("Cache key for SSH key lookup: %s", cacheKey)
5282 +- cacheBytes, err := redis.Get(cacheKey).Bytes()
5283 ++ cacheBytes, err := redis.Get(ctx, cacheKey).Bytes()
5290 diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0002-srht-keys-update-go.-mod-sum-for-go-redis.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0002-srht-keys-update-go.-mod-sum-for-go-redis.patch
5291 new file mode 100644
5292 index 00000000000..8db7dc674c7
5294 +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/scm/v2-0002-srht-keys-update-go.-mod-sum-for-go-redis.patch
5296 +From d0862969b1470701edded4772337822ca52c8509 Mon Sep 17 00:00:00 2001
5297 +From: Julien Moutinho <julm+srht@sourcephile.fr>
5298 +Date: Fri, 27 Aug 2021 13:06:27 +0200
5299 +Subject: [PATCH v2 2/2] srht-keys: update go.{mod,sum} for go-redis
5302 + srht-keys/go.mod | 2 +-
5303 + srht-keys/go.sum | 103 ++++++++++++++++++++++++++++++++++++++++++++---
5304 + 2 files changed, 99 insertions(+), 6 deletions(-)
5306 +diff --git a/srht-keys/go.mod b/srht-keys/go.mod
5307 +index d275913..8d1c10a 100644
5308 +--- a/srht-keys/go.mod
5309 ++++ b/srht-keys/go.mod
5310 +@@ -4,7 +4,7 @@ go 1.13
5313 + git.sr.ht/~sircmpwn/core-go v0.0.0-20201005173246-a9e49d17a1e6
5314 +- github.com/go-redis/redis v6.15.9+incompatible
5315 ++ github.com/go-redis/redis/v8 v8.11.3
5316 + github.com/google/uuid v1.1.1
5317 + github.com/lib/pq v1.8.0
5318 + github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec
5319 +diff --git a/srht-keys/go.sum b/srht-keys/go.sum
5320 +index 974326e..a264a26 100644
5321 +--- a/srht-keys/go.sum
5322 ++++ b/srht-keys/go.sum
5324 +-git.sr.ht/~sircmpwn/core-go v0.0.0-20200820135923-98806e712f5e h1:TJqf/neVU5peFAS9WcR1aADXcflPOvAd7ABEirmU7m0=
5325 +-git.sr.ht/~sircmpwn/core-go v0.0.0-20200820135923-98806e712f5e/go.mod h1:aXSNgRsGoI3tTFKlwD0xm2htbEzKlR2xUm1osRxfhOM=
5326 + git.sr.ht/~sircmpwn/core-go v0.0.0-20201005173246-a9e49d17a1e6 h1:Ky6HzcRmbMUxOrWXv04+mb97GkyxO/Nx7v8uJBUdpNk=
5327 + git.sr.ht/~sircmpwn/core-go v0.0.0-20201005173246-a9e49d17a1e6/go.mod h1:HpPX22ilJUWKOA4NDhrOcIyblQhdiKHPg4oMJFYdh0Y=
5328 ++github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
5329 ++github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5330 + github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5331 ++github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5332 ++github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5333 ++github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
5334 ++github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
5335 ++github.com/fernet/fernet-go v0.0.0-20191111064656-eff2850e6001 h1:/UMxx5lGDg30aioUL9e7xJnbJfJeX7vhcm57fa5udaI=
5336 + github.com/fernet/fernet-go v0.0.0-20191111064656-eff2850e6001/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c=
5337 +-github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
5338 +-github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
5339 ++github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
5340 ++github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
5341 ++github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
5342 ++github.com/go-redis/redis/v8 v8.11.3 h1:GCjoYp8c+yQTJfc0n69iwSiHjvuAdruxl7elnZCxgt8=
5343 ++github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc=
5344 ++github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
5345 ++github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
5346 ++github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
5347 ++github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
5348 ++github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
5349 ++github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
5350 ++github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
5351 ++github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
5352 ++github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
5353 ++github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
5354 ++github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
5355 ++github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
5356 ++github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
5357 ++github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5358 ++github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5359 ++github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
5360 ++github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5361 + github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
5362 + github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5363 ++github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
5364 + github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
5365 + github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
5366 ++github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
5367 ++github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
5368 ++github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
5369 ++github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
5370 ++github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
5371 ++github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
5372 ++github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
5373 ++github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
5374 ++github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
5375 ++github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU=
5376 ++github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
5377 ++github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5378 + github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5379 + github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5380 ++github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
5381 ++github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
5382 + github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5383 + github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec h1:DGmKwyZwEB8dI7tbLt/I/gQuP559o/0FrAkHKlQM/Ks=
5384 + github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec/go.mod h1:owBmyHYMLkxyrugmfwE/DLJyW8Ro9mkphwuVErQ0iUw=
5385 ++github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
5386 + golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5387 +-golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
5388 ++golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
5389 ++golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
5390 + golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
5391 ++golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
5392 ++golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
5393 + golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5394 ++golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
5395 ++golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
5396 ++golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
5397 ++golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
5398 ++golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
5399 ++golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5400 ++golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5401 ++golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5402 ++golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5403 + golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5404 + golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5405 ++golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5406 ++golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5407 ++golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5408 ++golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5409 ++golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5410 ++golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5411 ++golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5412 ++golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
5413 ++golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5414 ++golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
5415 + golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5416 ++golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
5417 ++golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
5418 ++golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
5419 ++golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5420 ++golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
5421 ++golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
5422 ++golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5423 ++golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5424 ++golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5425 ++golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
5426 ++golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5427 ++google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
5428 ++google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
5429 ++google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
5430 ++google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
5431 ++google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
5432 ++google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
5433 ++google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
5434 ++google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
5435 ++google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
5436 ++gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
5437 + gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5438 ++gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
5439 ++gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
5440 ++gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
5441 ++gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5442 ++gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5443 ++gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5444 ++gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
5445 ++gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
5446 ++gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
5447 + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5451 diff --git a/pkgs/applications/version-management/sourcehut/patches/srht-update-profiles/0001-fix-disgusting-hack-in-the-case-of-buildsrht.patch b/pkgs/applications/version-management/sourcehut/patches/srht-update-profiles/0001-fix-disgusting-hack-in-the-case-of-buildsrht.patch
5452 new file mode 100644
5453 index 00000000000..9db31c9e554
5455 +++ b/pkgs/applications/version-management/sourcehut/patches/srht-update-profiles/0001-fix-disgusting-hack-in-the-case-of-buildsrht.patch
5457 +From 8bb7c927c815582b26d026f4b2ea72f0245ccab7 Mon Sep 17 00:00:00 2001
5458 +From: Julien Moutinho <julm+srht@sourcephile.fr>
5459 +Date: Mon, 23 Aug 2021 18:45:07 +0200
5460 +Subject: [PATCH core.sr.ht] fix "disgusting hack" in the case of buildsrht
5463 + srht-update-profiles | 2 +-
5464 + 1 file changed, 1 insertion(+), 1 deletion(-)
5466 +diff --git a/srht-update-profiles b/srht-update-profiles
5467 +index 0d9588c..063d6e2 100755
5468 +--- a/srht-update-profiles
5469 ++++ b/srht-update-profiles
5470 +@@ -3,7 +3,7 @@ import sys
5472 + sys.path.append(os.getcwd())
5473 + site = sys.argv[1]
5474 +-app = __import__(site.replace(".", "") + ".app").app.app # disgusting hack
5475 ++app = __import__(site.replace(".", "").replace("builds","build") + ".app").app.app # disgusting hack
5476 + from srht.config import cfg
5477 + from srht.database import db, DbSession
5478 + db = DbSession(cfg(site, "connection-string"))
5482 diff --git a/pkgs/applications/version-management/sourcehut/scm.nix b/pkgs/applications/version-management/sourcehut/scm.nix
5483 index 1f385265360..6737251f833 100644
5484 --- a/pkgs/applications/version-management/sourcehut/scm.nix
5485 +++ b/pkgs/applications/version-management/sourcehut/scm.nix
5488 , fetchFromSourcehut
5490 , buildPythonPackage
5499 buildPythonPackage rec {
5501 - version = "0.22.9";
5502 + version = "0.22.13";
5504 src = fetchFromSourcehut {
5505 owner = "~sircmpwn";
5508 - sha256 = "sha256-327G6C8FW+iZx+167D7TQsFtV6FGc8MpMVo9L/cUUqU=";
5509 + sha256 = "sha256-9iRmQBt4Cxr5itTk34b8iDRyXYDHTDfZjV0SIDT/kkM=";
5513 + srht-keys = buildGoModule rec {
5514 + inherit src version;
5515 + sourceRoot = "source/srht-keys";
5516 + pname = "srht-keys";
5517 + vendorSha256 = "sha256-lQk1dymMCefHMFJhO3yC/muBP/cxI//5Yz991D2YZY4=";
5519 + # What follows is only to update go-redis
5520 + # go.{mod,sum} could be patched directly but that would be less resilient
5521 + # to changes from upstream, and thus harder to maintain the patching
5522 + # while it hasn't been merged upstream.
5524 + overrideModAttrs = old: {
5525 + inherit patches patchFlags;
5527 + go get github.com/go-redis/redis/v8
5528 + go get github.com/go-redis/redis@none
5531 + # Pass updated go.{mod,sum} from go-modules to srht-keys's vendor/go.{mod,sum}
5533 + cp --reflink=auto go.* $out
5538 + # Update go-redis to support Unix sockets
5539 + patches/redis-socket/scm/v2-0001-srht-keys-update-go-redis-to-support-Unix-sockets.patch
5541 + patchFlags = "-p2";
5543 + cp --reflink=auto *.go vendor/go.* $out
5548 nativeBuildInputs = srht.nativeBuildInputs;
5549 @@ -33,11 +70,12 @@ buildPythonPackage rec {
5552 dontUseSetuptoolsCheck = true;
5553 + pythonImportsCheck = [ "scmsrht" ];
5556 homepage = "https://git.sr.ht/~sircmpwn/git.sr.ht";
5557 description = "Shared support code for sr.ht source control services.";
5558 - license = licenses.agpl3;
5559 + license = licenses.agpl3Only;
5560 maintainers = with maintainers; [ eadwu ];
5563 diff --git a/pkgs/applications/version-management/sourcehut/todo.nix b/pkgs/applications/version-management/sourcehut/todo.nix
5564 index 85e1f5637b6..e091341c7dd 100644
5565 --- a/pkgs/applications/version-management/sourcehut/todo.nix
5566 +++ b/pkgs/applications/version-management/sourcehut/todo.nix
5569 buildPythonPackage rec {
5571 - version = "0.64.14";
5572 + version = "0.64.24";
5574 src = fetchFromSourcehut {
5575 owner = "~sircmpwn";
5576 repo = "todo.sr.ht";
5578 - sha256 = "sha256-huIAhn6h1F5w5ST4/yBwr82kAzyYwhLu+gpRuOQgnsE=";
5579 + sha256 = "sha256-H2XGOxHyurXw3GekZJXSO6RMChRjNbjqxik/mvFVqfY=";
5582 nativeBuildInputs = srht.nativeBuildInputs;
5583 @@ -42,11 +42,12 @@ buildPythonPackage rec {
5586 dontUseSetuptoolsCheck = true;
5587 + pythonImportsCheck = [ "todosrht" ];
5590 homepage = "https://todo.sr.ht/~sircmpwn/todo.sr.ht";
5591 description = "Ticket tracking service for the sr.ht network";
5592 - license = licenses.agpl3;
5593 + license = licenses.agpl3Only;
5594 maintainers = with maintainers; [ eadwu ];
5597 diff --git a/pkgs/applications/version-management/sourcehut/update.sh b/pkgs/applications/version-management/sourcehut/update.sh
5598 index 156d4cc35e4..6733046d000 100755
5599 --- a/pkgs/applications/version-management/sourcehut/update.sh
5600 +++ b/pkgs/applications/version-management/sourcehut/update.sh
5602 #! /usr/bin/env nix-shell
5603 #! nix-shell -i bash -p git mercurial common-updater-scripts
5606 -cd "$(dirname "${BASH_SOURCE[0]}")"
5607 +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
5610 +trap 'rm -rf "$tmp"' EXIT
5613 (cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
5614 @@ -13,19 +16,18 @@ version() {
5618 - (cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.src.drvAttrs.url" | tr -d '"')
5619 + nix-instantiate --eval --strict --expr " with import $root {}; let src = sourcehut.python.pkgs.$1.drvAttrs.src; in src.url or src.meta.homepage" | tr -d '"'
5622 get_latest_version() {
5623 src="$(src_url "$1")"
5627 if [ "$1" = "hgsrht" ]; then
5628 - hg clone "$src" "$tmp" &> /dev/null
5629 + hg clone "$src" "$tmp" >/dev/null
5630 printf "%s" "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')"
5632 - git clone "$src" "$tmp"
5633 - printf "%s" "$(cd "$tmp" && git describe $(git rev-list --tags --max-count=1))"
5634 + git clone "$src" "$tmp" >/dev/null
5635 + printf "%s" "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")"
5639 @@ -36,19 +38,33 @@ update_version() {
5641 (cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
5643 + # Update vendorSha256 of Go modules
5644 + nixFile="${1%srht}".nix
5645 + nixFile="${nixFile/build/builds}"
5647 + while "$retry"; do
5649 + exec < <(exec nix -L build -f "$root" sourcehut.python.pkgs."$1" 2>&1)
5650 + while IFS=' :' read -r origin hash; do
5652 + (expected|specified) oldHash="$hash";;
5653 + (got) sed -i "s|$oldHash|$(nix hash to-sri --type sha256 "$hash")|" "$nixFile"; retry=true; break;;
5654 + (*) printf >&2 "%s\n" "$origin${hash:+:$hash}"
5659 git add "$default_nix"
5660 - git commit -m "$1: $version_old -> $version"
5661 + git commit -m "sourcehut.$1: $version_old -> $version"
5664 -services=( "srht" "buildsrht" "dispatchsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
5665 - "metasrht" "pastesrht" "todosrht" "scmsrht" )
5667 -# Whether or not a specific service is requested
5668 -if [ -n "$1" ]; then
5669 - version="$(get_latest_version "$1")"
5670 - (cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
5671 +if [ $# -gt 0 ]; then
5674 - for service in "${services[@]}"; do
5675 - update_version "$service"
5677 + services=( "srht" "buildsrht" "dispatchsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
5678 + "metasrht" "pagessrht" "pastesrht" "todosrht" "scmsrht" )
5681 +for service in "${services[@]}"; do
5682 + update_version "$service"