@@ -4,6 +4,7 @@ with lib;
6 cfg = config.services.gitea;
6 cfg = config.services.gitea;
7 pg = config.services.postgresql;
8 pg = config.services.postgresql;
8 usePostgresql = cfg.database.type == "postgres";
9 usePostgresql = cfg.database.type == "postgres";
9 configFile = pkgs.writeText "app.ini" ''
10 configFile = pkgs.writeText "app.ini" ''
@@ -57,6 +58,13 @@ in
57 description = "Enable Gitea Service.";
58 description = "Enable Gitea Service.";
62+ default = pkgs.gitea;
63+ type = types.package;
64+ defaultText = "pkgs.gitea";
65+ description = "gitea derivation to use";
60 useWizard = mkOption {
68 useWizard = mkOption {
61 default = false;
69 default = false;
62 type = types.bool;
70 type = types.bool;
@@ -203,7 +211,7 @@ in
204 staticRootPath = mkOption {
212 staticRootPath = mkOption {
205 type = types.str;
213 type = types.str;
206− default = "${pkgs.gitea.data}";
214+ default = "${gitea.data}";
207 example = "/var/lib/gitea/data";
215 example = "/var/lib/gitea/data";
208 description = "Upper level of template and static files path.";
216 description = "Upper level of template and static files path.";
@@ -223,7 +231,7 @@ in
223 description = "gitea";
231 description = "gitea";
224 after = [ "network.target" "postgresql.service" ];
232 after = [ "network.target" "postgresql.service" ];
225 wantedBy = [ "multi-user.target" ];
233 wantedBy = [ "multi-user.target" ];
226− path = [ pkgs.gitea.bin ];
234+ path = [ gitea.bin ];
228 preStart = let
236 preStart = let
229 runConfig = "${cfg.stateDir}/custom/conf/app.ini";
237 runConfig = "${cfg.stateDir}/custom/conf/app.ini";
@@ -253,7 +261,7 @@ in
253 HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 4 -type f -wholename "*git/hooks/*")
261 HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 4 -type f -wholename "*git/hooks/*")
254 if [ "$HOOKS" ]
262 if [ "$HOOKS" ]
256− sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gitea,${pkgs.gitea.bin}/bin/gitea,g' $HOOKS
264+ sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gitea,${gitea.bin}/bin/gitea,g' $HOOKS
257 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/env,${pkgs.coreutils}/bin/env,g' $HOOKS
265 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/env,${pkgs.coreutils}/bin/env,g' $HOOKS
258 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/bash,${pkgs.bash}/bin/bash,g' $HOOKS
266 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/bash,${pkgs.bash}/bin/bash,g' $HOOKS
259 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/perl,${pkgs.perl}/bin/perl,g' $HOOKS
267 sed -ri 's,/nix/store/[a-z0-9.-]+/bin/perl,${pkgs.perl}/bin/perl,g' $HOOKS
@@ -261,7 +269,7 @@ in
261 if [ ! -d ${cfg.stateDir}/conf/locale ]
269 if [ ! -d ${cfg.stateDir}/conf/locale ]
263 mkdir -p ${cfg.stateDir}/conf
271 mkdir -p ${cfg.stateDir}/conf
264− cp -r ${pkgs.gitea.out}/locale ${cfg.stateDir}/conf/locale
272+ cp -r ${gitea.out}/locale ${cfg.stateDir}/conf/locale
266 '' + optionalString (usePostgresql && cfg.database.createDatabase) ''
274 '' + optionalString (usePostgresql && cfg.database.createDatabase) ''
267 if ! test -e "${cfg.stateDir}/db-created"; then
275 if ! test -e "${cfg.stateDir}/db-created"; then
@@ -288,7 +296,7 @@ in
288 User = cfg.user;
296 User = cfg.user;
289 WorkingDirectory = cfg.stateDir;
297 WorkingDirectory = cfg.stateDir;
290 PermissionsStartOnly = true;
298 PermissionsStartOnly = true;
291− ExecStart = "${pkgs.gitea.bin}/bin/gitea web";
299+ ExecStart = "${gitea.bin}/bin/gitea web";
292 Restart = "always";
300 Restart = "always";