1 { pkgs, lib, config, ... }:
3 inherit (config) networking;
4 inherit (config.services) nginx sourcehut;
5 inherit (config.security) gnupg;
6 domain = "code.${networking.domain}";
9 security.gnupg.secrets = lib.genAttrs [
10 "sourcehut/network-key"
11 "sourcehut/service-key"
12 "sourcehut/webhook-key"
13 "sourcehut/oauth-client-secret"
19 "metasrht-api.service"
23 "todosrht-lmtp.service"
27 systemdConfig.before = srhts;
28 systemdConfig.wantedBy = srhts;
33 secretKey = "12345678";
37 #environment.systemPackages = [ pkgs.minio-client ];
38 services.sourcehut = {
40 listenAddress = "localhost";
44 images.nixos.unstable.x86_64 =
45 import sourcehut/builds/nixos-unstable.nix
47 { inherit pkgs lib config; };
50 #dispatch.enable = true;
61 postgresql.enable = true;
62 postfix.enable = true;
66 useACMEHost = networking.domain;
70 environment = "production";
71 global-domain = domain;
72 owner-email = "julm+srht@sourcephile.fr";
73 owner-name = "Sourcephile";
74 site-blurb = "a simple free software forge";
75 site-info = "https://${domain}";
76 site-name = "Sourcephile";
77 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen network
78 network-key = gnupg.secrets."sourcehut/network-key".path;
79 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen service
80 service-key = gnupg.secrets."sourcehut/service-key".path;
81 #redis-host = "redis://localhost:6379/";
84 s3-upstream = "localhost";
85 s3-access-key = "12345";
86 s3-secret-key = pkgs.writeText "s3-secret-key" "12345678";
88 # nix shell nixpkgs#sourcehut.metasrht -c metasrht-manageuser -t admin -e mymail@gmail.com misuzu
90 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
91 oauth-client-id = "299db9f9c2013170";
95 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
96 oauth-client-id = "299db9f9c2013170";
99 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
100 oauth-client-id = "299db9f9c2013170";
101 s3-bucket = "pagesbuck";
104 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
105 oauth-client-id = "299db9f9c2013170";
108 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
109 oauth-client-id = "299db9f9c2013170";
112 "meta.sr.ht::settings" = {
113 onboarding-redirect = "https://meta.${domain}";
114 registration = false;
116 "meta.sr.ht::api" = {
117 #internal-ipnet= [ "127.0.0.0/8" "::1/128" "192.168.0.0/16" "10.0.0.0/8"];
120 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
121 oauth-client-id = "299db9f9c2013170";
124 outgoing-domain = "https://git.${domain}";
125 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
126 oauth-client-id = "gitsrht";
129 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
130 oauth-client-id = "299db9f9c2013170";
133 oauth-client-secret = gnupg.secrets."sourcehut/oauth-client-secret".path;
134 oauth-client-id = "299db9f9c2013170";
136 "lists.sr.ht::worker" = {
137 #sock = "/var/lib/postfix/queue/private/srht-lmtp";
139 # nix shell nixpkgs#sourcehut.coresrht -c srht-keygen webhook
140 #webhooks.private-key= "U7yd/8mGs/v0O3kId4jpeSghUCa9tqP1fYQwSV8UOqo=";
141 webhooks.private-key = gnupg.secrets."sourcehut/webhook-key".path;
143 smtp-host = "localhost";
146 smtp-password = null;
147 smtp-from = "julm+hut@${networking.domain}";
148 error-to = "julm+hut+error@${networking.domain}";
149 error-from = "julm+hut+error@${networking.domain}";
156 fileSystems."/var/lib/sourcehut" = {
157 device = "rpool/var/sourcehut";
160 services.sanoid.datasets = {
161 "rpool/var/sourcehut" = {
162 use_template = [ "snap" ];
167 virtualHosts."~^(?<subdomain>[^.]+).hut.${networking.domain}" = {
169 useACMEHost = networking.domain;
170 globalRedirect = "$subdomain.code.${networking.domain}";
172 virtualHosts."meta.${domain}" = {
173 locations."/query".extraConfig = lib.mkForce ''
174 if ($request_method = 'OPTIONS') {
175 ${nginx.configs.https_add_headers}
176 add_header 'Access-Control-Allow-Origin' '*';
177 add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
178 add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
179 add_header 'Access-Control-Max-Age' 1728000;
180 add_header 'Content-Type' 'text/plain; charset=utf-8';
181 add_header 'Content-Length' 0;
185 ${nginx.configs.https_add_headers}
186 add_header 'Access-Control-Allow-Origin' '*';
187 add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
188 add_header 'Access-Control-Allow-Headers' 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
189 add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';