fix nextcloud (case when enabled)

Previously, second mkIf for cleanup case took precedence when merge with
`//`. Now it's 2 modules: one for selfprivacy.modules.nextcloud.enable
== true, another for selfprivacy.modules.nextcloud.enable == false.
pull/55/head
Alexander Tomokhov 2023-11-26 03:11:23 +04:00
parent 3138260605
commit a98dafc98c
4 changed files with 31 additions and 21 deletions

View File

@ -0,0 +1,19 @@
{ config, lib, ... }:
let
inherit (import ./common.nix config) sp db-pass-filepath admin-pass-filepath;
in
# FIXME do we really want to delete passwords on module deactivation!?
{
config = lib.mkIf (!sp.modules.nextcloud.enable) {
system.activationScripts.nextcloudSecrets =
lib.trivial.warn
(
"nextcloud service is disabled, " +
"${db-pass-filepath} and ${admin-pass-filepath} will be removed!"
)
''
rm -f ${db-pass-filepath}
rm -f ${admin-pass-filepath}
'';
};
}

View File

@ -0,0 +1,7 @@
config: rec {
sp = config.selfprivacy;
secrets-filepath = "/etc/selfprivacy/secrets.json";
db-pass-filepath = "/var/lib/nextcloud/db-pass";
admin-pass-filepath = "/var/lib/nextcloud/admin-pass";
hostName = "cloud.${sp.domain}";
}

View File

@ -2,7 +2,8 @@
description = "PoC SP module for nextcloud";
outputs = { self }: {
nixosModules.default = import ./module.nix;
nixosModules.default = _:
{ imports = [ ./module.nix ./cleanup-module.nix ]; };
configPathsNeeded =
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
};

View File

@ -13,11 +13,8 @@
config =
let
sp = config.selfprivacy;
secrets-filepath = "/etc/selfprivacy/secrets.json";
db-pass-filepath = "/var/lib/nextcloud/db-pass";
admin-pass-filepath = "/var/lib/nextcloud/admin-pass";
hostName = "cloud.${sp.domain}";
inherit (import ./common.nix config)
sp secrets-filepath db-pass-filepath admin-pass-filepath hostName;
in
lib.mkIf sp.modules.nextcloud.enable
{
@ -83,19 +80,5 @@
};
};
};
}
# FIXME do we really want to delete passwords on module deactivation!?
//
lib.mkIf (!sp.modules.nextcloud.enable) {
system.activationScripts.nextcloudSecrets =
lib.trivial.warn
(
"nextcloud service is disabled, " +
"${db-pass-filepath} and ${admin-pass-filepath} will be removed!"
)
''
rm -f ${db-pass-filepath}
rm -f ${admin-pass-filepath}
'';
};
};
}