mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
Merge pull request #331187 from emilylange/forgejo
forgejo: refactor to support multiple versions, 7.0.5 -> 8.0.0, forgejo-lts: init at 7.0.6
This commit is contained in:
commit
accd3aa082
@ -66,7 +66,7 @@ in
|
||||
services.forgejo = {
|
||||
enable = mkEnableOption "Forgejo, a software forge";
|
||||
|
||||
package = mkPackageOption pkgs "forgejo" { };
|
||||
package = mkPackageOption pkgs "forgejo-lts" { };
|
||||
|
||||
useWizard = mkOption {
|
||||
default = false;
|
||||
|
@ -342,7 +342,8 @@ in {
|
||||
fluentd = handleTest ./fluentd.nix {};
|
||||
fluidd = handleTest ./fluidd.nix {};
|
||||
fontconfig-default-fonts = handleTest ./fontconfig-default-fonts.nix {};
|
||||
forgejo = handleTest ./forgejo.nix { };
|
||||
forgejo = handleTest ./forgejo.nix { forgejoPackage = pkgs.forgejo; };
|
||||
forgejo-lts = handleTest ./forgejo.nix { forgejoPackage = pkgs.forgejo-lts; };
|
||||
freenet = handleTest ./freenet.nix {};
|
||||
freeswitch = handleTest ./freeswitch.nix {};
|
||||
freetube = discoverTests (import ./freetube.nix);
|
||||
|
@ -1,6 +1,7 @@
|
||||
{ system ? builtins.currentSystem
|
||||
, config ? { }
|
||||
, pkgs ? import ../.. { inherit system config; }
|
||||
, forgejoPackage ? pkgs.forgejo
|
||||
}:
|
||||
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
@ -53,6 +54,7 @@ let
|
||||
virtualisation.memorySize = 2047;
|
||||
services.forgejo = {
|
||||
enable = true;
|
||||
package = forgejoPackage;
|
||||
database = { inherit type; };
|
||||
settings.service.DISABLE_REGISTRATION = true;
|
||||
settings."repository.signing".SIGNING_KEY = signingPrivateKeyId;
|
||||
@ -145,7 +147,7 @@ let
|
||||
assert "BEGIN PGP PUBLIC KEY BLOCK" in server.succeed("curl http://localhost:3000/api/v1/signing-key.gpg")
|
||||
|
||||
api_version = json.loads(server.succeed("curl http://localhost:3000/api/forgejo/v1/version")).get("version")
|
||||
assert "development" != api_version and "${pkgs.forgejo.version}+gitea-" in api_version, (
|
||||
assert "development" != api_version and "${forgejoPackage.version}+gitea-" in api_version, (
|
||||
"/api/forgejo/v1/version should not return 'development' "
|
||||
+ f"but should contain a forgejo+gitea compatibility version string. Got '{api_version}' instead."
|
||||
)
|
||||
|
169
pkgs/by-name/fo/forgejo/generic.nix
Normal file
169
pkgs/by-name/fo/forgejo/generic.nix
Normal file
@ -0,0 +1,169 @@
|
||||
{ lts ? false
|
||||
, version
|
||||
, hash
|
||||
, npmDepsHash
|
||||
, vendorHash
|
||||
}:
|
||||
|
||||
{ bash
|
||||
, brotli
|
||||
, buildGoModule
|
||||
, forgejo
|
||||
, git
|
||||
, gzip
|
||||
, lib
|
||||
, makeWrapper
|
||||
, nix-update-script
|
||||
, nixosTests
|
||||
, openssh
|
||||
, pam
|
||||
, pamSupport ? true
|
||||
, sqliteSupport ? true
|
||||
, xorg
|
||||
, runCommand
|
||||
, stdenv
|
||||
, fetchFromGitea
|
||||
, buildNpmPackage
|
||||
}:
|
||||
|
||||
let
|
||||
src = fetchFromGitea {
|
||||
domain = "codeberg.org";
|
||||
owner = "forgejo";
|
||||
repo = "forgejo";
|
||||
rev = "v${version}";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
frontend = buildNpmPackage {
|
||||
pname = "forgejo-frontend";
|
||||
inherit src version npmDepsHash;
|
||||
|
||||
patches = [
|
||||
./package-json-npm-build-frontend.patch
|
||||
];
|
||||
|
||||
# override npmInstallHook
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -R ./public $out/
|
||||
'';
|
||||
};
|
||||
in
|
||||
buildGoModule rec {
|
||||
pname = "forgejo" + lib.optionalString lts "-lts";
|
||||
|
||||
inherit
|
||||
version
|
||||
src
|
||||
vendorHash
|
||||
;
|
||||
|
||||
subPackages = [ "." "contrib/environment-to-ini" ];
|
||||
|
||||
outputs = [ "out" "data" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = lib.optional pamSupport pam;
|
||||
|
||||
nativeCheckInputs = [
|
||||
git
|
||||
openssh
|
||||
];
|
||||
|
||||
patches = [
|
||||
./static-root-path.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace modules/setting/server.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}'"
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
export ldflags+=" -X main.ForgejoVersion=$(GITEA_VERSION=${version} make show-version-api)"
|
||||
'';
|
||||
|
||||
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
|
||||
"TestPamAuth" # we don't have PAM set up in the build sandbox
|
||||
"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}$" ];
|
||||
|
||||
postInstall = ''
|
||||
mkdir $data
|
||||
cp -R ./{templates,options} ${frontend}/public $data
|
||||
mkdir -p $out
|
||||
cp -R ./options/locale $out/locale
|
||||
wrapProgram $out/bin/gitea \
|
||||
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
||||
'';
|
||||
|
||||
# $data is not available in goModules.drv
|
||||
overrideModAttrs = (_: {
|
||||
postPatch = null;
|
||||
});
|
||||
|
||||
passthru = {
|
||||
# allow nix-update to handle npmDepsHash
|
||||
inherit (frontend) npmDeps;
|
||||
|
||||
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 {} ';'
|
||||
'';
|
||||
|
||||
tests = if lts then nixosTests.forgejo-lts else nixosTests.forgejo;
|
||||
updateScript = nix-update-script { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Self-hosted lightweight software forge";
|
||||
homepage = "https://forgejo.org";
|
||||
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/${src.rev}";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ emilylange urandom bendlas adamcstephens ];
|
||||
broken = stdenv.isDarwin;
|
||||
mainProgram = "gitea";
|
||||
};
|
||||
}
|
7
pkgs/by-name/fo/forgejo/lts.nix
Normal file
7
pkgs/by-name/fo/forgejo/lts.nix
Normal file
@ -0,0 +1,7 @@
|
||||
import ./generic.nix {
|
||||
version = "7.0.6";
|
||||
hash = "sha256-Y8H85HMKnzNSXnrLOxhzOBSfedivGvcQ3MOAp31Kvno=";
|
||||
npmDepsHash = "sha256-OqtYRjftwGxgW1JgMxyWd+9DndpEkd3LdQHSECc40yU=";
|
||||
vendorHash = "sha256-hfbNyCQMQzDzJxFc2MPAR4+v/qNcnORiQNbwbbIA4Nw=";
|
||||
lts = true;
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
diff --git a/package.json b/package.json
|
||||
index b50c52cf43..d6aafb8775 100644
|
||||
index 0abf6fe8b9..9d6ae0fdff 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -98,5 +98,8 @@
|
||||
},
|
||||
"browserslist": [
|
||||
"defaults"
|
||||
- ]
|
||||
+ ],
|
||||
@@ -1,4 +1,7 @@
|
||||
{
|
||||
+ "scripts": {
|
||||
+ "build": "node_modules/.bin/webpack"
|
||||
+ }
|
||||
}
|
||||
+ },
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">= 18.0.0"
|
||||
|
@ -1,157 +1,7 @@
|
||||
{ bash
|
||||
, brotli
|
||||
, buildGoModule
|
||||
, forgejo
|
||||
, git
|
||||
, gzip
|
||||
, lib
|
||||
, makeWrapper
|
||||
, nix-update-script
|
||||
, nixosTests
|
||||
, openssh
|
||||
, pam
|
||||
, pamSupport ? true
|
||||
, sqliteSupport ? true
|
||||
, xorg
|
||||
, runCommand
|
||||
, stdenv
|
||||
, fetchFromGitea
|
||||
, buildNpmPackage
|
||||
}:
|
||||
|
||||
let
|
||||
frontend = buildNpmPackage {
|
||||
pname = "forgejo-frontend";
|
||||
inherit (forgejo) src version;
|
||||
|
||||
npmDepsHash = "sha256-Nu9aOjJpEAuCWWnJfZXy/GayiUDiyc3hOu6Bx7GxfxA=";
|
||||
|
||||
patches = [
|
||||
./package-json-npm-build-frontend.patch
|
||||
];
|
||||
|
||||
# override npmInstallHook
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -R ./public $out/
|
||||
'';
|
||||
};
|
||||
in
|
||||
buildGoModule rec {
|
||||
pname = "forgejo";
|
||||
version = "7.0.5";
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "codeberg.org";
|
||||
owner = "forgejo";
|
||||
repo = "forgejo";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-Y/Ita5dr3COACffAIAjcqHHcdKiUWWEb/f/MPzMG200=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-hfbNyCQMQzDzJxFc2MPAR4+v/qNcnORiQNbwbbIA4Nw=";
|
||||
|
||||
subPackages = [ "." "contrib/environment-to-ini" ];
|
||||
|
||||
outputs = [ "out" "data" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
git # checkPhase
|
||||
openssh # checkPhase
|
||||
];
|
||||
buildInputs = lib.optional pamSupport pam;
|
||||
|
||||
patches = [
|
||||
./static-root-path.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace modules/setting/server.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}'"
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
export ldflags+=" -X main.ForgejoVersion=$(GITEA_VERSION=${version} make show-version-api)"
|
||||
'';
|
||||
|
||||
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
|
||||
"TestPamAuth" # we don't have PAM set up in the build sandbox
|
||||
"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}$" ];
|
||||
|
||||
postInstall = ''
|
||||
mkdir $data
|
||||
cp -R ./{templates,options} ${frontend}/public $data
|
||||
mkdir -p $out
|
||||
cp -R ./options/locale $out/locale
|
||||
wrapProgram $out/bin/gitea \
|
||||
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
||||
'';
|
||||
|
||||
# $data is not available in goModules.drv
|
||||
overrideModAttrs = (_: {
|
||||
postPatch = null;
|
||||
});
|
||||
|
||||
passthru = {
|
||||
# allow nix-update to handle npmDepsHash
|
||||
inherit (frontend) npmDeps;
|
||||
|
||||
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 {} ';'
|
||||
'';
|
||||
|
||||
tests = nixosTests.forgejo;
|
||||
updateScript = nix-update-script { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Self-hosted lightweight software forge";
|
||||
homepage = "https://forgejo.org";
|
||||
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/${src.rev}";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ emilylange urandom bendlas adamcstephens ];
|
||||
broken = stdenv.isDarwin;
|
||||
mainProgram = "gitea";
|
||||
};
|
||||
import ./generic.nix {
|
||||
version = "8.0.0";
|
||||
hash = "sha256-ol/2D+zMieERVDHOKlu+wm3WKkQNjbIw0sc0KLUTwzI=";
|
||||
npmDepsHash = "sha256-6AMaZadgcTvOBsIXJjZQB6Q1rkdn+R82pclXdVvtdWY=";
|
||||
vendorHash = "sha256-tNb0tCf+gjUmUqrjkzt7Wqqz21hW9WRh8CEdX8rv8Do=";
|
||||
lts = false;
|
||||
}
|
||||
|
@ -2189,6 +2189,8 @@ with pkgs;
|
||||
|
||||
diff-so-fancy = callPackage ../applications/version-management/diff-so-fancy { };
|
||||
|
||||
forgejo-lts = callPackage ../by-name/fo/forgejo/lts.nix { };
|
||||
|
||||
gex = callPackage ../applications/version-management/gex {
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user