From c956a12e878700c196d73acdd98581ed2b8a8d5f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 12 Feb 2026 01:26:15 -0800 Subject: [PATCH] nixos: enable keepbook sync --- nixos/configuration.nix | 2 + nixos/flake.lock | 61 +++++++++++++++++ nixos/flake.nix | 8 +++ nixos/keepbook-sync.nix | 114 ++++++++++++++++++++++++++++++++ nixos/machines/railbird-sf.nix | 1 + nixos/machines/strixi-minaj.nix | 1 + 6 files changed, 187 insertions(+) create mode 100644 nixos/keepbook-sync.nix diff --git a/nixos/configuration.nix b/nixos/configuration.nix index c7f8bc7a..014ed81d 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -23,6 +23,7 @@ ./k3s.nix ./k3s-single-node.nix ./kat.nix + ./keepbook-sync.nix ./keybase.nix ./kubelet.nix ./laptop.nix @@ -69,6 +70,7 @@ myModules.electron.enable = true; myModules.code.enable = true; myModules.games.enable = false; + myModules."keepbook-sync".enable = true; myModules.syncthing.enable = true; myModules.fonts.enable = true; }) diff --git a/nixos/flake.lock b/nixos/flake.lock index 52a2e00c..d0bb17ff 100644 --- a/nixos/flake.lock +++ b/nixos/flake.lock @@ -238,6 +238,28 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": [ + "keepbook", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1769842381, + "narHash": "sha256-0dPzo1ElvAIZ0RwEwx5FfqAUiFj22K9QJOU9stiMCrw=", + "owner": "nix-community", + "repo": "fenix", + "rev": "b2344f384a82db1410ab09769eb8c4a820de667f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -1145,6 +1167,27 @@ "type": "github" } }, + "keepbook": { + "inputs": { + "fenix": "fenix", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770888240, + "narHash": "sha256-uDc/CQVg9dUigJtUpO21rE2JIdes7bRo6XYaWSa0asY=", + "path": "/home/imalison/Projects/keepbook", + "type": "path" + }, + "original": { + "path": "/home/imalison/Projects/keepbook", + "type": "path" + } + }, "mova": { "flake": false, "locked": { @@ -1655,6 +1698,7 @@ "hyprscratch": "hyprscratch", "imalison-taffybar": "imalison-taffybar", "kanshi-sni": "kanshi-sni", + "keepbook": "keepbook", "nix": "nix", "nixified-ai": "nixified-ai", "nixos-hardware": "nixos-hardware", @@ -1672,6 +1716,23 @@ "xmonad-contrib": "xmonad-contrib" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1769786006, + "narHash": "sha256-ax6cH54Nc20QuxlHNC8RMt1P8quMECY4gaACFAdd5ec=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "eb0588812b041ebbf2645555f2a4df3bcd853c6d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "rust-overlay": { "inputs": { "nixpkgs": [ diff --git a/nixos/flake.nix b/nixos/flake.nix index 47c15145..3ea7c8be 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -45,6 +45,14 @@ }; }; + keepbook = { + url = "path:/home/imalison/Projects/keepbook"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + org-agenda-api = { url = "github:colonelpanic8/org-agenda-api"; inputs = { diff --git a/nixos/keepbook-sync.nix b/nixos/keepbook-sync.nix new file mode 100644 index 00000000..09c2d094 --- /dev/null +++ b/nixos/keepbook-sync.nix @@ -0,0 +1,114 @@ +{ config, lib, pkgs, inputs, makeEnable, ... }: +let + cfg = config.myModules."keepbook-sync"; + keepbookTray = inputs.keepbook.packages.${pkgs.stdenv.hostPlatform.system}.keepbook-tray; + + daemonArgs = [ + "--config" cfg.configPath + "--interval" cfg.interval + "--jitter" cfg.jitter + "--history-points" (toString cfg.historyPoints) + "--tray-icon" cfg.trayIcon + ] + ++ 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 { + home-manager.users.${cfg.user} = { + systemd.user.services.keepbook-sync-daemon = { + Unit = { + Description = "keepbook sync daemon"; + After = [ "graphical-session.target" "tray.target" ]; + PartOf = [ "graphical-session.target" ]; + Requires = [ "tray.target" ]; + }; + Service = { + ExecStart = daemonExec; + Restart = "always"; + RestartSec = 5; + Environment = [ "RUST_LOG=info" ]; + }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; + }; +in +enabledModule // { + # Merge our extra options with the enable option produced by makeEnable. + options = lib.recursiveUpdate enabledModule.options { + myModules."keepbook-sync" = { + user = lib.mkOption { + type = lib.types.str; + default = "imalison"; + description = "User account to run the keepbook sync daemon."; + }; + + configPath = lib.mkOption { + type = lib.types.str; + default = "/home/imalison/.local/share/keepbook/keepbook.toml"; + description = "Path to keepbook.toml used by the daemon."; + }; + + 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.int; + default = 8; + description = "Recent portfolio history rows shown in tray menu."; + }; + + trayIcon = lib.mkOption { + type = lib.types.str; + default = "wallet"; + description = "Freedesktop icon name for idle keepbook tray state."; + }; + }; + }; +} diff --git a/nixos/machines/railbird-sf.nix b/nixos/machines/railbird-sf.nix index 4777bf9f..38ff2bed 100644 --- a/nixos/machines/railbird-sf.nix +++ b/nixos/machines/railbird-sf.nix @@ -60,6 +60,7 @@ myModules.gitea-runner.enable = true; # Disable the old multi-node railbird k3s setup myModules.railbird-k3s.enable = false; + myModules."keepbook-sync".enable = true; fileSystems."/" = { device = "/dev/disk/by-uuid/a317d456-6f84-41ee-a149-8e466e414aae"; diff --git a/nixos/machines/strixi-minaj.nix b/nixos/machines/strixi-minaj.nix index a4b951be..a76413b0 100644 --- a/nixos/machines/strixi-minaj.nix +++ b/nixos/machines/strixi-minaj.nix @@ -20,6 +20,7 @@ myModules.quickshell.enable = true; myModules.wyoming.enable = false; myModules.tts.enable = false; + myModules."keepbook-sync".enable = true; hardware.enableRedistributableFirmware = true;