libretro.mkLibretroCore: switch to lib.extendMkDerivation

+74 -77
+1 -1
pkgs/applications/emulators/libretro/default.nix
··· 4 4 }: 5 5 6 6 lib.makeScope newScope (self: { 7 - mkLibretroCore = self.callPackage ./mkLibretroCore.nix; 7 + mkLibretroCore = self.callPackage ./mkLibretroCore.nix { }; 8 8 9 9 atari800 = self.callPackage ./cores/atari800.nix { }; 10 10
+73 -76
pkgs/applications/emulators/libretro/mkLibretroCore.nix
··· 6 6 retroarch-bare, 7 7 unstableGitUpdater, 8 8 zlib, 9 - # Params 10 - core, 11 - makefile ? "Makefile.libretro", 12 - extraBuildInputs ? [ ], 13 - extraNativeBuildInputs ? [ ], 14 - ## Location of resulting RetroArch core on $out 15 - libretroCore ? "/lib/retroarch/cores", 16 - ## The core filename is derived from the core name 17 - ## Setting `normalizeCore` to `true` will convert `-` to `_` on the core filename 18 - normalizeCore ? true, 19 - ... 20 - }@args: 9 + }: 21 10 22 - let 23 - d2u = if normalizeCore then (lib.replaceStrings [ "-" ] [ "_" ]) else (x: x); 24 - coreDir = placeholder "out" + libretroCore; 25 - coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}"; 26 - mainProgram = "retroarch-${core}"; 27 - extraArgs = builtins.removeAttrs args [ 28 - "lib" 29 - "stdenv" 30 - "makeWrapper" 31 - "retroarch-bare" 32 - "unstableGitUpdater" 33 - "zlib" 11 + lib.extendMkDerivation { 12 + constructDrv = stdenv.mkDerivation; 34 13 14 + excludeDrvArgNames = [ 35 15 "core" 36 16 "extraBuildInputs" 37 17 "extraNativeBuildInputs" 38 18 "libretroCore" 39 - "makefile" 40 19 "normalizeCore" 41 - "passthru" 42 - "meta" 43 20 ]; 44 - in 45 - stdenv.mkDerivation ( 46 - { 47 - pname = "libretro-${core}"; 48 21 49 - buildInputs = [ zlib ] ++ extraBuildInputs; 50 - nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs; 22 + extendDrvArgs = 23 + finalAttrs: 24 + { 25 + core, 26 + enableParallelBuilding ? true, 27 + extraBuildInputs ? [ ], 28 + extraNativeBuildInputs ? [ ], 29 + makeFlags ? [ ], 30 + makefile ? "Makefile.libretro", 31 + meta ? { }, 32 + passthru ? { }, 33 + strictDeps ? true, 34 + ## Location of resulting RetroArch core on $out 35 + libretroCore ? "/lib/retroarch/cores", 36 + ## The core filename is derived from the core name 37 + ## Setting `normalizeCore` to `true` will convert `-` to `_` on the core filename 38 + normalizeCore ? true, 39 + ... 40 + }: 41 + let 42 + d2u = if normalizeCore then (lib.replaceStrings [ "-" ] [ "_" ]) else (x: x); 43 + coreDir = placeholder "out" + libretroCore; 44 + coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}"; 45 + mainProgram = "retroarch-${core}"; 46 + in 47 + { 48 + pname = "libretro-${core}"; 51 49 52 - inherit makefile; 50 + buildInputs = [ zlib ] ++ extraBuildInputs; 51 + nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs; 53 52 54 - makeFlags = [ 55 - "platform=${ 56 - { 57 - linux = "unix"; 58 - darwin = "osx"; 59 - windows = "win"; 60 - } 61 - .${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name 62 - }" 63 - "ARCH=${ 64 - { 65 - armv7l = "arm"; 66 - armv6l = "arm"; 67 - aarch64 = "arm64"; 68 - i686 = "x86"; 69 - } 70 - .${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name 71 - }" 72 - ] ++ (args.makeFlags or [ ]); 53 + inherit enableParallelBuilding makefile strictDeps; 73 54 74 - installPhase = '' 75 - runHook preInstall 55 + makeFlags = [ 56 + "platform=${ 57 + { 58 + linux = "unix"; 59 + darwin = "osx"; 60 + windows = "win"; 61 + } 62 + .${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name 63 + }" 64 + "ARCH=${ 65 + { 66 + armv7l = "arm"; 67 + armv6l = "arm"; 68 + aarch64 = "arm64"; 69 + i686 = "x86"; 70 + } 71 + .${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name 72 + }" 73 + ] ++ makeFlags; 76 74 77 - install -Dt ${coreDir} ${coreFilename} 78 - makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \ 79 - --add-flags "-L ${coreDir}/${coreFilename}" 75 + installPhase = '' 76 + runHook preInstall 80 77 81 - runHook postInstall 82 - ''; 78 + install -Dt ${coreDir} ${coreFilename} 79 + makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \ 80 + --add-flags "-L ${coreDir}/${coreFilename}" 83 81 84 - enableParallelBuilding = true; 82 + runHook postInstall 83 + ''; 85 84 86 - passthru = { 87 - inherit core libretroCore; 88 - # libretro repos sometimes has a fake tag like "Current", ignore 89 - # it by setting hardcodeZeroVersion 90 - updateScript = unstableGitUpdater { hardcodeZeroVersion = true; }; 91 - } // (args.passthru or { }); 85 + passthru = { 86 + inherit core libretroCore; 87 + # libretro repos sometimes has a fake tag like "Current", ignore 88 + # it by setting hardcodeZeroVersion 89 + updateScript = unstableGitUpdater { hardcodeZeroVersion = true; }; 90 + } // passthru; 92 91 93 - meta = { 94 - inherit mainProgram; 95 - inherit (retroarch-bare.meta) platforms; 96 - homepage = "https://www.libretro.com/"; 97 - teams = [ lib.teams.libretro ]; 98 - } // (args.meta or { }); 99 - } 100 - // extraArgs 101 - ) 92 + meta = { 93 + inherit mainProgram; 94 + inherit (retroarch-bare.meta) platforms; 95 + teams = [ lib.teams.libretro ]; 96 + } // meta; 97 + }; 98 + }