diff --git a/pkgs/by-name/go/got-unwrapped/package.nix b/pkgs/by-name/go/got-unwrapped/package.nix new file mode 100644 index 0000000000000..84c3bacd88911 --- /dev/null +++ b/pkgs/by-name/go/got-unwrapped/package.nix @@ -0,0 +1,78 @@ +{ lib +, stdenv +, fetchurl +, pkg-config +, libressl +, libbsd +, libevent +, libuuid +, libossp_uuid +, libmd +, zlib +, ncurses +, bison +, autoPatchelfHook +, testers +, got +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "got-unwrapped"; + version = "0.100"; + + src = fetchurl { + url = "https://gameoftrees.org/releases/portable/got-portable-${finalAttrs.version}.tar.gz"; + hash = "sha256-/DqKIGf/aZ09aL/rB7te+AauHmJ+mOTrVEbkqT9WUBI="; + }; + + patches = [ + # force got to search for ssh in PATH, to prevent locking in a dependency + ./search-for-ssh-in-path.patch + ]; + + nativeBuildInputs = [ pkg-config bison ] + ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + + buildInputs = [ libressl libbsd libevent libuuid libmd zlib ncurses ] + ++ lib.optionals stdenv.isDarwin [ libossp_uuid ]; + + preConfigure = lib.optionalString stdenv.isDarwin '' + # The configure script assumes dependencies on Darwin are installed via + # Homebrew or MacPorts and hardcodes assumptions about the paths of + # dependencies which fails the nixpkgs configurePhase. + substituteInPlace configure --replace-fail 'xdarwin' 'xhomebrew' + ''; + + env.NIX_CFLAGS_COMPILE = toString ([ + "-DGOT_DIAL_PATH_SSH=\"ssh\"" + "-DGOT_TAG_PATH_SSH_KEYGEN=\"ssh-keygen\"" + ] ++ lib.optionals stdenv.isDarwin [ + # error: conflicting types for 'strmode' + "-DHAVE_STRMODE=1" + # Undefined symbols for architecture arm64: "_bsd_getopt" + "-include getopt.h" + ]); + + passthru.tests.version = testers.testVersion { + package = got.override { got-unwrapped = finalAttrs.finalPackage; }; + }; + + meta = { + changelog = "https://gameoftrees.org/releases/CHANGES"; + description = "Version control system which prioritizes ease of use and simplicity over flexibility"; + longDescription = '' + Game of Trees (Got) is a version control system which prioritizes + ease of use and simplicity over flexibility. + + Got uses Git repositories to store versioned data. Git can be used + for any functionality which has not yet been implemented in + Got. It will always remain possible to work with both Got and Git + on the same repository. + ''; + homepage = "https://gameoftrees.org"; + license = lib.licenses.isc; + maintainers = with lib.maintainers; [ abbe afh ]; + mainProgram = "got"; + platforms = with lib.platforms; darwin ++ linux; + }; +}) diff --git a/pkgs/by-name/go/got-unwrapped/search-for-ssh-in-path.patch b/pkgs/by-name/go/got-unwrapped/search-for-ssh-in-path.patch new file mode 100644 index 0000000000000..5c89aa3bb4a29 --- /dev/null +++ b/pkgs/by-name/go/got-unwrapped/search-for-ssh-in-path.patch @@ -0,0 +1,13 @@ +--- a/lib/dial.c 1970-01-01 00:00:01.000000000 +0000 ++++ b/lib/dial.c 1970-01-01 00:00:01.000000000 +0000 +@@ -316,8 +316,8 @@ + err(1, "dup2"); + if (strlcpy(cmd, command, sizeof(cmd)) >= sizeof(cmd)) + err(1, "snprintf"); +- if (execv(GOT_DIAL_PATH_SSH, (char *const *)argv) == -1) +- err(1, "execv %s", GOT_DIAL_PATH_SSH); ++ if (execvp(GOT_DIAL_PATH_SSH, (char *const *)argv) == -1) ++ err(1, "execvp %s", GOT_DIAL_PATH_SSH); + abort(); /* not reached */ + } else { + if (close(pfd[0]) == -1) diff --git a/pkgs/by-name/go/got/package.nix b/pkgs/by-name/go/got/package.nix index 7faf1ff013a5a..36e3607643eaf 100644 --- a/pkgs/by-name/go/got/package.nix +++ b/pkgs/by-name/go/got/package.nix @@ -1,69 +1,40 @@ -{ lib -, stdenv -, fetchurl -, pkg-config -, libressl -, libbsd -, libevent -, libuuid -, libossp_uuid -, libmd -, zlib -, ncurses -, bison -, autoPatchelfHook -, testers +{ + lib, + stdenv, + got-unwrapped, + openssh, + makeWrapper, }: -stdenv.mkDerivation (finalAttrs: { +stdenv.mkDerivation { pname = "got"; - version = "0.100"; + inherit (got-unwrapped) version; - src = fetchurl { - url = "https://gameoftrees.org/releases/portable/got-portable-${finalAttrs.version}.tar.gz"; - hash = "sha256-/DqKIGf/aZ09aL/rB7te+AauHmJ+mOTrVEbkqT9WUBI="; - }; - - nativeBuildInputs = [ pkg-config bison ] - ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + dontUnpack = true; + dontConfigure = true; + dontBuild = true; - buildInputs = [ libressl libbsd libevent libuuid libmd zlib ncurses ] - ++ lib.optionals stdenv.isDarwin [ libossp_uuid ]; + nativeBuildInputs = [ makeWrapper ]; - preConfigure = lib.optionalString stdenv.isDarwin '' - # The configure script assumes dependencies on Darwin are installed via - # Homebrew or MacPorts and hardcodes assumptions about the paths of - # dependencies which fails the nixpkgs configurePhase. - substituteInPlace configure --replace-fail 'xdarwin' 'xhomebrew' - ''; + installPhase = '' + runHook preInstall - env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.isDarwin [ - # error: conflicting types for 'strmode' - "-DHAVE_STRMODE=1" - # Undefined symbols for architecture arm64: "_bsd_getopt" - "-include getopt.h" - ]); + makeWrapper ${got-unwrapped}/bin/got $out/bin/got \ + --prefix PATH : ${lib.makeBinPath [ openssh ]} - passthru.tests.version = testers.testVersion { - package = finalAttrs.finalPackage; - }; + runHook postInstall + ''; meta = { - changelog = "https://gameoftrees.org/releases/CHANGES"; - description = "Version control system which prioritizes ease of use and simplicity over flexibility"; - longDescription = '' - Game of Trees (Got) is a version control system which prioritizes - ease of use and simplicity over flexibility. - - Got uses Git repositories to store versioned data. Git can be used - for any functionality which has not yet been implemented in - Got. It will always remain possible to work with both Got and Git - on the same repository. - ''; - homepage = "https://gameoftrees.org"; - license = lib.licenses.isc; - maintainers = with lib.maintainers; [ abbe afh ]; - mainProgram = "got"; - platforms = with lib.platforms; darwin ++ linux; + inherit (got-unwrapped.meta) + changelog + description + longDescription + homepage + license + maintainers + mainProgram + platforms + ; }; -}) +}