Open AndrewKvalheim opened 1 month ago
I noticed it bundles a vastly outdated version (2.0) of a dead project, which makes it quite risky. It also oddly bundles its own libgit2
, and I couldn't get it to use the system libgit2
.
I've been playing around with packaging it.
Here's what I have so far:
{ darwin
, fetchFromGitHub
, iconv
, lib
, libgit2
, ncurses
, stdenv
, cmake
, python3
, zlib
, useNixDeps ? true
}:
stdenv.mkDerivation rec {
pname = "debase";
version = "2";
src = (fetchFromGitHub {
owner = "toasterllc";
repo = "debase";
rev = "v${version}";
hash = "sha256-b1JbIwiSJxqpKiIexEZc2X0TDHxtFPcw95qCUxjFFUc=";
fetchSubmodules = true;
leaveDotGit = true;
}).overrideAttrs {
GIT_CONFIG_COUNT = 1;
GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf";
GIT_CONFIG_VALUE_0 = "git@github.com:";
};
patches = [
./debase-no-git.patch
./debase-no-xcrun.patch
] ++ lib.optionals useNixDeps [
./debase-no-vendored-deps.patch
];
buildInputs = (if useNixDeps then [
libgit2
ncurses
] else [
iconv
zlib
]) ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Foundation
];
nativeBuildInputs = lib.optionals (!useNixDeps) [
cmake
python3
];
dontUseCmakeConfigure = true;
installPhase = ''
mkdir -p $out/bin
cp build-${if stdenv.isDarwin then "mac" else "linux"}/release/debase $out/bin
'';
enableParallelBuilding = true;
makeFlags = [
"ARCHS=${
if stdenv.isx86_64 then
"x86_64"
else if stdenv.isAarch64 then
"arm64"
else
abort "unsupported system: ${stdenv.system}"
}"
];
}
debase-no-vendored-deps.patch debase-no-xcrun.patch debase-no-git.patch
This packages debase two different ways: one with debase's vendored ncurses
and libgit2
, and one with nix's ncurses
and libgit2
. The parameter useNixDeps
switches between them.
Both versions are building and running for me on my aarch64-darwin laptop.
Using the nix deps seems better, but debase has made a few patches to its copy of ncurses that are necessary to support its drag-and-drop features. I'm looking into that now to see if there is a good way to use nix's ncurses while still supporting those features. Using nix's libgit2 just seems to be a straightforward win, though.
I've looked at the patches that debase made to ncurses, and they are significant enough that it seems worthwhile to use debases's vendored copy of ncurses instead of using nix's ncurses.
Also, debase has now changed its submodule URLs, which allows us to drop the GITCONFIG* overrides. https://github.com/toasterllc/debase/pull/3
So here is a derivation that builds debase using debase's vendored ncurses and nix's libgit2:
{ darwin
, fetchFromGitHub
, lib
, libgit2
, stdenv
}:
stdenv.mkDerivation rec {
pname = "debase";
version = "2.2024-06-06";
src = fetchFromGitHub {
owner = "toasterllc";
repo = "debase";
rev = "4ea2c193bdeff6580ac623561ad81b008f2e34c7";
hash = "sha256-CqeU8LZJ4hc8eOzoRD81Opp5RmUjDrkTdOZg15U+mE0=";
fetchSubmodules = true;
leaveDotGit = true;
};
patches = [
./debase-no-git.patch
./debase-no-xcrun.patch
./debase-no-vendored-libgit2.patch
];
buildInputs = [
libgit2
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Foundation
];
installPhase = ''
mkdir -p $out/bin
cp build-${if stdenv.isDarwin then "mac" else "linux"}/release/debase $out/bin
'';
enableParallelBuilding = true;
makeFlags = [
"ARCHS=${
if stdenv.isx86_64 then
"x86_64"
else if stdenv.isAarch64 then
"arm64"
else
abort "unsupported system: ${stdenv.system}"
}"
];
}
debase-no-xcrun.patch debase-no-git.patch debase-no-vendored-libgit2.patch
I tested it on my aarch64-darwin laptop and it builds and runs and supports drag and drop.
Project description
debase is a TUI for drag-and-drop manipulation of Git commits:
Metadata
Add a :+1: reaction to issues you find important.