2023-02-09 11:40:11 +00:00
|
|
|
{ bash
|
2023-03-24 00:07:29 +00:00
|
|
|
, brotli
|
2023-02-02 18:25:31 +00:00
|
|
|
, buildGoModule
|
2023-03-24 00:07:29 +00:00
|
|
|
, forgejo
|
2023-02-02 18:25:31 +00:00
|
|
|
, git
|
|
|
|
, gzip
|
2023-02-09 11:40:11 +00:00
|
|
|
, lib
|
|
|
|
, makeWrapper
|
2023-03-04 12:14:45 +00:00
|
|
|
, nixosTests
|
2023-02-09 11:40:11 +00:00
|
|
|
, openssh
|
2023-02-02 18:25:31 +00:00
|
|
|
, pam
|
|
|
|
, pamSupport ? true
|
|
|
|
, sqliteSupport ? true
|
2023-03-24 00:07:29 +00:00
|
|
|
, xorg
|
|
|
|
, runCommand
|
2023-02-09 11:40:11 +00:00
|
|
|
, stdenv
|
2023-04-29 16:46:19 +00:00
|
|
|
, fetchFromGitea
|
|
|
|
, buildNpmPackage
|
2023-02-02 18:25:31 +00:00
|
|
|
}:
|
2022-12-28 21:21:41 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
let
|
2023-07-15 17:15:38 +00:00
|
|
|
frontend = buildNpmPackage {
|
2023-04-29 16:46:19 +00:00
|
|
|
pname = "forgejo-frontend";
|
|
|
|
inherit (forgejo) src version;
|
|
|
|
|
|
|
|
npmDepsHash = "sha256-dB/uBuS0kgaTwsPYnqklT450ejLHcPAqBdDs3JT8Uxg=";
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./package-json-npm-build-frontend.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
# override npmInstallHook
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp -R ./public $out/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2023-02-02 18:25:31 +00:00
|
|
|
buildGoModule rec {
|
2022-12-28 21:21:41 +00:00
|
|
|
pname = "forgejo";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "1.19.4-0";
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "codeberg.org";
|
|
|
|
owner = "forgejo";
|
|
|
|
repo = "forgejo";
|
|
|
|
rev = "v${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-pTcnST8A4gADPBkNago9uwRFEmTx8vNONL/Emer4xLI=";
|
2022-12-28 21:21:41 +00:00
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
vendorHash = "sha256-LKxhNbSIRaP4EGWX6mE26G9CWfoFTrPRjrL4ShpRHWo=";
|
2023-02-02 18:25:31 +00:00
|
|
|
|
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
outputs = [ "out" "data" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = lib.optional pamSupport pam;
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./../gitea/static-root-path.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace modules/setting/setting.go --subst-var data
|
|
|
|
'';
|
|
|
|
|
|
|
|
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}'"
|
|
|
|
];
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
preBuild = ''
|
|
|
|
go run build/merge-forgejo-locales.go
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir $data
|
2023-04-29 16:46:19 +00:00
|
|
|
cp -R ./{templates,options} ${frontend}/public $data
|
2023-02-02 18:25:31 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cp -R ./options/locale $out/locale
|
|
|
|
wrapProgram $out/bin/gitea \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
2022-12-28 21:21:41 +00:00
|
|
|
'';
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
# $data is not available in go-modules.drv and preBuild isn't needed
|
|
|
|
overrideModAttrs = (_: {
|
|
|
|
postPatch = null;
|
|
|
|
preBuild = null;
|
|
|
|
});
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru = {
|
|
|
|
data-compressed = runCommand "forgejo-data-compressed" {
|
|
|
|
nativeBuildInputs = [ brotli xorg.lndir ];
|
|
|
|
} ''
|
|
|
|
mkdir $out
|
|
|
|
lndir ${forgejo.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 {} ';'
|
2023-02-09 11:40:11 +00:00
|
|
|
'';
|
2023-03-24 00:07:29 +00:00
|
|
|
|
|
|
|
tests = nixosTests.forgejo;
|
|
|
|
};
|
2023-02-09 11:40:11 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = {
|
2022-12-28 21:21:41 +00:00
|
|
|
description = "A self-hosted lightweight software forge";
|
|
|
|
homepage = "https://forgejo.org";
|
2023-07-15 17:15:38 +00:00
|
|
|
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/${src.rev}";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ emilylange urandom bendlas ];
|
2023-02-02 18:25:31 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2023-02-09 11:40:11 +00:00
|
|
|
mainProgram = "gitea";
|
2022-12-28 21:21:41 +00:00
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
}
|