From 0ad9a4ab539769ec8575642b3c5bbdd515554785 Mon Sep 17 00:00:00 2001 From: Ra77a3l3-jar Date: Sat, 9 May 2026 13:07:47 +0200 Subject: [PATCH 1/2] pkgit: init at 0.0.11 --- pkgs/by-name/pk/pkgit/lock.json | 15 +++++++++ pkgs/by-name/pk/pkgit/package.nix | 54 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 pkgs/by-name/pk/pkgit/lock.json create mode 100644 pkgs/by-name/pk/pkgit/package.nix diff --git a/pkgs/by-name/pk/pkgit/lock.json b/pkgs/by-name/pk/pkgit/lock.json new file mode 100644 index 000000000000..605cd1f580e9 --- /dev/null +++ b/pkgs/by-name/pk/pkgit/lock.json @@ -0,0 +1,15 @@ +{ + "depends": [ + { + "method": "fetchzip", + "packages": [ + "parsetoml" + ], + "ref": "v0.7.2", + "rev": "d297f5a81be2472905d367aa675dcbbca6e7a5d2", + "sha256": "0dax2bfzwygx4142qywib9n4z3h3cvvr5dy2h3jy35iizg16iqka", + "srcDir": "src", + "url": "https://github.com/NimParsers/parsetoml/archive/d297f5a81be2472905d367aa675dcbbca6e7a5d2.tar.gz" + } + ] +} diff --git a/pkgs/by-name/pk/pkgit/package.nix b/pkgs/by-name/pk/pkgit/package.nix new file mode 100644 index 000000000000..a589aca6b333 --- /dev/null +++ b/pkgs/by-name/pk/pkgit/package.nix @@ -0,0 +1,54 @@ +{ + lib, + buildNimPackage, + fetchFromGitHub, + git, + makeWrapper, + nix-update-script, + versionCheckHook, +}: + +buildNimPackage (finalAttrs: { + pname = "pkgit"; + version = "0.0.11"; + + src = fetchFromGitHub { + owner = "dacctal"; + repo = "pkgit"; + tag = "${finalAttrs.version}"; + hash = "sha256-k9egbZD7V2EdIQRTJ8kVic7pNvAvIln5O+ke1lciCT8="; + }; + + __structuredAttrs = true; + + lockFile = ./lock.json; + + # getAppFilename() returns .pkgit-wrapped after wrapProgram renames the binary, + # breaking ensureSu's sudo re-exec. paramStr(0) gives the full wrapper path. + postPatch = '' + substituteInPlace src/ensureSu.nim \ + --replace-fail 'getAppFilename().extractFileName' 'paramStr(0)' + ''; + + nativeBuildInputs = [ makeWrapper ]; + + postInstall = '' + wrapProgram $out/bin/pkgit \ + --prefix PATH : ${lib.makeBinPath [ git ]} + ''; + + doCheck = true; + + nativeCheckInputs = [ versionCheckHook ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Unconventional package manager that compiles and installs packages directly from Git repositories"; + homepage = "https://github.com/dacctal/pkgit"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ Ra77a3l3-jar ]; + mainProgram = "pkgit"; + platforms = lib.platforms.unix; + }; +}) From a103ad9dd8b20c87581d8126129c51349227ce36 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Mon, 29 Jun 2026 09:55:29 -0700 Subject: [PATCH 2/2] 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) --- ...n-help-before-loading-the-Lua-config.patch | 45 ++++++++++++++++ pkgs/by-name/pk/pkgit/lock.json | 15 ------ pkgs/by-name/pk/pkgit/package.nix | 54 +++++++++++-------- 3 files changed, 78 insertions(+), 36 deletions(-) create mode 100644 pkgs/by-name/pk/pkgit/0001-main-handle-version-help-before-loading-the-Lua-config.patch delete mode 100644 pkgs/by-name/pk/pkgit/lock.json diff --git a/pkgs/by-name/pk/pkgit/0001-main-handle-version-help-before-loading-the-Lua-config.patch b/pkgs/by-name/pk/pkgit/0001-main-handle-version-help-before-loading-the-Lua-config.patch new file mode 100644 index 000000000000..c62480fac27d --- /dev/null +++ b/pkgs/by-name/pk/pkgit/0001-main-handle-version-help-before-loading-the-Lua-config.patch @@ -0,0 +1,45 @@ +From 366607d5e2bc8a7e067105f1c0d0e6c2c235c131 Mon Sep 17 00:00:00 2001 +From: Philip Taron +Date: Mon, 29 Jun 2026 10:04:36 -0700 +Subject: [PATCH] main: handle --version/--help before loading the Lua config + +main() loads the Lua configuration before parsing arguments, and the +loader exits when no config file exists. That makes `pkgit --version` +and `pkgit --help` fail on a fresh install. Answer those informational +flags first so they work without a config. +--- + src/main.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/main.c b/src/main.c +index 9010d3e..4c45b8a 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -1,4 +1,5 @@ + #include ++#include + + #include "cla_parse.h" + #include "lua_state.h" +@@ -7,6 +8,18 @@ + + int main(int argc, char *argv[]) { + init_vars(); ++ ++ /* Respond to informational flags before loading the Lua config, which aborts ++ when no config file (~/.config/pkgit/init.lua) exists. This keeps ++ `pkgit --version` and `pkgit --help` usable on a fresh install. */ ++ for (int i = 1; i < argc; i++) { ++ if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") || ++ !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { ++ cla_parse(argc, argv); ++ return 0; ++ } ++ } ++ + init_lua_state(); + setup_pkgit(); + cache_repos(); +-- +2.54.0 + diff --git a/pkgs/by-name/pk/pkgit/lock.json b/pkgs/by-name/pk/pkgit/lock.json deleted file mode 100644 index 605cd1f580e9..000000000000 --- a/pkgs/by-name/pk/pkgit/lock.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "depends": [ - { - "method": "fetchzip", - "packages": [ - "parsetoml" - ], - "ref": "v0.7.2", - "rev": "d297f5a81be2472905d367aa675dcbbca6e7a5d2", - "sha256": "0dax2bfzwygx4142qywib9n4z3h3cvvr5dy2h3jy35iizg16iqka", - "srcDir": "src", - "url": "https://github.com/NimParsers/parsetoml/archive/d297f5a81be2472905d367aa675dcbbca6e7a5d2.tar.gz" - } - ] -} diff --git a/pkgs/by-name/pk/pkgit/package.nix b/pkgs/by-name/pk/pkgit/package.nix index a589aca6b333..33fb6ac9254e 100644 --- a/pkgs/by-name/pk/pkgit/package.nix +++ b/pkgs/by-name/pk/pkgit/package.nix @@ -1,51 +1,63 @@ { lib, - buildNimPackage, - fetchFromGitHub, + stdenv, + fetchgit, + pkg-config, + luajit, git, makeWrapper, nix-update-script, versionCheckHook, }: -buildNimPackage (finalAttrs: { +stdenv.mkDerivation (finalAttrs: { pname = "pkgit"; - version = "0.0.11"; + version = "1.1.3"; - src = fetchFromGitHub { - owner = "dacctal"; - repo = "pkgit"; - tag = "${finalAttrs.version}"; - hash = "sha256-k9egbZD7V2EdIQRTJ8kVic7pNvAvIln5O+ke1lciCT8="; + src = fetchgit { + url = "https://git.symlinx.net/pkgit"; + tag = finalAttrs.version; + hash = "sha256-xGrhkVA5H/expArfUbfJ8p1odUAeJiL/vbsPedd92EE="; }; __structuredAttrs = true; - lockFile = ./lock.json; + 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 + ]; - # getAppFilename() returns .pkgit-wrapped after wrapProgram renames the binary, - # breaking ensureSu's sudo re-exec. paramStr(0) gives the full wrapper path. - postPatch = '' - substituteInPlace src/ensureSu.nim \ - --replace-fail 'getAppFilename().extractFileName' 'paramStr(0)' - ''; + strictDeps = true; - nativeBuildInputs = [ makeWrapper ]; + 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 ]} ''; - doCheck = true; - - nativeCheckInputs = [ versionCheckHook ]; + 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://github.com/dacctal/pkgit"; + homepage = "https://git.symlinx.net/pkgit"; license = lib.licenses.gpl3Plus; maintainers = with lib.maintainers; [ Ra77a3l3-jar ]; mainProgram = "pkgit";