gitea: build from source

+37 -14
+37 -14
pkgs/applications/version-management/gitea/default.nix
··· 1 1 { lib 2 2 , stdenv 3 3 , buildGoModule 4 - , fetchurl 4 + , fetchFromGitHub 5 5 , makeWrapper 6 6 , git 7 7 , bash ··· 16 16 , brotli 17 17 , xorg 18 18 , nixosTests 19 + , buildNpmPackage 19 20 }: 20 21 21 - buildGoModule rec { 22 + let 23 + frontend = buildNpmPackage { 24 + pname = "gitea-frontend"; 25 + inherit (gitea) src version; 26 + 27 + npmDepsHash = "sha256-gXBBiDIIS0aW6qK37HcF0AuJOliblinznRVXoo6DV1s="; 28 + 29 + # use webpack directly instead of 'make frontend' as the packages are already installed 30 + buildPhase = '' 31 + BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack 32 + ''; 33 + 34 + installPhase = '' 35 + mkdir -p $out 36 + cp -R public $out/ 37 + ''; 38 + }; 39 + in buildGoModule rec { 22 40 pname = "gitea"; 23 41 version = "1.22.0"; 24 42 25 - # not fetching directly from the git repo, because that lacks several vendor files for the web UI 26 - src = fetchurl { 27 - url = "https://dl.gitea.com/gitea/${version}/gitea-src-${version}.tar.gz"; 28 - hash = "sha256-bU4u/RsE12InXjJ2ZvIL31z9AzB7XULyV0+ytAYnyjg="; 43 + src = fetchFromGitHub { 44 + owner = "go-gitea"; 45 + repo = "gitea"; 46 + rev = "v${gitea.version}"; 47 + hash = "sha256-LdNEiPch2BZNYMOjE9yWsq78g6DolMjM5wUci3jXj30="; 29 48 }; 30 49 31 - vendorHash = null; 50 + vendorHash = "sha256-8VoJR4p2WnhG6nTFMzBlcrd/B6UwaOU3Q/rnDx9MtWc="; 51 + 52 + outputs = [ "out" "data" ]; 32 53 33 - patches = [ 34 - ./static-root-path.patch 35 - ]; 54 + patches = [ ./static-root-path.patch ]; 55 + 56 + # go-modules derivation doesn't provide $data 57 + # so we need to wait until it is built, and then 58 + # at that time we can then apply the substituteInPlace 59 + overrideModAttrs = _: { postPatch = null; }; 36 60 37 61 postPatch = '' 38 62 substituteInPlace modules/setting/server.go --subst-var data ··· 54 78 "-X 'main.Tags=${lib.concatStringsSep " " tags}'" 55 79 ]; 56 80 57 - outputs = [ "out" "data" ]; 58 - 59 81 postInstall = '' 60 82 mkdir $data 61 - cp -R ./{public,templates,options} $data 83 + ln -s ${frontend}/public $data/public 84 + cp -R ./{templates,options} $data 62 85 mkdir -p $out 63 86 cp -R ./options/locale $out/locale 64 87 ··· 84 107 85 108 meta = with lib; { 86 109 description = "Git with a cup of tea"; 87 - homepage = "https://gitea.io"; 110 + homepage = "https://about.gitea.com"; 88 111 license = licenses.mit; 89 112 maintainers = with maintainers; [ ma27 techknowlogick SuperSandro2000 ]; 90 113 broken = stdenv.isDarwin;