From 5fe7a12b74042da1930c197611512a77d66765fa Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 5 Jul 2024 13:21:18 +0200 Subject: [PATCH] forgejo: unbundle, use from nixos-unstable-small this is almost a revert of 147fe172d93333b14816aa9cd6b307dc0d146cf6, but we now use the forgejo package of nixos-unstable-small instead of that from stable nixos. we were never noticably faster than forgejo maintainance upstream (turns out that unlike mattermost, some services actually get updated in time); no update was ever more than just copying the latest upstream package recipe. As a side-effect, this also updates forgejo to 7.0.5, which is a security release: https://codeberg.org/forgejo/forgejo/src/branch/forgejo/RELEASE-NOTES.md#7-0-5 --- pkgs/default.nix | 4 +- pkgs/forgejo/default.nix | 126 ------------------ .../package-json-npm-build-frontend.patch | 14 -- pkgs/forgejo/static-root-path.patch | 13 -- 4 files changed, 1 insertion(+), 156 deletions(-) delete mode 100644 pkgs/forgejo/default.nix delete mode 100644 pkgs/forgejo/package-json-npm-build-frontend.patch delete mode 100644 pkgs/forgejo/static-root-path.patch diff --git a/pkgs/default.nix b/pkgs/default.nix index d006442..e1e6bc4 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -17,9 +17,7 @@ let buildGoModule = unstable.buildGo122Module; }; - forgejo = callPackage ./forgejo { - buildGoModule = unstable.buildGo122Module; - }; + forgejo = unstable.forgejo; tracktrain = import sources.tracktrain { nixpkgs = unstable; diff --git a/pkgs/forgejo/default.nix b/pkgs/forgejo/default.nix deleted file mode 100644 index 94e3dc8..0000000 --- a/pkgs/forgejo/default.nix +++ /dev/null @@ -1,126 +0,0 @@ -{ 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.4"; - - src = fetchFromGitea { - domain = "codeberg.org"; - owner = "forgejo"; - repo = "forgejo"; - rev = "v${version}"; - hash = "sha256-WtJJdqPbx5k9U+u3ZpI3q/dm3eidxdkFgc8IskaJg88="; - }; - - vendorHash = "sha256-TYVWou9fIVL4od2o1uOb/MRBpf2lIg/9Tem9w+ihYzU="; - - subPackages = [ "." "contrib/environment-to-ini" ]; - - outputs = [ "out" "data" ]; - - nativeBuildInputs = [ makeWrapper ]; - 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)" - ''; - - 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"; - }; -} diff --git a/pkgs/forgejo/package-json-npm-build-frontend.patch b/pkgs/forgejo/package-json-npm-build-frontend.patch deleted file mode 100644 index f7567da..0000000 --- a/pkgs/forgejo/package-json-npm-build-frontend.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/package.json b/package.json -index b50c52cf43..d6aafb8775 100644 ---- a/package.json -+++ b/package.json -@@ -98,5 +98,8 @@ - }, - "browserslist": [ - "defaults" -- ] -+ ], -+ "scripts": { -+ "build": "node_modules/.bin/webpack" -+ } - } diff --git a/pkgs/forgejo/static-root-path.patch b/pkgs/forgejo/static-root-path.patch deleted file mode 100644 index 598c3a8..0000000 --- a/pkgs/forgejo/static-root-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/modules/setting/server.go b/modules/setting/server.go -index c20dd1949d..c9bcdce99a 100644 ---- a/modules/setting/server.go -+++ b/modules/setting/server.go -@@ -317,7 +317,7 @@ func loadServerFrom(rootCfg ConfigProvider) { - RedirectorUseProxyProtocol = sec.Key("REDIRECTOR_USE_PROXY_PROTOCOL").MustBool(UseProxyProtocol) - OfflineMode = sec.Key("OFFLINE_MODE").MustBool(true) - if len(StaticRootPath) == 0 { -- StaticRootPath = AppWorkPath -+ StaticRootPath = "@data@" - } - StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath) - StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)