diff --git a/README.md b/README.md index adab1e7..1cbfc86 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Managed via Home Manager (`home.nix`). Applied using `./apply.sh`. **CLI Utilities** - `neovim` - Editor - `git`, `lazygit` - Version control +- `but` - GitButler CLI (`pkgs/but.nix`, pinned; bump version/hashes by hand) - `ripgrep` (`rg`), `fd` - Fast search - `pay-respects` - Command correction (`f`) - `sops`, `age` - Secret management diff --git a/home.nix b/home.nix index 5c0d20c..fd994de 100644 --- a/home.nix +++ b/home.nix @@ -43,6 +43,7 @@ starship zoxide lazygit + (callPackage ./pkgs/but.nix { }) fastfetch eza atuin diff --git a/pkgs/but.nix b/pkgs/but.nix new file mode 100644 index 0000000..b45f636 --- /dev/null +++ b/pkgs/but.nix @@ -0,0 +1,70 @@ +# GitButler CLI (`but`). nixpkgs `gitbutler` is GUI-only and builds from source. +# ponytail: pinned by hand; bump `version`, `build`, and both hashes (see releases JSON at +# https://app.gitbutler.com/releases/version/) to upgrade. +{ + lib, + stdenvNoCC, + fetchurl, + autoPatchelfHook, + dbus, + zlib, + stdenv, +}: +let + version = "0.22.3"; + build = "3234"; + base = "https://releases.gitbutler.com/releases/release/${version}-${build}"; + isDarwin = stdenvNoCC.hostPlatform.isDarwin; + src = + if isDarwin then + fetchurl { + url = "${base}/macos/aarch64/GitButler.app.tar.gz"; + hash = "sha256-7fD2gMEC/4b67h2RnqKmFm/L5uOpiYZwbJGjju1mL3Q="; + } + else + fetchurl { + url = "${base}/linux/x86_64/but"; + hash = "sha256-P09UOmzNkxzmyGxIQFjb5eKUOVl9AB9qCpwo2eUz6hg="; + }; +in +stdenvNoCC.mkDerivation { + pname = "but"; + inherit version src; + + sourceRoot = "."; + unpackPhase = if isDarwin then "tar xzf $src" else "true"; + + nativeBuildInputs = lib.optional (!isDarwin) autoPatchelfHook; + buildInputs = lib.optionals (!isDarwin) [ + dbus + zlib + stdenv.cc.cc.lib + ]; + + # Re-signing/stripping would break the app's code signature on macOS. + dontFixup = isDarwin; + + installPhase = + if isDarwin then + '' + mkdir -p $out/Applications $out/bin + cp -r GitButler.app $out/Applications/ + # the app binary acts as the CLI when invoked as `but` + ln -s $out/Applications/GitButler.app/Contents/MacOS/gitbutler-tauri $out/bin/but + '' + else + '' + install -Dm755 $src $out/bin/but + ''; + + meta = { + description = "GitButler CLI"; + homepage = "https://gitbutler.com"; + license = lib.licenses.fsl11Mit; + mainProgram = "but"; + platforms = [ + "aarch64-darwin" + "x86_64-linux" + ]; + }; +}