Skip to content

Commit

Permalink
nixos/lemmy: inline localPostgres into database assertion
Browse files Browse the repository at this point in the history
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: Brian Leung <leungbk@posteo.net>
Co-authored-by: Ilan Joselevich <personal@ilanjoselevich.com>
  • Loading branch information
5 people authored and Yt committed Sep 21, 2022
1 parent 1d9d8a3 commit 3de898f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions nixos/modules/services/web-apps/lemmy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ in
};

config =
let
localPostgres = (cfg.settings.database.host == "localhost" || cfg.settings.database.host == "/run/postgresql");
in
lib.mkIf cfg.enable {
services.lemmy.settings = (mapAttrs (name: mkDefault)
{
Expand All @@ -100,7 +97,7 @@ in
};
});

services.postgresql = mkIf localPostgres {
services.postgresql = mkIf cfg.database.createLocally {
enable = mkDefault true;
};

Expand Down Expand Up @@ -141,7 +138,7 @@ in
};

assertions = [{
assertion = cfg.database.createLocally -> localPostgres;
assertion = cfg.database.createLocally -> cfg.settings.database.host == "localhost" || cfg.settings.database.host == "/run/postgresql";
message = "if you want to create the database locally, you need to use a local database";
}];

Expand Down

0 comments on commit 3de898f

Please sign in to comment.