From f5d50fd8cba8a92af2dabc317f8e3d4e722ae0a6 Mon Sep 17 00:00:00 2001 From: Aguirre Matteo Date: Sun, 8 Feb 2026 10:58:23 -0300 Subject: [PATCH] lazyworktree: add module --- modules/programs/lazyworktree.nix | 48 +++++++++++++++++++ .../modules/programs/lazyworktree/config.yaml | 8 ++++ .../modules/programs/lazyworktree/default.nix | 1 + .../programs/lazyworktree/settings.nix | 21 ++++++++ 4 files changed, 78 insertions(+) create mode 100644 modules/programs/lazyworktree.nix create mode 100644 tests/modules/programs/lazyworktree/config.yaml create mode 100644 tests/modules/programs/lazyworktree/default.nix create mode 100644 tests/modules/programs/lazyworktree/settings.nix diff --git a/modules/programs/lazyworktree.nix b/modules/programs/lazyworktree.nix new file mode 100644 index 00000000..ba675c09 --- /dev/null +++ b/modules/programs/lazyworktree.nix @@ -0,0 +1,48 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + cfg = config.programs.lazyworktree; + yamlFormat = pkgs.formats.yaml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.lazyworktree = { + enable = mkEnableOption "lazyworktree"; + package = mkPackageOption pkgs "lazyworktree" { nullable = true; }; + settings = mkOption { + inherit (yamlFormat) type; + default = { }; + example = { + worktree_dir = "~/.local/share/worktrees"; + sort_mode = "switched"; + auto_fetch_prs = false; + auto_refresh = true; + refresh_interval = 10; + icon_set = "nerd-font-v3"; + search_auto_select = false; + fuzzy_finder_input = false; + }; + description = '' + Configuration settings for lazyworktree. All the available options can be found here: + + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."lazyworktree/config.yaml" = mkIf (cfg.settings != { }) { + source = yamlFormat.generate "lazyworktree.yaml" cfg.settings; + }; + }; +} diff --git a/tests/modules/programs/lazyworktree/config.yaml b/tests/modules/programs/lazyworktree/config.yaml new file mode 100644 index 00000000..76839ef1 --- /dev/null +++ b/tests/modules/programs/lazyworktree/config.yaml @@ -0,0 +1,8 @@ +auto_fetch_prs: false +auto_refresh: true +fuzzy_finder_input: false +icon_set: nerd-font-v3 +refresh_interval: 10 +search_auto_select: false +sort_mode: switched +worktree_dir: ~/.local/share/worktrees diff --git a/tests/modules/programs/lazyworktree/default.nix b/tests/modules/programs/lazyworktree/default.nix new file mode 100644 index 00000000..cc19e1b1 --- /dev/null +++ b/tests/modules/programs/lazyworktree/default.nix @@ -0,0 +1 @@ +{ lazyworktree-settings = ./settings.nix; } diff --git a/tests/modules/programs/lazyworktree/settings.nix b/tests/modules/programs/lazyworktree/settings.nix new file mode 100644 index 00000000..d5a77f20 --- /dev/null +++ b/tests/modules/programs/lazyworktree/settings.nix @@ -0,0 +1,21 @@ +{ + programs.lazyworktree = { + enable = true; + settings = { + worktree_dir = "~/.local/share/worktrees"; + sort_mode = "switched"; + auto_fetch_prs = false; + auto_refresh = true; + refresh_interval = 10; + icon_set = "nerd-font-v3"; + search_auto_select = false; + fuzzy_finder_input = false; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/lazyworktree/config.yaml + assertFileContent home-files/.config/lazyworktree/config.yaml \ + ${./config.yaml} + ''; +}