nixpkgs/pkgs/applications/version-management/sourcehut/git.nix

151 lines
4.4 KiB
Nix
Raw Normal View History

2021-04-18 03:13:58 +00:00
{ lib
, fetchFromSourcehut
, buildPythonPackage
, buildGoModule
2021-04-18 03:13:58 +00:00
, python
, srht
, pygit2
, scmsrht
, srht-keys
2021-04-18 03:13:58 +00:00
}:
let
2021-11-13 21:46:58 +00:00
version = "0.73.6";
2021-04-18 03:13:58 +00:00
src = fetchFromSourcehut {
owner = "~sircmpwn";
repo = "git.sr.ht";
rev = version;
2021-11-13 21:46:58 +00:00
sha256 = "sha256-9WdeHXmyX5K/ldaE9AbSWTRlsrSDuKtm8QhthEHfmuU=";
2021-04-18 03:13:58 +00:00
};
gitsrht-shell = buildGoModule {
inherit src version;
sourceRoot = "source/gitsrht-shell";
2019-12-30 01:03:37 +00:00
pname = "gitsrht-shell";
2021-04-18 03:13:58 +00:00
vendorSha256 = "sha256-aqUFICp0C2reqb2p6JCPAUIRsxzSv0t9BHoNWrTYfqk=";
};
gitsrht-dispatch = buildGoModule {
inherit src version;
sourceRoot = "source/gitsrht-dispatch";
pname = "gitsrht-dispatch";
2021-04-18 03:13:58 +00:00
vendorSha256 = "sha256-qWXPHo86s6iuRBhRMtmD5jxnAWKdrWHtA/iSUkdw89M=";
patches = [
# Add support for supplementary groups
patches/redis-socket/git/v3-0003-gitsrht-dispatch-add-support-for-supplementary-gr.patch
];
patchFlags = ["-p2"];
};
2019-12-30 01:03:37 +00:00
gitsrht-keys = buildGoModule {
2019-12-30 01:03:37 +00:00
inherit src version;
sourceRoot = "source/gitsrht-keys";
2019-12-30 01:03:37 +00:00
pname = "gitsrht-keys";
2021-10-23 00:19:38 +00:00
vendorSha256 = "sha256-SOI7wimFthY+BwsDtMuyqKS1hCaEa3R90Q0qaA9boyE=";
# What follows is only to update go-redis,
# and thus also using a patched srht-keys.
# go.{mod,sum} could be patched directly but that would be less resilient
# to changes from upstream, and thus harder to maintain the patching
# while it hasn't been merged upstream.
overrideModAttrs = _: {
preBuild = ''
# This is a fixed-output derivation so it is not allowed to reference other derivations,
# but here srht-keys will be copied to vendor/ by go mod vendor
ln -s ${srht-keys} srht-keys
go mod edit -replace git.sr.ht/~sircmpwn/scm.sr.ht/srht-keys=$PWD/srht-keys
go get github.com/go-redis/redis/v8
go get github.com/go-redis/redis@none
go mod tidy
'';
# Pass updated go.{mod,sum} from go-modules to gitsrht-keys' vendor/go.{mod,sum}
postInstall = ''
cp --reflink=auto go.* $out/
'';
};
patches = [
# Update go-redis to support Unix sockets
patches/redis-socket/git/v3-0001-gitsrht-keys-update-go-redis-to-support-Unix-sock.patch
];
patchFlags = ["-p2"];
postConfigure = ''
cp -v vendor/go.{mod,sum} .
'';
2019-12-30 01:03:37 +00:00
};
gitsrht-update-hook = buildGoModule {
2019-12-30 01:03:37 +00:00
inherit src version;
sourceRoot = "source/gitsrht-update-hook";
2019-12-30 01:03:37 +00:00
pname = "gitsrht-update-hook";
2021-11-13 21:46:58 +00:00
vendorSha256 = "sha256-L/tGwbBSwhtGhHcinCK/0lsp1ffXjiHXCmGgsY9s2Nc=";
2020-06-23 00:18:41 +00:00
# What follows is only to update go-redis
# and thus also using a patched srht-keys.
overrideModAttrs = old: {
preBuild = ''
# This is a fixed-output derivation so it is not allowed to reference other derivations,
# but here srht-keys will be copied to vendor/ by go mod vendor
ln -s ${srht-keys} srht-keys
go mod edit -replace git.sr.ht/~sircmpwn/scm.sr.ht/srht-keys=$PWD/srht-keys
go get github.com/go-redis/redis/v8
go get github.com/go-redis/redis@none
go mod tidy
'';
# Pass updated go.{mod,sum} from go-modules to gitsrht-keys' vendor/go.{mod,sum}
postInstall = ''
cp --reflink=auto go.* $out/
'';
};
patches = [
# Update go-redis to support Unix sockets
patches/redis-socket/git/v3-0002-gitsrht-update-hook-update-go-redis-to-support-Un.patch
];
patchFlags = ["-p2"];
postConfigure = ''
cp -v vendor/go.{mod,sum} .
'';
};
2021-04-18 03:13:58 +00:00
in
buildPythonPackage rec {
inherit src version;
pname = "gitsrht";
nativeBuildInputs = srht.nativeBuildInputs;
propagatedBuildInputs = [
srht
pygit2
scmsrht
];
preBuild = ''
export PKGVER=${version}
2021-04-18 03:13:58 +00:00
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';
postInstall = ''
mkdir -p $out/bin
cp ${gitsrht-shell}/bin/gitsrht-shell $out/bin/gitsrht-shell
cp ${gitsrht-dispatch}/bin/gitsrht-dispatch $out/bin/gitsrht-dispatch
cp ${gitsrht-keys}/bin/gitsrht-keys $out/bin/gitsrht-keys
cp ${gitsrht-update-hook}/bin/gitsrht-update-hook $out/bin/gitsrht-update-hook
'';
2021-04-18 03:13:58 +00:00
passthru = {
inherit gitsrht-shell gitsrht-dispatch gitsrht-keys gitsrht-update-hook;
2021-04-18 03:13:58 +00:00
};
2021-01-03 05:36:55 +00:00
2021-08-15 21:11:47 +00:00
pythonImportsCheck = [ "gitsrht" ];
meta = with lib; {
homepage = "https://git.sr.ht/~sircmpwn/git.sr.ht";
description = "Git repository hosting service for the sr.ht network";
2021-08-15 20:54:11 +00:00
license = licenses.agpl3Only;
maintainers = with maintainers; [ eadwu ];
};
}