Skip to content

Commit 1e03233

Browse files
Merge pull request #349 from NuschtOS/drop-25.05
Drop 25.05
2 parents 00e9584 + fece1a2 commit 1e03233

File tree

4 files changed

+94
-111
lines changed

4 files changed

+94
-111
lines changed

.github/workflows/flake-check.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ jobs:
1919
matrix:
2020
targets:
2121
- repo: NixOS/nixpkgs
22-
branch: nixos-25.05
22+
branch: nixos-25.11
2323
- repo: NixOS/nixpkgs
2424
branch: nixos-unstable
2525

26+
# Do we need this?
27+
# - repo: NuschtOS/nuschtpkgs
28+
# branch: nixos-25.11
2629
- repo: NuschtOS/nuschtpkgs
27-
branch: nixos-25.05
28-
- repo: NuschtOS/nuschtpkgs
29-
branch: backports-25.05
30+
branch: backports-25.11
3031
- repo: NuschtOS/nuschtpkgs
3132
branch: nixos-unstable
3233

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/nextcloud.nix

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33
let
44
cfg = config.services.nextcloud;
55
inherit (config.services.nextcloud.package.packages) apps;
6-
7-
hasImaginary = lib.versionAtLeast lib.version "25.11pre";
86
in
97
{
108
options = {
119
services.nextcloud = {
1210
recommendedDefaults = libS.mkOpinionatedOption "set recommended default settings";
1311

14-
# TODO: drop when removing 25.05 support
15-
imaginary.enable = if (!hasImaginary) then
16-
lib.mkEnableOption "Imaginary" // {
17-
default = config.opinionatedDefaults;
18-
}
19-
else
20-
lib.mkOption { };
21-
2212
configureMemories = lib.mkEnableOption "" // { description = "Whether to configure dependencies for Memories App."; };
2313

2414
configureMemoriesVaapi = lib.mkOption {

modules/postgres.nix

Lines changed: 86 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ let
77
cfgb = config.services.postgresqlBackup;
88
cfgu = config.services.postgresql.upgrade;
99

10-
# TODO: clean up when dropping support for 25.05
11-
hasPGdumpAllOptionsAndPostgresqlSetup = lib.versionAtLeast lib.version "25.11pre";
1210
latestVersion = if pkgs?postgresql_18 then "18" else "17";
1311
currentMajorVersion = lib.versions.major cfg.package.version;
1412
newMajorVersion = lib.versions.major cfgu.newPackage.version;
@@ -156,7 +154,7 @@ in
156154
};
157155
};
158156

159-
postgresqlBackup = lib.optionalAttrs hasPGdumpAllOptionsAndPostgresqlSetup {
157+
postgresqlBackup = {
160158
backupAll = lib.mkOption { };
161159

162160
backupAllExcept = lib.mkOption {
@@ -169,7 +167,7 @@ in
169167
This option also enforces ${optb.backupAll} to be turned on which has the effect that all databases are backed up except the ones listed in this option.
170168
'';
171169
};
172-
} // {
170+
173171
databases = lib.mkOption {
174172
defaultText = lib.literalExpression /* nix */ ''${opt.databases} ++ [ "postgres" ]'';
175173
# NOTE: option description cannot be overwritten or merged
@@ -338,12 +336,11 @@ in
338336
};
339337

340338
postgresqlBackup = lib.mkMerge [
341-
({
339+
{
342340
databases = lib.mkIf (cfg.recommendedDefaults || cfgb.databasesExcept != [ ]) (lib.subtractLists cfgb.databasesExcept config.services.postgresql.databases);
343-
} // lib.optionalAttrs hasPGdumpAllOptionsAndPostgresqlSetup {
344341
backupAll = lib.mkIf (cfgb.backupAllExcept != []) true;
345342
pgdumpAllOptions = lib.concatMapStringsSep" " (db: "--exclude-database=${db}") cfgb.backupAllExcept;
346-
})
343+
}
347344

348345
(lib.mkIf cfg.recommendedDefaults {
349346
compression = "zstd";
@@ -354,99 +351,94 @@ in
354351
};
355352

356353
systemd = {
357-
# TODO: drop the mkMerge when support for 25.05 is removed and we always have postgresql and postgresql-setup
358-
services = lib.mkMerge [
359-
{
360-
postgresql.preStart = lib.mkIf cfg.preventDowngrade /* bash */ ''
361-
found_current=false
362-
for dir in $(find /var/lib/postgresql/ -mindepth 1 -maxdepth 1 -type d -not -name ".*" | sort --version-sort); do
363-
if [[ $found_current == true ]]; then
364-
echo "Found directory ''${dir} which is newer than the current major postgres version ${currentMajorVersion}, aborting startup due to ${opt.preventDowngrade}"
365-
exit 10
366-
fi
367-
368-
if [[ $(basename "$dir") == ${currentMajorVersion} ]]; then
369-
found_current=true
370-
continue
371-
fi
354+
services = {
355+
postgresql.preStart = lib.mkIf cfg.preventDowngrade /* bash */ ''
356+
found_current=false
357+
for dir in $(find /var/lib/postgresql/ -mindepth 1 -maxdepth 1 -type d -not -name ".*" | sort --version-sort); do
358+
if [[ $found_current == true ]]; then
359+
echo "Found directory ''${dir} which is newer than the current major postgres version ${currentMajorVersion}, aborting startup due to ${opt.preventDowngrade}"
360+
exit 10
361+
fi
362+
363+
if [[ $(basename "$dir") == ${currentMajorVersion} ]]; then
364+
found_current=true
365+
continue
366+
fi
367+
done
368+
'';
369+
370+
postgresql-setup = {
371+
preStart = lib.mkIf cfg.refreshCollation /* bash */ ''
372+
# copied from upstream due to the lack of extensibility #
373+
check-connection() {
374+
psql -d postgres -v ON_ERROR_STOP=1 <<-' EOF'
375+
SELECT pg_is_in_recovery() \gset
376+
\if :pg_is_in_recovery
377+
\i still-recovering
378+
\endif
379+
EOF
380+
}
381+
while ! check-connection 2> /dev/null; do
382+
if ! systemctl is-active --quiet postgresql.service; then exit 1; fi
383+
sleep 0.1
372384
done
373-
'';
374-
}
385+
###
375386
376-
{
377-
"postgresql${lib.optionalString hasPGdumpAllOptionsAndPostgresqlSetup "-setup"}" = {
378-
postStart = lib.mkMerge [
379-
(lib.mkIf cfg.refreshCollation (lib.mkBefore /* bash */ ''
380-
### TODO: clean up when dropping support for 25.05
381-
# copied from upstream due to the lack of extensibility
382-
# TODO: improve this upstream?
383-
PSQL="psql --port=${toString cfg.settings.port}"
384-
385-
while ! $PSQL -d postgres -c "" 2> /dev/null; do
386-
if ! kill -0 "$MAINPID"; then exit 1; fi
387-
sleep 0.1
388-
done
389-
###
390-
391-
$PSQL -tAc 'ALTER DATABASE "template1" REFRESH COLLATION VERSION'
392-
''))
393-
394-
(lib.concatMapStrings (user: lib.optionalString (user.ensurePasswordFile != null) /* psql */ ''
395-
# TODO: use psql when dropping support for 25.05
396-
$PSQL -tA <<'EOF'
397-
DO $$
398-
DECLARE password TEXT;
399-
BEGIN
400-
password := trim(both from replace(pg_read_file('${user.ensurePasswordFile}'), E'\n', '''));
401-
EXECUTE format('ALTER ROLE ${user.name} WITH PASSWORD '''%s''';', password);
402-
END $$;
403-
EOF
404-
'') cfg.ensureUsers)
405-
406-
# install/update pg_stat_statements extension in all databases
407-
# based on https://git.catgirl.cloud/999eagle/dotfiles-nix/-/blob/main/modules/system/server/postgres/default.nix#L294-302
408-
(lib.mkIf (cfg.installAllAvailableExtensions || cfg.configurePgStatStatements) (lib.concatStrings (map (db:
409-
(lib.concatMapStringsSep "\n" (ext: let
410-
extUpdateStatement = name: {
411-
# pg_repack cannot be updated but reinstalling it is safe
412-
"pg_repack" = "DROP EXTENSION pg_repack CASCADE; CREATE EXTENSION pg_repack";
413-
"postgis" = "SELECT postgis_extensions_upgrade()";
414-
}.${name} or ''ALTER EXTENSION "${ext}" UPDATE'';
415-
in /* bash */ ''
416-
# TODO: use psql when dropping support for 25.05
417-
$PSQL -tAd '${db}' -c 'CREATE EXTENSION IF NOT EXISTS "${ext}"'
418-
$PSQL -tAd '${db}' -c '${extUpdateStatement ext}'
419-
'') cfgInstalledExtensions
420-
)
421-
) cfg.databases)))
422-
423-
(lib.mkIf cfg.refreshCollation (lib.concatStrings (map (db: /* bash */ ''
424-
# TODO: use psql when dropping support for 25.05
425-
$PSQL -tAc 'ALTER DATABASE "${db}" REFRESH COLLATION VERSION'
426-
'') cfg.databases)))
427-
];
428-
429-
# reduce downtime for dependent services
430-
stopIfChanged = lib.mkIf cfg.recommendedDefaults false;
431-
};
387+
psql -tAc 'ALTER DATABASE "template1" REFRESH COLLATION VERSION'
388+
'';
389+
script = lib.mkMerge [
390+
(lib.concatMapStrings (user: lib.optionalString (user.ensurePasswordFile != null) /* bash */ ''
391+
psql -tA <<'EOF'
392+
DO $$
393+
DECLARE password TEXT;
394+
BEGIN
395+
password := trim(both from replace(pg_read_file('${user.ensurePasswordFile}'), E'\n', '''));
396+
EXECUTE format('ALTER ROLE ${user.name} WITH PASSWORD '''%s''';', password);
397+
END $$;
398+
EOF
399+
'') cfg.ensureUsers)
400+
401+
# install/update pg_stat_statements extension in all databases
402+
# based on https://git.catgirl.cloud/999eagle/dotfiles-nix/-/blob/main/modules/system/server/postgres/default.nix#L294-302
403+
(lib.mkIf (cfg.installAllAvailableExtensions || cfg.configurePgStatStatements) (lib.concatStrings (map (db:
404+
(lib.concatMapStringsSep "\n" (ext: let
405+
extUpdateStatement = name: {
406+
# pg_repack cannot be updated but reinstalling it is safe
407+
"pg_repack" = "DROP EXTENSION pg_repack CASCADE; CREATE EXTENSION pg_repack";
408+
"postgis" = "SELECT postgis_extensions_upgrade()";
409+
}.${name} or ''ALTER EXTENSION "${ext}" UPDATE'';
410+
in /* bash */ ''
411+
psql -tAd '${db}' -c 'CREATE EXTENSION IF NOT EXISTS "${ext}"'
412+
psql -tAd '${db}' -c '${extUpdateStatement ext}'
413+
'') cfgInstalledExtensions
414+
)
415+
) cfg.databases)))
416+
417+
(lib.mkIf cfg.refreshCollation (lib.concatStrings (map (db: /* bash */ ''
418+
psql -tAc 'ALTER DATABASE "${db}" REFRESH COLLATION VERSION'
419+
'') cfg.databases)))
420+
];
421+
422+
# reduce downtime for dependent services
423+
stopIfChanged = lib.mkIf cfg.recommendedDefaults false;
424+
};
432425

433-
postgresql-pg-repack = lib.mkIf cfg.vacuumAnalyzeTimer.enable {
434-
description = "Repack all PostgreSQL databases";
435-
serviceConfig = {
436-
ExecStart = "${lib.getExe cfg.package.pkgs.pg_repack} --port=${builtins.toString cfg.settings.port} --all";
437-
User = "postgres";
438-
};
426+
postgresql-pg-repack = lib.mkIf cfg.vacuumAnalyzeTimer.enable {
427+
description = "Repack all PostgreSQL databases";
428+
serviceConfig = {
429+
ExecStart = "${lib.getExe cfg.package.pkgs.pg_repack} --port=${builtins.toString cfg.settings.port} --all";
430+
User = "postgres";
439431
};
432+
};
440433

441-
postgresql-vacuum-analyze = lib.mkIf cfg.vacuumAnalyzeTimer.enable {
442-
description = "Vacuum and analyze all PostgreSQL databases";
443-
serviceConfig = {
444-
ExecStart = "${lib.getExe' cfg.package "psql"} --port=${builtins.toString cfg.settings.port} -tAc 'VACUUM ANALYZE'";
445-
User = "postgres";
446-
};
434+
postgresql-vacuum-analyze = lib.mkIf cfg.vacuumAnalyzeTimer.enable {
435+
description = "Vacuum and analyze all PostgreSQL databases";
436+
serviceConfig = {
437+
ExecStart = "${lib.getExe' cfg.package "psql"} --port=${builtins.toString cfg.settings.port} -tAc 'VACUUM ANALYZE'";
438+
User = "postgres";
447439
};
448-
}
449-
];
440+
};
441+
};
450442

451443
timers = let
452444
mkTimerConfig = name: lib.mkMerge [

0 commit comments

Comments
 (0)