about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2024-04-26 13:59:54 -0300
committerAnderson Torres <torres.anderson.85@protonmail.com>2024-05-01 15:41:00 -0300
commita13158505e39fc3622f7a4ed07fafcfb0f49d220 (patch)
tree3f94b6543af7330e121e86885c0bff8bad1b6ea8
parent922be032e50087a60bf6b878c196ef692d62ff0d (diff)
SDL2_net: refactor
- finalAttrs
- use fetchFromGitHub (since the url is deactivated)
- strictDeps
- no nested with
-rw-r--r--pkgs/by-name/sd/SDL2_net/package.nix54
1 files changed, 37 insertions, 17 deletions
diff --git a/pkgs/by-name/sd/SDL2_net/package.nix b/pkgs/by-name/sd/SDL2_net/package.nix
index 83840a4eada64..79e0e0098623d 100644
--- a/pkgs/by-name/sd/SDL2_net/package.nix
+++ b/pkgs/by-name/sd/SDL2_net/package.nix
@@ -1,30 +1,50 @@
-{ lib, stdenv, pkg-config, darwin, fetchurl, SDL2 }:
-
-stdenv.mkDerivation rec {
+{
+  lib,
+  SDL2,
+  darwin,
+  fetchFromGitHub,
+  pkg-config,
+  stdenv,
+  # Boolean flags
+  enableSdltest ? (!stdenv.isDarwin),
+}:
+
+stdenv.mkDerivation (finalAttrs: {
   pname = "SDL2_net";
   version = "2.2.0";
 
-  src = fetchurl {
-    url = "https://www.libsdl.org/projects/SDL_net/release/${pname}-${version}.tar.gz";
-    sha256 = "sha256-TkqJGYgxYnGXT/TpWF7R73KaEj0iwIvUcxKRedyFf+s=";
+  src = fetchFromGitHub {
+    owner = "libsdl-org";
+    repo = "SDL_net";
+    rev = "release-${finalAttrs.version}";
+    hash = "sha256-sEcKn/apA6FcR7ijb7sfuvP03ZdVfjkNZTXsasK8fAI=";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkg-config ];
-
-  buildInputs = lib.optional stdenv.isDarwin darwin.libobjc;
+  nativeBuildInputs = [
+    SDL2
+    pkg-config
+  ];
 
-  configureFlags = [ "--disable-examples" ]
-  ++ lib.optional stdenv.isDarwin "--disable-sdltest";
+  buildInputs = lib.optionals stdenv.isDarwin [
+    darwin.libobjc
+  ];
 
   propagatedBuildInputs = [ SDL2 ];
 
-  meta = with lib; {
+  configureFlags = [
+    (lib.enableFeature false "examples") # can't find libSDL2_test.a
+    (lib.enableFeature enableSdltest "sdltest")
+  ];
+
+  strictDeps = true;
+
+  meta = {
+    homepage = "https://github.com/libsdl-org/SDL_net";
     description = "SDL multiplatform networking library";
-    homepage = "https://www.libsdl.org/projects/SDL_net";
-    license = licenses.zlib;
-    maintainers = with maintainers; [ AndersonTorres ];
-    platforms = platforms.unix;
+    license = lib.licenses.zlib;
+    maintainers = with lib.maintainers; [ AndersonTorres ];
+    inherit (SDL2.meta) platforms;
   };
-}
+})