From 51824a08f3289f771594db0cf6b700392b2c0cf4 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:44:32 +0200 Subject: [PATCH 01/11] etlegacy: remove unused `runCommand` argument --- pkgs/games/etlegacy/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index deb10bf3842e..7c9863fcef97 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -5,7 +5,6 @@ writeScriptBin, fetchFromGitHub, fetchurl, - runCommand, cmake, git, glew, From 81f84d95e46f651b18c95106e8a623b38d479673 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:44:52 +0200 Subject: [PATCH 02/11] etlegacy: add `drupol` as maintainer --- pkgs/games/etlegacy/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 7c9863fcef97..94faf5d42e80 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -132,6 +132,6 @@ in platforms = ["i686-linux" "x86_64-linux"]; license = [licenses.gpl3 licenses.cc-by-nc-sa-30]; inherit mainProgram; - maintainers = with maintainers; [ashleyghooper]; + maintainers = with maintainers; [ashleyghooper drupol]; }; } From 918f740a6775fec57fdd5d27cde2e1303ed7bc9f Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:46:06 +0200 Subject: [PATCH 03/11] etlegacy: reduce amount of local vars --- pkgs/games/etlegacy/default.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 94faf5d42e80..33c92f026cd8 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -24,15 +24,14 @@ cjson, }: let version = "2.81.1"; - pkgname = "etlegacy"; - mirror = "https://mirror.etlegacy.com"; + fetchAsset = { asset, sha256, }: fetchurl { - url = mirror + "/etmain/" + asset; + url = "https://mirror.etlegacy.com/etmain/${asset}"; inherit sha256; }; pak0 = @@ -64,8 +63,8 @@ then "etl.i386" else "etl.x86_64"; in - stdenv.mkDerivation rec { - pname = pkgname; + stdenv.mkDerivation { + pname = "etlegacy"; inherit version; src = fetchFromGitHub { From 9a0d0c1b50196bf884467870362b0204c72140ea Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:49:20 +0200 Subject: [PATCH 04/11] etlegacy: refactor `fetchAsset` --- pkgs/games/etlegacy/default.nix | 47 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 33c92f026cd8..28eb6a7602a8 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -25,33 +25,26 @@ }: let version = "2.81.1"; - fetchAsset = { - asset, - sha256, - }: - fetchurl - { - url = "https://mirror.etlegacy.com/etmain/${asset}"; - inherit sha256; - }; - pak0 = - fetchAsset - { - asset = "pak0.pk3"; - sha256 = "712966b20e06523fe81419516500e499c86b2b4fec823856ddbd333fcb3d26e5"; - }; - pak1 = - fetchAsset - { - asset = "pak1.pk3"; - sha256 = "5610fd749024405b4425a7ce6397e58187b941d22092ef11d4844b427df53e5d"; - }; - pak2 = - fetchAsset - { - asset = "pak2.pk3"; - sha256 = "a48ab749a1a12ab4d9137286b1f23d642c29da59845b2bafc8f64e052cf06f3e"; - }; + fetchAsset = { asset, hash }: fetchurl { + url = "https://mirror.etlegacy.com/etmain/${asset}"; + inherit hash; + }; + + pak0 = fetchAsset { + asset = "pak0.pk3"; + hash = "sha256-cSlmsg4GUj/oFBlRZQDkmchrK0/sgjhW3b0zP8s9JuU="; + }; + + pak1 = fetchAsset { + asset = "pak1.pk3"; + hash = "sha256-VhD9dJAkQFtEJafOY5flgYe5QdIgku8R1IRLQn31Pl0="; + }; + + pak2 = fetchAsset { + asset = "pak2.pk3"; + hash = "sha256-pIq3SaGhKrTZE3KGsfI9ZCwp2lmEWyuvyPZOBSzwbz4="; + }; + fakeGit = writeScriptBin "git" '' #! ${stdenv.shell} -e if [ "$1" = "describe" ]; then From f07f9addb14c7c4dac2563faa4f74575e8514fde Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:52:03 +0200 Subject: [PATCH 05/11] etlegacy: build server and client --- pkgs/games/etlegacy/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 28eb6a7602a8..14b711947f10 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -95,7 +95,7 @@ in cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DCROSS_COMPILE32=0" - "-DBUILD_SERVER=0" + "-DBUILD_SERVER=1" "-DBUILD_CLIENT=1" "-DBUNDLED_JPEG=0" "-DBUNDLED_LIBS=0" @@ -116,6 +116,7 @@ in ln -s ${pak1} $ETMAIN/pak1.pk3 ln -s ${pak2} $ETMAIN/pak2.pk3 makeWrapper $out/${mainProgram} $out/bin/${mainProgram} --chdir $out + makeWrapper $out/etlded.* $out/bin/etlded --chdir $out ''; meta = with lib; { From 1461c8fdd3e89a7ebfd37cfadeb123c28285a76a Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:52:49 +0200 Subject: [PATCH 06/11] etlegacy: update `cmakeFlags` and change default install directories --- pkgs/games/etlegacy/default.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 14b711947f10..0b773dc162bc 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -104,19 +104,18 @@ in "-DINSTALL_GEOIP=0" "-DINSTALL_WOLFADMIN=0" "-DFEATURE_AUTOUPDATE=0" - "-DINSTALL_DEFAULT_BASEDIR=." - "-DINSTALL_DEFAULT_BINDIR=." - "-DINSTALL_DEFAULT_MODDIR=." + "-DINSTALL_DEFAULT_BASEDIR=${placeholder "out"}/lib/etlegacy" + "-DINSTALL_DEFAULT_BINDIR=${placeholder "out"}/bin" ]; postInstall = '' - ETMAIN=$out/etmain + ETMAIN=$out/lib/etlegacy/etmain mkdir -p $ETMAIN ln -s ${pak0} $ETMAIN/pak0.pk3 ln -s ${pak1} $ETMAIN/pak1.pk3 ln -s ${pak2} $ETMAIN/pak2.pk3 - makeWrapper $out/${mainProgram} $out/bin/${mainProgram} --chdir $out - makeWrapper $out/etlded.* $out/bin/etlded --chdir $out + makeWrapper $out/bin/etl.* $out/bin/etl + makeWrapper $out/bin/etlded.* $out/bin/etlded ''; meta = with lib; { From eab7a24373dcfbb1af49e4730a1dc40dd46df3b6 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 21:57:10 +0200 Subject: [PATCH 07/11] etlegacy: disable `fortify` to have fully working binaries --- pkgs/games/etlegacy/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 0b773dc162bc..d13ac5d52613 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -118,6 +118,8 @@ in makeWrapper $out/bin/etlded.* $out/bin/etlded ''; + hardeningDisable = [ "fortify" ]; + meta = with lib; { description = "ET: Legacy is an open source project based on the code of Wolfenstein: Enemy Territory which was released in 2010 under the terms of the GPLv3 license"; homepage = "https://etlegacy.com"; From 3c9d06797bfd1a19c4d52bab2808223d63d130b0 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sun, 20 Aug 2023 18:52:02 +0200 Subject: [PATCH 08/11] etlegacy: remove `mainprogram` attribute --- pkgs/games/etlegacy/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index d13ac5d52613..0ae4bb93c2f8 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -51,10 +51,6 @@ echo "${version}" fi ''; - mainProgram = - if stdenv.hostPlatform.system == "i686-linux" - then "etl.i386" - else "etl.x86_64"; in stdenv.mkDerivation { pname = "etlegacy"; @@ -125,7 +121,7 @@ in homepage = "https://etlegacy.com"; platforms = ["i686-linux" "x86_64-linux"]; license = [licenses.gpl3 licenses.cc-by-nc-sa-30]; - inherit mainProgram; + mainProgram = "etl"; maintainers = with maintainers; [ashleyghooper drupol]; }; } From d998c261ccb6abd400bcd837025e73fb45bda11f Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sun, 20 Aug 2023 23:42:49 +0200 Subject: [PATCH 09/11] etlegacy: replace `writeScriptBin` with `writeShellApplication` --- pkgs/games/etlegacy/default.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index 0ae4bb93c2f8..e3fea938d43b 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -2,7 +2,7 @@ stdenv, lib, makeWrapper, - writeScriptBin, + writeShellApplication, fetchFromGitHub, fetchurl, cmake, @@ -45,12 +45,15 @@ hash = "sha256-pIq3SaGhKrTZE3KGsfI9ZCwp2lmEWyuvyPZOBSzwbz4="; }; - fakeGit = writeScriptBin "git" '' - #! ${stdenv.shell} -e - if [ "$1" = "describe" ]; then - echo "${version}" - fi - ''; + fakeGit = writeShellApplication { + name = "git"; + + text = '' + if [ "$1" = "describe" ]; then + echo "${version}" + fi + ''; + }; in stdenv.mkDerivation { pname = "etlegacy"; From bc586df93d44ce2a672e2afb3ea60f67a62ddf39 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sun, 20 Aug 2023 23:43:18 +0200 Subject: [PATCH 10/11] etlegacy: add `meta.longDescription` --- pkgs/games/etlegacy/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index e3fea938d43b..cf22db9024d9 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -124,6 +124,11 @@ in homepage = "https://etlegacy.com"; platforms = ["i686-linux" "x86_64-linux"]; license = [licenses.gpl3 licenses.cc-by-nc-sa-30]; + longDescription = '' + ET: Legacy, an open source project fully compatible client and server + for the popular online FPS game Wolfenstein: Enemy Territory - whose + gameplay is still considered unmatched by many, despite its great age. + ''; mainProgram = "etl"; maintainers = with maintainers; [ashleyghooper drupol]; }; From 2836fd6fce609d0fb1b01a9cb75500750a6ea5f3 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 19 Aug 2023 22:30:28 +0200 Subject: [PATCH 11/11] etlegacy: reformat files --- pkgs/games/etlegacy/default.nix | 205 +++++++++++++++++--------------- 1 file changed, 106 insertions(+), 99 deletions(-) diff --git a/pkgs/games/etlegacy/default.nix b/pkgs/games/etlegacy/default.nix index cf22db9024d9..ee5d31874c68 100644 --- a/pkgs/games/etlegacy/default.nix +++ b/pkgs/games/etlegacy/default.nix @@ -1,28 +1,28 @@ -{ - stdenv, - lib, - makeWrapper, - writeShellApplication, - fetchFromGitHub, - fetchurl, - cmake, - git, - glew, - SDL2, - zlib, - minizip, - libjpeg, - curl, - lua, - libogg, - libtheora, - freetype, - libpng, - sqlite, - openal, - unzip, - cjson, -}: let +{ lib +, stdenv +, fetchurl +, writeShellApplication +, fetchFromGitHub +, cjson +, cmake +, git +, makeWrapper +, unzip +, curl +, freetype +, glew +, libjpeg +, libogg +, libpng +, libtheora +, lua +, minizip +, openal +, SDL2 +, sqlite +, zlib +}: +let version = "2.81.1"; fetchAsset = { asset, hash }: fetchurl { @@ -55,81 +55,88 @@ ''; }; in - stdenv.mkDerivation { - pname = "etlegacy"; - inherit version; +stdenv.mkDerivation { + pname = "etlegacy"; + inherit version; - src = fetchFromGitHub { - owner = "etlegacy"; - repo = "etlegacy"; - rev = "refs/tags/v" + version; - sha256 = "sha256-CGXtc51vaId/SHbD34ZeT0gPsrl7p2DEw/Kp+GBZIaA="; # 2.81.1 - }; + src = fetchFromGitHub { + owner = "etlegacy"; + repo = "etlegacy"; + rev = "refs/tags/v${version}"; + hash = "sha256-CGXtc51vaId/SHbD34ZeT0gPsrl7p2DEw/Kp+GBZIaA="; # 2.81.1 + }; - nativeBuildInputs = [cmake fakeGit git makeWrapper unzip cjson]; - buildInputs = [ - glew - SDL2 - zlib - minizip - libjpeg - curl - lua - libogg - libtheora - freetype - libpng - sqlite - openal - ]; + nativeBuildInputs = [ + cjson + cmake + fakeGit + git + makeWrapper + unzip + ]; - preBuild = '' - # Required for build time to not be in 1980 - export SOURCE_DATE_EPOCH=$(date +%s) - # This indicates the build was by a CI pipeline and prevents the resource - # files from being flagged as 'dirty' due to potentially being custom built. - export CI="true" + buildInputs = [ + curl + freetype + glew + libjpeg + libogg + libpng + libtheora + lua + minizip + openal + SDL2 + sqlite + zlib + ]; + + preBuild = '' + # Required for build time to not be in 1980 + export SOURCE_DATE_EPOCH=$(date +%s) + # This indicates the build was by a CI pipeline and prevents the resource + # files from being flagged as 'dirty' due to potentially being custom built. + export CI="true" + ''; + + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=Release" + "-DCROSS_COMPILE32=0" + "-DBUILD_SERVER=1" + "-DBUILD_CLIENT=1" + "-DBUNDLED_JPEG=0" + "-DBUNDLED_LIBS=0" + "-DINSTALL_EXTRA=0" + "-DINSTALL_OMNIBOT=0" + "-DINSTALL_GEOIP=0" + "-DINSTALL_WOLFADMIN=0" + "-DFEATURE_AUTOUPDATE=0" + "-DINSTALL_DEFAULT_BASEDIR=${placeholder "out"}/lib/etlegacy" + "-DINSTALL_DEFAULT_BINDIR=${placeholder "out"}/bin" + ]; + + postInstall = '' + ln -s ${pak0} $out/lib/etlegacy/etmain/pak0.pk3 + ln -s ${pak1} $out/lib/etlegacy/etmain/pak1.pk3 + ln -s ${pak2} $out/lib/etlegacy/etmain/pak2.pk3 + + makeWrapper $out/bin/etl.* $out/bin/etl + makeWrapper $out/bin/etlded.* $out/bin/etlded + ''; + + hardeningDisable = [ "fortify" ]; + + meta = { + description = "ET: Legacy is an open source project based on the code of Wolfenstein: Enemy Territory which was released in 2010 under the terms of the GPLv3 license"; + homepage = "https://etlegacy.com"; + license = with lib.licenses; [ gpl3 cc-by-nc-sa-30 ]; + longDescription = '' + ET: Legacy, an open source project fully compatible client and server + for the popular online FPS game Wolfenstein: Enemy Territory - whose + gameplay is still considered unmatched by many, despite its great age. ''; - - cmakeFlags = [ - "-DCMAKE_BUILD_TYPE=Release" - "-DCROSS_COMPILE32=0" - "-DBUILD_SERVER=1" - "-DBUILD_CLIENT=1" - "-DBUNDLED_JPEG=0" - "-DBUNDLED_LIBS=0" - "-DINSTALL_EXTRA=0" - "-DINSTALL_OMNIBOT=0" - "-DINSTALL_GEOIP=0" - "-DINSTALL_WOLFADMIN=0" - "-DFEATURE_AUTOUPDATE=0" - "-DINSTALL_DEFAULT_BASEDIR=${placeholder "out"}/lib/etlegacy" - "-DINSTALL_DEFAULT_BINDIR=${placeholder "out"}/bin" - ]; - - postInstall = '' - ETMAIN=$out/lib/etlegacy/etmain - mkdir -p $ETMAIN - ln -s ${pak0} $ETMAIN/pak0.pk3 - ln -s ${pak1} $ETMAIN/pak1.pk3 - ln -s ${pak2} $ETMAIN/pak2.pk3 - makeWrapper $out/bin/etl.* $out/bin/etl - makeWrapper $out/bin/etlded.* $out/bin/etlded - ''; - - hardeningDisable = [ "fortify" ]; - - meta = with lib; { - description = "ET: Legacy is an open source project based on the code of Wolfenstein: Enemy Territory which was released in 2010 under the terms of the GPLv3 license"; - homepage = "https://etlegacy.com"; - platforms = ["i686-linux" "x86_64-linux"]; - license = [licenses.gpl3 licenses.cc-by-nc-sa-30]; - longDescription = '' - ET: Legacy, an open source project fully compatible client and server - for the popular online FPS game Wolfenstein: Enemy Territory - whose - gameplay is still considered unmatched by many, despite its great age. - ''; - mainProgram = "etl"; - maintainers = with maintainers; [ashleyghooper drupol]; - }; - } + mainProgram = "etl"; + maintainers = with lib.maintainers; [ ashleyghooper drupol ]; + platforms = lib.platforms.linux; + }; +}