Files
nixpkgs/pkgs/by-name/pk/pkgit/package.nix
Philip Taron a103ad9dd8 pkgit: repackage 1.1.3 from upstream C rewrite
The package targeted pkgit 0.0.11 from the abandoned GitHub mirror
(dacctal/pkgit), the old Nim implementation. Real upstream
(https://git.symlinx.net/pkgit) has since rewritten pkgit in C and
released up to 1.1.3.

Repackage against real upstream:

- build the C sources (Makefile + luajit) via stdenv.mkDerivation,
  fetching from git.symlinx.net with fetchgit (drops buildNimPackage
  and lock.json)
- patch main() so -v/--version and -h/--help respond before the Lua
  config is loaded, so they work without a config and versionCheckHook
  (now correctly wired via doInstallCheck/nativeInstallCheckInputs)
  can use them
- wrap with git on PATH (runtime dependency, src/fetch_git.c)

Assisted-by: Claude Code (claude-opus-4-8)
2026-06-29 10:35:15 -07:00

67 lines
1.6 KiB
Nix

{
lib,
stdenv,
fetchgit,
pkg-config,
luajit,
git,
makeWrapper,
nix-update-script,
versionCheckHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "pkgit";
version = "1.1.3";
src = fetchgit {
url = "https://git.symlinx.net/pkgit";
tag = finalAttrs.version;
hash = "sha256-xGrhkVA5H/expArfUbfJ8p1odUAeJiL/vbsPedd92EE=";
};
__structuredAttrs = true;
patches = [
# main() loads the Lua config (which requires ~/.config/pkgit/init.lua)
# before parsing arguments, so `pkgit --version` and `--help` abort without
# a config. Answer those informational flags first so they work standalone
# and can be used by versionCheckHook.
./0001-main-handle-version-help-before-loading-the-Lua-config.patch
];
strictDeps = true;
nativeBuildInputs = [
pkg-config
makeWrapper
];
buildInputs = [ luajit ];
# The Makefile defaults CC to clang via `?=`; stdenv exports CC, which wins.
makeFlags = [ "PREFIX=${placeholder "out"}" ];
enableParallelBuilding = true;
# pkgit shells out to git at runtime (src/fetch_git.c execvp's "git").
postInstall = ''
wrapProgram $out/bin/pkgit \
--prefix PATH : ${lib.makeBinPath [ git ]}
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
passthru.updateScript = nix-update-script { };
meta = {
description = "Unconventional package manager that compiles and installs packages directly from Git repositories";
homepage = "https://git.symlinx.net/pkgit";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ Ra77a3l3-jar ];
mainProgram = "pkgit";
platforms = lib.platforms.unix;
};
})