keepbook: run dioxus desktop service
This commit is contained in:
@@ -21,7 +21,7 @@ priorities:
|
|||||||
priority: 0
|
priority: 0
|
||||||
- key: item-id:flameshot
|
- key: item-id:flameshot
|
||||||
priority: 0
|
priority: 0
|
||||||
- key: item-id:keepbook-sync-daemon
|
- key: item-id:keepbook-dioxus
|
||||||
priority: 0
|
priority: 0
|
||||||
- key: item-id:udiskie
|
- key: item-id:udiskie
|
||||||
priority: 0
|
priority: 0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ tray_services=(
|
|||||||
flameshot.service
|
flameshot.service
|
||||||
kanshi-sni.service
|
kanshi-sni.service
|
||||||
kdeconnect-indicator.service
|
kdeconnect-indicator.service
|
||||||
keepbook-sync-daemon.service
|
keepbook-dioxus.service
|
||||||
network-manager-applet.service
|
network-manager-applet.service
|
||||||
notifications-tray-icon-gitea.service
|
notifications-tray-icon-gitea.service
|
||||||
notifications-tray-icon-github.service
|
notifications-tray-icon-github.service
|
||||||
|
|||||||
@@ -8,48 +8,24 @@
|
|||||||
}: let
|
}: let
|
||||||
cfg = config.myModules."keepbook-sync";
|
cfg = config.myModules."keepbook-sync";
|
||||||
keepbookPackages = inputs.keepbook.packages.${pkgs.stdenv.hostPlatform.system};
|
keepbookPackages = inputs.keepbook.packages.${pkgs.stdenv.hostPlatform.system};
|
||||||
keepbookTray = keepbookPackages.keepbook-tray.overrideAttrs (_: {
|
keepbookDioxusDesktop = keepbookPackages.keepbook-dioxus-desktop;
|
||||||
# Upstream currently includes a contract test that expects a built TS CLI
|
keepbookDioxusExec = "${keepbookDioxusDesktop}/bin/keepbook-dioxus";
|
||||||
# entrypoint under ts/dist/, but the Nix build does not build the TS
|
|
||||||
# artifacts first. Skip checks to keep the package usable on NixOS.
|
|
||||||
doCheck = false;
|
|
||||||
});
|
|
||||||
keepbookDioxusDesktopPackages =
|
|
||||||
lib.optional (keepbookPackages ? keepbook-dioxus-desktop)
|
|
||||||
keepbookPackages.keepbook-dioxus-desktop;
|
|
||||||
|
|
||||||
daemonArgs =
|
|
||||||
[
|
|
||||||
"--config"
|
|
||||||
cfg.configPath
|
|
||||||
"--interval"
|
|
||||||
cfg.interval
|
|
||||||
"--jitter"
|
|
||||||
cfg.jitter
|
|
||||||
]
|
|
||||||
++ lib.optionals (cfg.historyPoints != null) ["--history-points" (toString cfg.historyPoints)]
|
|
||||||
++ lib.optionals (!cfg.syncOnStart) ["--no-sync-on-start"]
|
|
||||||
++ lib.optionals (!cfg.syncPrices) ["--no-sync-prices"]
|
|
||||||
++ lib.optionals (!cfg.syncSymlinks) ["--no-sync-symlinks"]
|
|
||||||
++ lib.optionals (cfg.balanceStaleness != null) ["--balance-staleness" cfg.balanceStaleness]
|
|
||||||
++ lib.optionals (cfg.priceStaleness != null) ["--price-staleness" cfg.priceStaleness];
|
|
||||||
|
|
||||||
daemonExec = lib.escapeShellArgs (["${keepbookTray}/bin/keepbook-sync-daemon"] ++ daemonArgs);
|
|
||||||
|
|
||||||
enabledModule = makeEnable config "myModules.keepbook-sync" false {
|
enabledModule = makeEnable config "myModules.keepbook-sync" false {
|
||||||
environment.systemPackages = [keepbookTray] ++ keepbookDioxusDesktopPackages;
|
environment.systemPackages = [keepbookDioxusDesktop];
|
||||||
|
|
||||||
home-manager.users.${cfg.user} = {
|
home-manager.users.${cfg.user} = {
|
||||||
systemd.user.services.keepbook-sync-daemon = {
|
systemd.user.services.keepbook-dioxus = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "keepbook sync daemon";
|
Description = "Keepbook Dioxus desktop app";
|
||||||
After = ["graphical-session.target" "tray.target"];
|
After = ["graphical-session.target" "tray.target"];
|
||||||
PartOf = ["graphical-session.target"];
|
PartOf = ["graphical-session.target"];
|
||||||
Requires = ["tray.target"];
|
Requires = ["tray.target"];
|
||||||
};
|
};
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = daemonExec;
|
ExecStart = keepbookDioxusExec;
|
||||||
Restart = "always";
|
WorkingDirectory = builtins.dirOf cfg.configPath;
|
||||||
|
Restart = "on-failure";
|
||||||
RestartSec = 5;
|
RestartSec = 5;
|
||||||
Environment = ["RUST_LOG=info"];
|
Environment = ["RUST_LOG=info"];
|
||||||
};
|
};
|
||||||
@@ -68,61 +44,13 @@ in
|
|||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "imalison";
|
default = "imalison";
|
||||||
description = "User account to run the keepbook sync daemon.";
|
description = "User account to run the keepbook Dioxus desktop app.";
|
||||||
};
|
};
|
||||||
|
|
||||||
configPath = lib.mkOption {
|
configPath = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "/home/imalison/.local/share/keepbook/keepbook.toml";
|
default = "/home/imalison/.local/share/keepbook/keepbook.toml";
|
||||||
description = "Path to keepbook.toml used by the daemon.";
|
description = "Path to keepbook.toml. The Dioxus app is launched from this file's directory so keepbook's default config discovery finds it.";
|
||||||
};
|
|
||||||
|
|
||||||
interval = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "30m";
|
|
||||||
description = "Base sync interval for keepbook-sync-daemon (e.g. 30m, 1h).";
|
|
||||||
};
|
|
||||||
|
|
||||||
jitter = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "5m";
|
|
||||||
description = "Random jitter applied around each scheduled interval.";
|
|
||||||
};
|
|
||||||
|
|
||||||
balanceStaleness = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = "Optional override for balance staleness threshold.";
|
|
||||||
};
|
|
||||||
|
|
||||||
priceStaleness = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = "Optional override for price staleness threshold.";
|
|
||||||
};
|
|
||||||
|
|
||||||
syncOnStart = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Run a sync cycle immediately when the daemon starts.";
|
|
||||||
};
|
|
||||||
|
|
||||||
syncPrices = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Enable periodic price refresh during sync cycles.";
|
|
||||||
};
|
|
||||||
|
|
||||||
syncSymlinks = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Enable periodic symlink rebuild during sync cycles.";
|
|
||||||
};
|
|
||||||
|
|
||||||
historyPoints = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.int;
|
|
||||||
default = null;
|
|
||||||
description = "Optional override for the maximum recent portfolio history rows shown in the tray menu.";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user