2024-07-31 01:59:07 +00:00
|
|
|
{ lts ? false
|
|
|
|
, version
|
2024-10-06 12:20:23 +00:00
|
|
|
, rev ? "refs/tags/v${version}"
|
2024-07-31 01:59:07 +00:00
|
|
|
, hash
|
|
|
|
, npmDepsHash
|
|
|
|
, vendorHash
|
2024-08-09 16:12:44 +00:00
|
|
|
, nixUpdateExtraArgs ? [ ]
|
2024-07-31 01:59:07 +00:00
|
|
|
}:
|
|
|
|
|
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
|
|
|
, 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
|
2024-07-31 01:59:07 +00:00
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "codeberg.org";
|
|
|
|
owner = "forgejo";
|
|
|
|
repo = "forgejo";
|
2024-10-06 12:20:23 +00:00
|
|
|
inherit rev hash;
|
2024-07-31 01:59:07 +00:00
|
|
|
};
|
|
|
|
|
2023-07-05 21:58:48 +00:00
|
|
|
frontend = buildNpmPackage {
|
2023-04-19 06:04:46 +00:00
|
|
|
pname = "forgejo-frontend";
|
2024-07-31 01:59:07 +00:00
|
|
|
inherit src version npmDepsHash;
|
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 {
|
2024-07-31 01:59:07 +00:00
|
|
|
pname = "forgejo" + lib.optionalString lts "-lts";
|
2022-12-26 21:28:16 +00:00
|
|
|
|
2024-07-31 01:59:07 +00:00
|
|
|
inherit
|
|
|
|
version
|
|
|
|
src
|
|
|
|
vendorHash
|
|
|
|
;
|
2023-01-25 11:44:31 +00:00
|
|
|
|
2024-05-17 21:23:17 +00:00
|
|
|
subPackages = [ "." "contrib/environment-to-ini" ];
|
2023-01-25 11:44:31 +00:00
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
outputs = [ "out" "data" ];
|
|
|
|
|
2024-06-15 15:46:51 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
];
|
2024-07-31 00:18:00 +00:00
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
git
|
|
|
|
openssh
|
|
|
|
];
|
|
|
|
|
2023-01-01 13:14:13 +00:00
|
|
|
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
|
|
|
'';
|
|
|
|
|
2024-08-17 19:07:23 +00:00
|
|
|
tags = 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
|
|
|
'';
|
|
|
|
|
2024-06-15 15:46:51 +00:00
|
|
|
preCheck = ''
|
|
|
|
# $HOME is required for ~/.ssh/authorized_keys and such
|
|
|
|
export HOME="$TMPDIR/home"
|
|
|
|
|
|
|
|
# expose and use the GO_TEST_PACKAGES var from the Makefile
|
|
|
|
# instead of manually copying over the entire list:
|
|
|
|
# https://codeberg.org/forgejo/forgejo/src/tag/v7.0.4/Makefile#L124
|
|
|
|
echo -e 'show-backend-tests:\n\t@echo ''${GO_TEST_PACKAGES}' >> Makefile
|
|
|
|
getGoDirs() {
|
|
|
|
make show-backend-tests
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkFlags =
|
|
|
|
let
|
|
|
|
skippedTests = [
|
|
|
|
"Test_SSHParsePublicKey/dsa-1024/SSHKeygen" # dsa-1024 is deprecated in openssh and requires opting-in at compile time
|
|
|
|
"Test_calcFingerprint/dsa-1024/SSHKeygen" # dsa-1024 is deprecated in openssh and requires opting-in at compile time
|
|
|
|
"TestPassword" # requires network: api.pwnedpasswords.com
|
|
|
|
"TestCaptcha" # requires network: hcaptcha.com
|
|
|
|
"TestDNSUpdate" # requires network: release.forgejo.org
|
|
|
|
"TestMigrateWhiteBlocklist" # requires network: gitlab.com (DNS)
|
|
|
|
];
|
|
|
|
in
|
|
|
|
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
|
|
|
|
|
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
|
|
|
|
2024-07-31 01:59:13 +00:00
|
|
|
tests = if lts then nixosTests.forgejo-lts else nixosTests.forgejo;
|
2024-11-16 22:39:32 +00:00
|
|
|
|
|
|
|
updateScript = nix-update-script {
|
|
|
|
extraArgs = nixUpdateExtraArgs ++ [
|
|
|
|
"--version-regex"
|
|
|
|
"v(${lib.versions.major version}\.[0-9.]+)"
|
|
|
|
];
|
|
|
|
};
|
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 = "Self-hosted lightweight software forge";
|
|
|
|
homepage = "https://forgejo.org";
|
2024-11-01 21:59:25 +00:00
|
|
|
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/v${version}";
|
2024-10-06 12:20:23 +00:00
|
|
|
license = if lib.versionAtLeast version "9.0.0" then lib.licenses.gpl3Plus else lib.licenses.mit;
|
2024-10-06 12:38:52 +00:00
|
|
|
maintainers = with lib.maintainers; [ emilylange urandom bendlas adamcstephens marie ];
|
2023-01-01 13:14:13 +00:00
|
|
|
broken = stdenv.hostPlatform.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
|
|
|
}
|