From 136dcc5f93936a795854bd9ddcbdb5e55f3708e6 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 18 Jul 2025 21:12:51 +0200 Subject: [PATCH 1/3] gams: move assert behind meta.license check This now errors with the "allow unfree" error first - and only when that's passed it asserts the specific `licenseFile` option. This ensures that CI will not produce an eval warning for the assert once we turn that on. --- pkgs/tools/misc/gams/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/tools/misc/gams/default.nix b/pkgs/tools/misc/gams/default.nix index c69f98a9ca23..d27d3ddacd9d 100644 --- a/pkgs/tools/misc/gams/default.nix +++ b/pkgs/tools/misc/gams/default.nix @@ -8,8 +8,6 @@ optgamsFile ? null, }: -assert licenseFile != null; - stdenv.mkDerivation rec { version = "25.0.2"; pname = "gams"; @@ -23,6 +21,7 @@ stdenv.mkDerivation rec { dontBuild = true; installPhase = + assert licenseFile != null; '' mkdir -p "$out/bin" "$out/share/gams" cp -a * "$out/share/gams" From ccd127bc7ce5f5691d395b050d271b72e4b891d3 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 18 Jul 2025 21:20:26 +0200 Subject: [PATCH 2/3] sc2-headless: move throw behind meta.license check Same reasoning as commit before. --- .../machine-learning/sc2-headless/default.nix | 123 +++++++++--------- .../machine-learning/sc2-headless/maps.nix | 17 ++- 2 files changed, 75 insertions(+), 65 deletions(-) diff --git a/pkgs/applications/science/machine-learning/sc2-headless/default.nix b/pkgs/applications/science/machine-learning/sc2-headless/default.nix index 0700580b9598..cd067cec8e26 100644 --- a/pkgs/applications/science/machine-learning/sc2-headless/default.nix +++ b/pkgs/applications/science/machine-learning/sc2-headless/default.nix @@ -8,66 +8,67 @@ licenseAccepted ? config.sc2-headless.accept_license or false, }: -if !licenseAccepted then - throw '' - You must accept the Blizzard® Starcraft® II AI and Machine Learning License at - https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html - by setting nixpkgs config option 'sc2-headless.accept_license = true;' - '' -else - assert licenseAccepted; - let - maps = callPackage ./maps.nix { }; - in - stdenv.mkDerivation rec { - version = "4.7.1"; - pname = "sc2-headless"; +let + maps = callPackage ./maps.nix { inherit licenseAccepted; }; +in +stdenv.mkDerivation rec { + version = "4.7.1"; + pname = "sc2-headless"; - src = fetchurl { - url = "https://blzdistsc2-a.akamaihd.net/Linux/SC2.${version}.zip"; - sha256 = "0q1ry9bd3dm8y4hvh57yfq7s05hl2k2sxi2wsl6h0r3w690v1kdd"; + src = fetchurl { + url = "https://blzdistsc2-a.akamaihd.net/Linux/SC2.${version}.zip"; + sha256 = "0q1ry9bd3dm8y4hvh57yfq7s05hl2k2sxi2wsl6h0r3w690v1kdd"; + }; + + unpackCmd = + if !licenseAccepted then + throw '' + You must accept the Blizzard® Starcraft® II AI and Machine Learning License at + https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html + by setting nixpkgs config option 'sc2-headless.accept_license = true;' + '' + else + assert licenseAccepted; + '' + unzip -P 'iagreetotheeula' $curSrc + ''; + + nativeBuildInputs = [ unzip ]; + + installPhase = '' + mkdir -p $out + cp -r . "$out" + rm -r $out/Libs + + cp -ur "${maps.minigames}"/* "${maps.melee}"/* "${maps.ladder2017season1}"/* "${maps.ladder2017season2}"/* "${maps.ladder2017season3}"/* \ + "${maps.ladder2017season4}"/* "${maps.ladder2018season1}"/* "${maps.ladder2018season2}"/* \ + "${maps.ladder2018season3}"/* "${maps.ladder2018season4}"/* "${maps.ladder2019season1}"/* "$out"/Maps/ + ''; + + preFixup = '' + find $out -type f -print0 | while IFS=''' read -d ''' -r file; do + isELF "$file" || continue + patchelf \ + --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath ${ + lib.makeLibraryPath [ + stdenv.cc.cc + stdenv.cc.libc + ] + } \ + "$file" + done + ''; + + meta = { + platforms = lib.platforms.linux; + description = "Starcraft II headless linux client for machine learning research"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = { + fullName = "BLIZZARD® STARCRAFT® II AI AND MACHINE LEARNING LICENSE"; + url = "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"; + free = false; }; - - unpackCmd = '' - unzip -P 'iagreetotheeula' $curSrc - ''; - - nativeBuildInputs = [ unzip ]; - - installPhase = '' - mkdir -p $out - cp -r . "$out" - rm -r $out/Libs - - cp -ur "${maps.minigames}"/* "${maps.melee}"/* "${maps.ladder2017season1}"/* "${maps.ladder2017season2}"/* "${maps.ladder2017season3}"/* \ - "${maps.ladder2017season4}"/* "${maps.ladder2018season1}"/* "${maps.ladder2018season2}"/* \ - "${maps.ladder2018season3}"/* "${maps.ladder2018season4}"/* "${maps.ladder2019season1}"/* "$out"/Maps/ - ''; - - preFixup = '' - find $out -type f -print0 | while IFS=''' read -d ''' -r file; do - isELF "$file" || continue - patchelf \ - --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ - --set-rpath ${ - lib.makeLibraryPath [ - stdenv.cc.cc - stdenv.cc.libc - ] - } \ - "$file" - done - ''; - - meta = { - platforms = lib.platforms.linux; - description = "Starcraft II headless linux client for machine learning research"; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - license = { - fullName = "BLIZZARD® STARCRAFT® II AI AND MACHINE LEARNING LICENSE"; - url = "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html"; - free = false; - }; - maintainers = [ ]; - }; - } + maintainers = [ ]; + }; +} diff --git a/pkgs/applications/science/machine-learning/sc2-headless/maps.nix b/pkgs/applications/science/machine-learning/sc2-headless/maps.nix index 19019408a18d..2552397c5fdd 100644 --- a/pkgs/applications/science/machine-learning/sc2-headless/maps.nix +++ b/pkgs/applications/science/machine-learning/sc2-headless/maps.nix @@ -1,12 +1,21 @@ { fetchzip, + licenseAccepted, }: let fetchzip' = - args: - (fetchzip args).overrideAttrs (old: { - UNZIP = "-j -P iagreetotheeula"; - }); + if !licenseAccepted then + throw '' + You must accept the Blizzard® Starcraft® II AI and Machine Learning License at + https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html + by setting nixpkgs config option 'sc2-headless.accept_license = true;' + '' + else + assert licenseAccepted; + args: + (fetchzip args).overrideAttrs (old: { + UNZIP = "-j -P iagreetotheeula"; + }); in { minigames = fetchzip { From b2b3b4b7681d7d8736c11fa031cb707c8af61720 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 19 Jul 2025 10:41:28 +0200 Subject: [PATCH 3/3] androidsdk: move throw behind meta.license check This allows evaluating the package's meta attribute without triggering the throw, thus making it possible to list the package in the search results. It also avoids CI falling over with this attribute. --- .../androidenv/compose-android-packages.nix | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/pkgs/development/mobile/androidenv/compose-android-packages.nix b/pkgs/development/mobile/androidenv/compose-android-packages.nix index 1803a04a6638..44259a2f2e48 100644 --- a/pkgs/development/mobile/androidenv/compose-android-packages.nix +++ b/pkgs/development/mobile/androidenv/compose-android-packages.nix @@ -631,32 +631,32 @@ lib.recurseIntoAttrs rec { # This derivation deploys the tools package and symlinks all the desired # plugins that we want to use. If the license isn't accepted, prints all the licenses # requested and throws. - androidsdk = - if !licenseAccepted then - throw '' - ${builtins.concatStringsSep "\n\n" (mkLicenseTexts licenseNames)} + androidsdk = callPackage ./cmdline-tools.nix { + inherit + deployAndroidPackage + os + arch + meta + ; - You must accept the following licenses: - ${lib.concatMapStringsSep "\n" (str: " - ${str}") licenseNames} + package = cmdline-tools-package; - a) - by setting nixpkgs config option 'android_sdk.accept_license = true;'. - b) - by an environment variable for a single invocation of the nix tools. - $ export NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1 - '' - else - callPackage ./cmdline-tools.nix { - inherit - deployAndroidPackage - os - arch - meta - ; + postInstall = + if !licenseAccepted then + throw '' + ${builtins.concatStringsSep "\n\n" (mkLicenseTexts licenseNames)} - package = cmdline-tools-package; + You must accept the following licenses: + ${lib.concatMapStringsSep "\n" (str: " - ${str}") licenseNames} - postInstall = '' + a) + by setting nixpkgs config option 'android_sdk.accept_license = true;'. + b) + by an environment variable for a single invocation of the nix tools. + $ export NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1 + '' + else + '' # Symlink all requested plugins ${linkPlugin { name = "platform-tools"; @@ -769,5 +769,5 @@ lib.recurseIntoAttrs rec { '' ) licenseNames} ''; - }; + }; }