mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
joplin-desktop: allow undefined options
This PR fixes two issues that cause rebuild to fail, see #5222. The first was caused when sync.target and sync.interval were not set, this was fixed by changing the default values from null to "undefined" and filtering these out later. The second error occurred when the .config/joplin-desktop directory didn't exist (e.g. when installing Joplin for the first time) which caused the touch command to fail. This was fixed using mkdir to ensure that .config/joplin-desktop exists.
This commit is contained in:
parent
ad83c154bd
commit
2846d5230a
1 changed files with 18 additions and 7 deletions
|
@ -49,7 +49,7 @@ in {
|
||||||
sync = {
|
sync = {
|
||||||
target = lib.mkOption {
|
target = lib.mkOption {
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
null
|
"undefined"
|
||||||
"none"
|
"none"
|
||||||
"file-system"
|
"file-system"
|
||||||
"onedrive"
|
"onedrive"
|
||||||
|
@ -60,15 +60,23 @@ in {
|
||||||
"joplin-server"
|
"joplin-server"
|
||||||
"joplin-cloud"
|
"joplin-cloud"
|
||||||
];
|
];
|
||||||
default = null;
|
default = "undefined";
|
||||||
example = "dropbox";
|
example = "dropbox";
|
||||||
description = "What is the type of sync target.";
|
description = "What is the type of sync target.";
|
||||||
};
|
};
|
||||||
|
|
||||||
interval = lib.mkOption {
|
interval = lib.mkOption {
|
||||||
type =
|
type = lib.types.enum [
|
||||||
lib.types.enum [ null "disabled" "5m" "10m" "30m" "1h" "12h" "1d" ];
|
"undefined"
|
||||||
default = null;
|
"disabled"
|
||||||
|
"5m"
|
||||||
|
"10m"
|
||||||
|
"30m"
|
||||||
|
"1h"
|
||||||
|
"12h"
|
||||||
|
"1d"
|
||||||
|
];
|
||||||
|
default = "undefined";
|
||||||
example = "10m";
|
example = "10m";
|
||||||
description = ''
|
description = ''
|
||||||
Set the synchronisation interval.
|
Set the synchronisation interval.
|
||||||
|
@ -90,6 +98,7 @@ in {
|
||||||
"editor" = cfg.general.editor;
|
"editor" = cfg.general.editor;
|
||||||
|
|
||||||
"sync.target" = {
|
"sync.target" = {
|
||||||
|
"undefined" = null;
|
||||||
"none" = 0;
|
"none" = 0;
|
||||||
"file-system" = 2;
|
"file-system" = 2;
|
||||||
"onedrive" = 3;
|
"onedrive" = 3;
|
||||||
|
@ -99,9 +108,10 @@ in {
|
||||||
"s3" = 8;
|
"s3" = 8;
|
||||||
"joplin-server" = 9;
|
"joplin-server" = 9;
|
||||||
"joplin-cloud" = 10;
|
"joplin-cloud" = 10;
|
||||||
}.${cfg.sync.target} or null;
|
}.${cfg.sync.target};
|
||||||
|
|
||||||
"sync.interval" = {
|
"sync.interval" = {
|
||||||
|
"undefined" = null;
|
||||||
"disabled" = 0;
|
"disabled" = 0;
|
||||||
"5m" = 300;
|
"5m" = 300;
|
||||||
"10m" = 600;
|
"10m" = 600;
|
||||||
|
@ -109,10 +119,11 @@ in {
|
||||||
"1h" = 3600;
|
"1h" = 3600;
|
||||||
"12h" = 43200;
|
"12h" = 43200;
|
||||||
"1d" = 86400;
|
"1d" = 86400;
|
||||||
}.${cfg.sync.interval} or null;
|
}.${cfg.sync.interval};
|
||||||
} // cfg.extraConfig));
|
} // cfg.extraConfig));
|
||||||
in lib.hm.dag.entryAfter [ "linkGeneration" ] ''
|
in lib.hm.dag.entryAfter [ "linkGeneration" ] ''
|
||||||
# Ensure that settings.json exists.
|
# Ensure that settings.json exists.
|
||||||
|
mkdir -p ${builtins.dirOf configPath}
|
||||||
touch ${configPath}
|
touch ${configPath}
|
||||||
# Config has to be written to temporary variable because jq cannot edit files in place.
|
# Config has to be written to temporary variable because jq cannot edit files in place.
|
||||||
config="$(jq -s '.[0] + .[1]' ${configPath} ${newConfig})"
|
config="$(jq -s '.[0] + .[1]' ${configPath} ${newConfig})"
|
||||||
|
|
Loading…
Reference in a new issue