2021-03-20 04:20:00 +00:00
|
|
|
{ lib
|
2023-01-11 07:51:40 +00:00
|
|
|
, stdenv
|
2023-02-02 18:25:31 +00:00
|
|
|
, buildGoModule
|
2024-06-05 15:53:02 +00:00
|
|
|
, fetchFromGitHub
|
2021-03-20 04:20:00 +00:00
|
|
|
, makeWrapper
|
|
|
|
, git
|
|
|
|
, bash
|
2023-07-15 17:15:38 +00:00
|
|
|
, coreutils
|
2023-03-24 00:07:29 +00:00
|
|
|
, gitea
|
2021-03-20 04:20:00 +00:00
|
|
|
, gzip
|
|
|
|
, openssh
|
|
|
|
, pam
|
2020-04-24 23:36:52 +00:00
|
|
|
, sqliteSupport ? true
|
|
|
|
, pamSupport ? true
|
2023-03-24 00:07:29 +00:00
|
|
|
, runCommand
|
|
|
|
, brotli
|
|
|
|
, xorg
|
2021-02-05 17:12:51 +00:00
|
|
|
, nixosTests
|
2024-06-05 15:53:02 +00:00
|
|
|
, buildNpmPackage
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
let
|
|
|
|
frontend = buildNpmPackage {
|
|
|
|
pname = "gitea-frontend";
|
|
|
|
inherit (gitea) src version;
|
|
|
|
|
|
|
|
npmDepsHash = "sha256-gXBBiDIIS0aW6qK37HcF0AuJOliblinznRVXoo6DV1s=";
|
|
|
|
|
|
|
|
# use webpack directly instead of 'make frontend' as the packages are already installed
|
|
|
|
buildPhase = ''
|
|
|
|
BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R public $out/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in buildGoModule rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "gitea";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "1.22.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "go-gitea";
|
|
|
|
repo = "gitea";
|
|
|
|
rev = "v${gitea.version}";
|
|
|
|
hash = "sha256-LdNEiPch2BZNYMOjE9yWsq78g6DolMjM5wUci3jXj30=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
vendorHash = "sha256-8VoJR4p2WnhG6nTFMzBlcrd/B6UwaOU3Q/rnDx9MtWc=";
|
2023-02-02 18:25:31 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
outputs = [ "out" "data" ];
|
|
|
|
|
|
|
|
patches = [ ./static-root-path.patch ];
|
|
|
|
|
|
|
|
# go-modules derivation doesn't provide $data
|
|
|
|
# so we need to wait until it is built, and then
|
|
|
|
# at that time we can then apply the substituteInPlace
|
|
|
|
overrideModAttrs = _: { postPatch = null; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
substituteInPlace modules/setting/server.go --subst-var data
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
subPackages = [ "." ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
buildInputs = lib.optional pamSupport pam;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
tags = lib.optional pamSupport "pam"
|
|
|
|
++ lib.optionals sqliteSupport [ "sqlite" "sqlite_unlock_notify" ];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X main.Version=${version}"
|
|
|
|
"-X 'main.Tags=${lib.concatStringsSep " " tags}'"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir $data
|
2024-06-05 15:53:02 +00:00
|
|
|
ln -s ${frontend}/public $data/public
|
|
|
|
cp -R ./{templates,options} $data
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out
|
2023-02-02 18:25:31 +00:00
|
|
|
cp -R ./options/locale $out/locale
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
wrapProgram $out/bin/gitea \
|
2023-07-15 17:15:38 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ bash coreutils git gzip openssh ]}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru = {
|
|
|
|
data-compressed = runCommand "gitea-data-compressed" {
|
|
|
|
nativeBuildInputs = [ brotli xorg.lndir ];
|
|
|
|
} ''
|
|
|
|
mkdir $out
|
|
|
|
lndir ${gitea.data}/ $out/
|
|
|
|
|
|
|
|
# Create static gzip and brotli files
|
|
|
|
find -L $out -type f -regextype posix-extended -iregex '.*\.(css|html|js|svg|ttf|txt)' \
|
|
|
|
-exec gzip --best --keep --force {} ';' \
|
|
|
|
-exec brotli --best --keep --no-copy-stat {} ';'
|
|
|
|
'';
|
|
|
|
|
|
|
|
tests = nixosTests.gitea;
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Git with a cup of tea";
|
2024-06-05 15:53:02 +00:00
|
|
|
homepage = "https://about.gitea.com";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2024-06-05 15:53:02 +00:00
|
|
|
maintainers = with maintainers; [ ma27 techknowlogick SuperSandro2000 ];
|
2023-01-11 07:51:40 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2023-08-04 22:07:22 +00:00
|
|
|
mainProgram = "gitea";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|