Skip to content

Commit

Permalink
got-unwrapped: init at 0.100; got: wrap got-unwrapped with ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
eclairevoyant committed Jun 24, 2024
1 parent 69b095e commit 1ee1ddb
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 58 deletions.
78 changes: 78 additions & 0 deletions pkgs/by-name/go/got-unwrapped/package.nix
Original file line number Diff line number Diff line change
@@ -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;
};
})
13 changes: 13 additions & 0 deletions pkgs/by-name/go/got-unwrapped/search-for-ssh-in-path.patch
Original file line number Diff line number Diff line change
@@ -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)
87 changes: 29 additions & 58 deletions pkgs/by-name/go/got/package.nix
Original file line number Diff line number Diff line change
@@ -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
;
};
})
}

0 comments on commit 1ee1ddb

Please sign in to comment.