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-08-04 22:07:22 +00:00
|
|
|
, nix-update-script
|
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;
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
npmDepsHash = "sha256-nXQew6PR5z+FGzmD15WBclnOYxzNZxTmHypuzh5+7Ew=";
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
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";
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "1.21.4-0";
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "codeberg.org";
|
|
|
|
owner = "forgejo";
|
|
|
|
repo = "forgejo";
|
|
|
|
rev = "v${version}";
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-m5y9lg1XAyOWA9jyeieGhzgJ9FaNorS45GCJPwMftXI=";
|
2022-12-28 21:21:41 +00:00
|
|
|
};
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
vendorHash = "sha256-eL3wxoRjxpkv012SqqifNLN9IOez5TbfGfZRgEX0AEM=";
|
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-08-04 22:07:22 +00:00
|
|
|
# $data is not available in goModules.drv and preBuild isn't needed
|
2023-04-29 16:46:19 +00:00
|
|
|
overrideModAttrs = (_: {
|
|
|
|
postPatch = null;
|
|
|
|
preBuild = null;
|
|
|
|
});
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru = {
|
2023-08-04 22:07:22 +00:00
|
|
|
# allow nix-update to handle npmDepsHash
|
|
|
|
inherit (frontend) npmDeps;
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
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-08-04 22:07:22 +00:00
|
|
|
updateScript = nix-update-script { };
|
2023-03-24 00:07:29 +00:00
|
|
|
};
|
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;
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with lib.maintainers; [ emilylange urandom bendlas adamcstephens ];
|
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
|
|
|
}
|