{ lib , stdenv , buildGoPackage , fetchurl , makeWrapper , git , bash , gzip , openssh , pam , sqliteSupport ? true , pamSupport ? true , nixosTests }: buildGoPackage rec { pname = "gitea"; version = "1.18.1"; # not fetching directly from the git repo, because that lacks several vendor files for the web UI src = fetchurl { url = "https://dl.gitea.io/gitea/${version}/gitea-src-${version}.tar.gz"; sha256 = "sha256-FUliQ77P0WiwB1dWHDY3FjeJdHhUAcs/97JKXBdEdl0="; }; patches = [ ./static-root-path.patch ]; postPatch = '' substituteInPlace modules/setting/setting.go --subst-var data ''; nativeBuildInputs = [ makeWrapper ]; buildInputs = lib.optional pamSupport pam; preBuild = let tags = lib.optional pamSupport "pam" ++ lib.optional sqliteSupport "sqlite sqlite_unlock_notify"; tagsString = lib.concatStringsSep " " tags; in '' export buildFlagsArray=( -tags="${tagsString}" -ldflags='-X "main.Version=${version}" -X "main.Tags=${tagsString}"' ) ''; outputs = [ "out" "data" ]; postInstall = '' mkdir $data cp -R ./go/src/${goPackagePath}/{public,templates,options} $data mkdir -p $out cp -R ./go/src/${goPackagePath}/options/locale $out/locale wrapProgram $out/bin/gitea \ --prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]} ''; goPackagePath = "code.gitea.io/gitea"; passthru.tests = nixosTests.gitea; meta = with lib; { description = "Git with a cup of tea"; homepage = "https://gitea.io"; license = licenses.mit; maintainers = with maintainers; [ disassembler kolaente ma27 techknowlogick ]; broken = stdenv.isDarwin; }; }