1 { pkgs, lib, config, ... }:
3 inherit (config) networking;
4 inherit (config.services) nginx sourcehut;
5 inherit (config.users) users groups;
6 inherit (config.security) gnupg;
7 domain = "code.${networking.domain}";
10 security.gnupg.secrets = lib.genAttrs [
11 "sourcehut/network-key"
12 "sourcehut/service-key"
13 "sourcehut/webhook-key"
14 "sourcehut/oauth-client-secret"
17 "metasrht-api.service"
21 "todosrht-lmtp.service"
23 systemdConfig.before = srhts;
24 systemdConfig.wantedBy = srhts;
29 secretKey = "12345678";
33 #environment.systemPackages = [ pkgs.minio-client ];
34 services.sourcehut = {
36 listenAddress = "localhost";
40 images.nixos.unstable.x86_64 =
41 import sourcehut/builds/nixos-unstable.nix
42 "x86_64-linux" { inherit pkgs lib config; };
45 #dispatch.enable = true;
56 postgresql.enable = true;
57 postfix.enable = true;
61 useACMEHost = networking.domain;
65 environment = "production";
66 global-domain = domain;
67 owner-email = "julm+srht@sourcephile.fr";
68 owner-name = "Sourcephile";
69 site-blurb = "a simple free software forge";
70 site-info = "https://${domain}";
71 site-name = "Sourcephile";
72 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen network
73 network-key = gnupg.secrets."sourcehut/network-key".path;
74 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen service
75 service-key = gnupg.secrets."sourcehut/service-key".path;
76 #redis-host = "redis://localhost:6379/";
79 s3-upstream = "localhost";
80 s3-access-key = "12345";
81 s3-secret-key = pkgs.writeText "s3-secret-key" "12345678";
83 # nix shell nixpkgs#sourcehut.metasrht -c metasrht-manageuser -t admin -e mymail@gmail.com misuzu
85 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
86 oauth-client-id = "299db9f9c2013170";
90 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
91 oauth-client-id = "299db9f9c2013170";
94 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
95 oauth-client-id = "299db9f9c2013170";
96 s3-bucket = "pagesbuck";
99 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
100 oauth-client-id = "299db9f9c2013170";
103 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
104 oauth-client-id = "299db9f9c2013170";
108 "meta.sr.ht::settings" = {
109 onboarding-redirect = "https://meta.${domain}";
110 registration = false;
112 "meta.sr.ht::api" = {
113 #internal-ipnet= [ "127.0.0.0/8" "::1/128" "192.168.0.0/16" "10.0.0.0/8"];
116 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
117 oauth-client-id = "299db9f9c2013170";
120 outgoing-domain = "https://git.${domain}";
121 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
122 oauth-client-id = "gitsrht";
125 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
126 oauth-client-id = "299db9f9c2013170";
129 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
130 oauth-client-id = "299db9f9c2013170";
132 "lists.sr.ht::worker" = {
133 #sock = "/var/lib/postfix/queue/private/srht-lmtp";
135 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen webhook
136 #webhooks.private-key= "U7yd/8mGs/v0O3kId4jpeSghUCa9tqP1fYQwSV8UOqo=";
137 webhooks.private-key = gnupg.secrets."sourcehut/webhook-key".path;
139 smtp-host = "localhost";
142 smtp-password = null;
143 smtp-from = "julm+hut@${networking.domain}";
144 error-to = "julm+hut+error@${networking.domain}";
145 error-from = "julm+hut+error@${networking.domain}";
152 fileSystems."/var/lib/sourcehut" = {
153 device = "rpool/var/sourcehut";
156 services.sanoid.datasets = {
157 "rpool/var/sourcehut" = {
158 use_template = [ "snap" ];
163 virtualHosts."~^(?<subdomain>[^.]+).hut.${networking.domain}" = {
165 useACMEHost = networking.domain;
166 globalRedirect = "$subdomain.code.${networking.domain}";
168 virtualHosts."meta.${domain}" = {
169 locations."/query".extraConfig = lib.mkForce ''
170 if ($request_method = 'OPTIONS') {
171 ${nginx.configs.https_add_headers}
172 add_header 'Access-Control-Allow-Origin' '*';
173 add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
174 add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
175 add_header 'Access-Control-Max-Age' 1728000;
176 add_header 'Content-Type' 'text/plain; charset=utf-8';
177 add_header 'Content-Length' 0;
181 ${nginx.configs.https_add_headers}
182 add_header 'Access-Control-Allow-Origin' '*';
183 add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
184 add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
185 add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';