mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git
synced 2025-01-07 16:41:23 +00:00
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.
This commit is contained in:
parent
3138260605
commit
a98dafc98c
19
sp-modules/nextcloud/cleanup-module.nix
Normal file
19
sp-modules/nextcloud/cleanup-module.nix
Normal 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}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
7
sp-modules/nextcloud/common.nix
Normal file
7
sp-modules/nextcloud/common.nix
Normal 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}";
|
||||||
|
}
|
|
@ -2,7 +2,8 @@
|
||||||
description = "PoC SP module for nextcloud";
|
description = "PoC SP module for nextcloud";
|
||||||
|
|
||||||
outputs = { self }: {
|
outputs = { self }: {
|
||||||
nixosModules.default = import ./module.nix;
|
nixosModules.default = _:
|
||||||
|
{ imports = [ ./module.nix ./cleanup-module.nix ]; };
|
||||||
configPathsNeeded =
|
configPathsNeeded =
|
||||||
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
|
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,11 +13,8 @@
|
||||||
|
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
sp = config.selfprivacy;
|
inherit (import ./common.nix config)
|
||||||
secrets-filepath = "/etc/selfprivacy/secrets.json";
|
sp secrets-filepath db-pass-filepath admin-pass-filepath hostName;
|
||||||
db-pass-filepath = "/var/lib/nextcloud/db-pass";
|
|
||||||
admin-pass-filepath = "/var/lib/nextcloud/admin-pass";
|
|
||||||
hostName = "cloud.${sp.domain}";
|
|
||||||
in
|
in
|
||||||
lib.mkIf sp.modules.nextcloud.enable
|
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}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue