2023-02-06 01:00:30 +00:00
|
|
|
{ bash
|
2023-03-02 17:41:59 +00:00
|
|
|
, brotli
|
2023-01-25 11:44:31 +00:00
|
|
|
, buildGoModule
|
2023-03-02 17:41:59 +00:00
|
|
|
, forgejo
|
2023-01-01 13:14:13 +00:00
|
|
|
, git
|
2023-01-25 11:44:31 +00:00
|
|
|
, gzip
|
2023-02-06 01:00:30 +00:00
|
|
|
, lib
|
|
|
|
, makeWrapper
|
2023-07-30 17:34:42 +00:00
|
|
|
, nix-update-script
|
2023-02-24 01:59:30 +00:00
|
|
|
, nixosTests
|
2023-02-06 01:00:30 +00:00
|
|
|
, openssh
|
2023-01-01 13:14:13 +00:00
|
|
|
, pam
|
|
|
|
, pamSupport ? true
|
|
|
|
, sqliteSupport ? true
|
2023-03-02 17:41:59 +00:00
|
|
|
, xorg
|
|
|
|
, runCommand
|
2023-02-06 01:00:30 +00:00
|
|
|
, stdenv
|
2023-04-19 06:04:46 +00:00
|
|
|
, fetchFromGitea
|
|
|
|
, buildNpmPackage
|
2023-01-01 13:14:13 +00:00
|
|
|
}:
|
2022-12-26 21:28:16 +00:00
|
|
|
|
2023-04-19 06:04:46 +00:00
|
|
|
let
|
2023-07-05 21:58:48 +00:00
|
|
|
frontend = buildNpmPackage {
|
2023-04-19 06:04:46 +00:00
|
|
|
pname = "forgejo-frontend";
|
|
|
|
inherit (forgejo) src version;
|
|
|
|
|
2024-05-22 18:22:07 +00:00
|
|
|
npmDepsHash = "sha256-Nu9aOjJpEAuCWWnJfZXy/GayiUDiyc3hOu6Bx7GxfxA=";
|
2023-04-19 06:04:46 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./package-json-npm-build-frontend.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
# override npmInstallHook
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp -R ./public $out/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2023-01-25 11:44:31 +00:00
|
|
|
buildGoModule rec {
|
2022-12-26 21:28:16 +00:00
|
|
|
pname = "forgejo";
|
2024-05-22 18:22:07 +00:00
|
|
|
version = "7.0.3";
|
2022-12-26 21:28:16 +00:00
|
|
|
|
2023-04-19 06:04:46 +00:00
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "codeberg.org";
|
|
|
|
owner = "forgejo";
|
|
|
|
repo = "forgejo";
|
|
|
|
rev = "v${version}";
|
2024-05-22 18:22:07 +00:00
|
|
|
hash = "sha256-P+HVZmfNA1ao+fQ253tK8A2DNGNPxvdyzCvByQJ0FGA=";
|
2022-12-26 21:28:16 +00:00
|
|
|
};
|
|
|
|
|
2024-05-22 18:22:07 +00:00
|
|
|
vendorHash = "sha256-8qMpnGL5GXJuxOpxh9a1Bcxd7tVweUKwbun8UBxCfQA=";
|
2023-01-25 11:44:31 +00:00
|
|
|
|
|
|
|
subPackages = [ "." ];
|
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
outputs = [ "out" "data" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = lib.optional pamSupport pam;
|
|
|
|
|
|
|
|
patches = [
|
2024-03-28 19:10:53 +00:00
|
|
|
./static-root-path.patch
|
2023-01-01 13:14:13 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2024-03-28 19:10:53 +00:00
|
|
|
substituteInPlace modules/setting/server.go --subst-var data
|
2022-12-26 21:28:16 +00:00
|
|
|
'';
|
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
tags = lib.optional pamSupport "pam"
|
|
|
|
++ lib.optionals sqliteSupport [ "sqlite" "sqlite_unlock_notify" ];
|
2023-01-25 11:44:31 +00:00
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
ldflags = [
|
2023-01-25 11:44:31 +00:00
|
|
|
"-s"
|
|
|
|
"-w"
|
2023-01-01 13:14:13 +00:00
|
|
|
"-X main.Version=${version}"
|
|
|
|
"-X 'main.Tags=${lib.concatStringsSep " " tags}'"
|
|
|
|
];
|
|
|
|
|
2024-04-02 15:04:16 +00:00
|
|
|
preConfigure = ''
|
2024-04-23 22:35:34 +00:00
|
|
|
export ldflags+=" -X main.ForgejoVersion=$(GITEA_VERSION=${version} make show-version-api)"
|
2024-04-02 15:04:16 +00:00
|
|
|
'';
|
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir $data
|
2023-04-19 06:04:46 +00:00
|
|
|
cp -R ./{templates,options} ${frontend}/public $data
|
2023-01-01 13:14:13 +00:00
|
|
|
mkdir -p $out
|
2023-01-25 11:44:31 +00:00
|
|
|
cp -R ./options/locale $out/locale
|
2023-01-01 13:14:13 +00:00
|
|
|
wrapProgram $out/bin/gitea \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
|
|
|
'';
|
|
|
|
|
2024-05-20 20:19:00 +00:00
|
|
|
# $data is not available in goModules.drv
|
2023-04-19 06:04:46 +00:00
|
|
|
overrideModAttrs = (_: {
|
|
|
|
postPatch = null;
|
|
|
|
});
|
|
|
|
|
2023-03-02 17:41:59 +00:00
|
|
|
passthru = {
|
2023-07-30 17:34:42 +00:00
|
|
|
# allow nix-update to handle npmDepsHash
|
|
|
|
inherit (frontend) npmDeps;
|
|
|
|
|
2023-03-20 19:49:01 +00:00
|
|
|
data-compressed = runCommand "forgejo-data-compressed" {
|
2023-03-02 17:41:59 +00:00
|
|
|
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-06 01:00:30 +00:00
|
|
|
'';
|
2023-03-02 17:41:59 +00:00
|
|
|
|
|
|
|
tests = nixosTests.forgejo;
|
2023-07-30 17:34:42 +00:00
|
|
|
updateScript = nix-update-script { };
|
2023-03-02 17:41:59 +00:00
|
|
|
};
|
2023-02-06 01:00:30 +00:00
|
|
|
|
2023-07-05 21:58:48 +00:00
|
|
|
meta = {
|
2022-12-26 21:28:16 +00:00
|
|
|
description = "A self-hosted lightweight software forge";
|
|
|
|
homepage = "https://forgejo.org";
|
2023-07-05 21:58:48 +00:00
|
|
|
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/${src.rev}";
|
|
|
|
license = lib.licenses.mit;
|
2023-07-30 16:00:43 +00:00
|
|
|
maintainers = with lib.maintainers; [ emilylange urandom bendlas adamcstephens ];
|
2023-01-01 13:14:13 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2023-02-06 01:00:30 +00:00
|
|
|
mainProgram = "gitea";
|
2022-12-26 21:28:16 +00:00
|
|
|
};
|
2023-01-01 13:14:13 +00:00
|
|
|
}
|