From e5bd86b7518c0cd40f82ae3cca4b131c4db053f7 Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Thu, 14 Nov 2024 23:22:59 +0100 Subject: [PATCH 1/3] maintainers: Add jiriks74 --- maintainers/maintainer-list.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 6669374552729..af83af87c36fc 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -10456,6 +10456,18 @@ githubId = 1476865; name = "jigglycrumb"; }; + jiriks74 = { + name = "Jiří Štefka"; + email = "jiri@stefka.eu"; + github = "jiriks74"; + githubId = 54378412; + matrix = "@jiriks74:matrix.org"; + keys = [ + { + fingerprint = "563AC7887FD6414714A6ACAC1D5E30D3DB2264DE"; + } + ]; + }; jirkamarsik = { email = "jiri.marsik89@gmail.com"; github = "jirkamarsik"; From 17121bf6202f76fa52b2a41165fc38a0f132f8a6 Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Thu, 14 Nov 2024 23:23:10 +0100 Subject: [PATCH 2/3] git-worktree-switcher: init at 0.2.4 [`git worktree` documentation](https://git-scm.com/docs/git-worktree) [`git-worktree-switcher` repository](https://github.com/mateusauler/git-worktree-switcher) From the project's description: > Switch between git worktrees with speed. It's a wrapper script around `git worktree` making some tasks, like switching between worktrees, easier. > [!Note] > `git worktree` is a little known feature and adding QoL things can help it's adoption as it's a considerable upgrade against the `git stash` workflow. --- .../disable-update.patch | 30 ++++++++++ .../gi/git-worktree-switcher/package.nix | 60 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 pkgs/by-name/gi/git-worktree-switcher/disable-update.patch create mode 100644 pkgs/by-name/gi/git-worktree-switcher/package.nix diff --git a/pkgs/by-name/gi/git-worktree-switcher/disable-update.patch b/pkgs/by-name/gi/git-worktree-switcher/disable-update.patch new file mode 100644 index 0000000000000..2763ab3a3fe17 --- /dev/null +++ b/pkgs/by-name/gi/git-worktree-switcher/disable-update.patch @@ -0,0 +1,30 @@ +diff --git a/wt b/wt +index 60999f2..5687822 100755 +--- a/wt ++++ b/wt +@@ -27,7 +27,6 @@ help_message() { + echo -e "\twt: go to the main worktree" + echo -e "\twt : search for worktree names and change to that directory." + echo -e "\twt names: list out only the git worktree names." +- echo -e "\twt update: update to the latest release of worktree switcher." + echo -e "\twt version: show the CLI version." + echo -e "\twt init : print the init script for ." + echo -e "\twt help: shows this help message." +@@ -163,9 +162,6 @@ case "${args[0]}" in + names) + worktree_list_names + ;; +-update) +- update +- ;; + help) + help_message + ;; +@@ -176,7 +172,6 @@ init) + init + ;; + *) +- auto_check_update + directory=$(git worktree list --porcelain 2> /dev/null | sed -n '/'"${arg:-.}"'/{s/^worktree\s*//p;q}') + ;; + esac diff --git a/pkgs/by-name/gi/git-worktree-switcher/package.nix b/pkgs/by-name/gi/git-worktree-switcher/package.nix new file mode 100644 index 0000000000000..9c9f64e58c966 --- /dev/null +++ b/pkgs/by-name/gi/git-worktree-switcher/package.nix @@ -0,0 +1,60 @@ +{ + lib, + stdenv, + fetchFromGitHub, + makeWrapper, + installShellFiles, + git, + jq, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "git-worktree-switcher"; + version = "0.2.4"; + + src = fetchFromGitHub { + owner = "mateusauler"; + repo = "git-worktree-switcher"; + rev = "refs/tags/${finalAttrs.version}-fork"; + hash = "sha256-N+bDsLEUM6FWhyliUav2n5hwMa5EEuVPoIK+Cja0DxA="; + }; + + buildInputs = [ + jq + git + ]; + + nativeBuildInputs = [ + makeWrapper + installShellFiles + ]; + + patches = [ + ./disable-update.patch # Disable update and auto update functionality + ]; + + installPhase = '' + mkdir -p $out/bin + + cp wt $out/bin + wrapProgram $out/bin/wt --prefix PATH : ${ + lib.makeBinPath [ + git + jq + ] + } + + installShellCompletion --zsh completions/_wt_completion + installShellCompletion --bash completions/wt_completion + installShellCompletion --fish completions/wt.fish + ''; + + meta = { + homepage = "https://github.com/mateusauler/git-worktree-switcher"; + description = "Switch between git worktrees with speed."; + license = lib.licenses.mit; + platforms = lib.platforms.all; + mainProgram = "wt"; + maintainers = with lib.maintainers; [ jiriks74 ]; + }; +}) From 3318aa52de01fed525e04ba6d73a7cc2e2aafff4 Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Thu, 14 Nov 2024 12:53:07 +0100 Subject: [PATCH 3/3] nixos/git-worktree-switcher: init git-worktree-switcher This module sets up shells so that they work with [git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher) --- .../manual/release-notes/rl-2505.section.md | 2 + nixos/modules/module-list.nix | 1 + .../programs/git-worktree-switcher.nix | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 nixos/modules/programs/git-worktree-switcher.nix diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 39849d5d64c24..bb690cb8a467f 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -20,6 +20,8 @@ - [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable). +- [git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher), switch between git worktrees with speed. Available as [programs.git-worktree-switcher](#opt-programs.git-worktree-switcher.enable) + ## Backward Incompatibilities {#sec-release-25.05-incompatibilities} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3b31c12df77aa..4081aa28b140e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -205,6 +205,7 @@ ./programs/gdk-pixbuf.nix ./programs/geary.nix ./programs/git.nix + ./programs/git-worktree-switcher.nix ./programs/gnome-disks.nix ./programs/gnome-terminal.nix ./programs/gnupg.nix diff --git a/nixos/modules/programs/git-worktree-switcher.nix b/nixos/modules/programs/git-worktree-switcher.nix new file mode 100644 index 0000000000000..c85ebfbd49cda --- /dev/null +++ b/nixos/modules/programs/git-worktree-switcher.nix @@ -0,0 +1,40 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.programs.git-worktree-switcher; + + initScript = + shell: + if (shell == "fish") then + '' + ${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source + '' + else + '' + eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})" + ''; +in +{ + options = { + programs.git-worktree-switcher = { + enable = lib.mkEnableOption "git-worktree-switcher, switch between git worktrees with speed."; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ git-worktree-switcher ]; + + programs.bash.interactiveShellInit = initScript "bash"; + programs.zsh.interactiveShellInit = lib.optionalString config.programs.zsh.enable ( + initScript "zsh" + ); + programs.fish.interactiveShellInit = lib.optionalString config.programs.fish.enable ( + initScript "fish" + ); + }; +}