krunker: init at 2.1.3

seth 10ac8238 d9de10ce

+152
+32
pkgs/by-name/kr/krunker/darwin.nix
··· 1 + { 2 + stdenvNoCC, 3 + fetchurl, 4 + makeBinaryWrapper, 5 + undmg, 6 + }: 7 + 8 + stdenvNoCC.mkDerivation (finalAttrs: { 9 + pname = "krunker"; 10 + version = "2.1.3"; 11 + 12 + src = fetchurl { 13 + url = "https://client2.krunker.io/Official%20Krunker.io%20Client-${finalAttrs.version}.dmg"; 14 + hash = "sha512-brvrOPCsXkkrUGcRxsa8bzpFsrY7GF3llt29ZIax6dC0XBsILKXUleESJ5LpurMOgSBsfxNYjZLPJhicIAtuUA=="; 15 + }; 16 + 17 + sourceRoot = "."; 18 + 19 + nativeBuildInputs = [ 20 + makeBinaryWrapper 21 + undmg 22 + ]; 23 + 24 + postInstall = '' 25 + mkdir -p $out/Applications 26 + cp -r *.app $out/Applications 27 + 28 + makeBinaryWrapper \ 29 + $out/Applications/Official\ Krunker.io\ Client.app/Contents/MacOS/Official\ Krunker.io\ Client \ 30 + $out/bin/krunker 31 + ''; 32 + })
+30
pkgs/by-name/kr/krunker/linux.nix
··· 1 + { appimageTools, fetchurl }: 2 + 3 + let 4 + pname = "krunker"; 5 + version = "2.1.3"; 6 + 7 + appId = "io.krunker.desktop"; 8 + 9 + src = fetchurl { 10 + url = "https://client2.krunker.io/Official%20Krunker.io%20Client-${version}.AppImage"; 11 + hash = "sha512-a8E5heLsKXOtv/wRKlrnV0GD48cY1mOiSSDW93c7YZ+HoeuBQDxtRaHKg5EqU51Yi+d4tPF5nOh10jZW36c7WQ=="; 12 + }; 13 + 14 + appimageContents = appimageTools.extractType2 { 15 + inherit pname version src; 16 + }; 17 + in 18 + 19 + appimageTools.wrapType2 { 20 + inherit pname version src; 21 + 22 + extraInstallCommands = '' 23 + mkdir -p $out/share/{applications,pixmaps} 24 + install -Dm644 ${appimageContents}/${appId}.desktop -t $out/share/applications 25 + install -Dm644 ${appimageContents}/${appId}.png -t $out/share/pixmaps 26 + 27 + substituteInPlace $out/share/applications/${appId}.desktop \ 28 + --replace-fail 'Exec=AppRun' "Exec=$pname" 29 + ''; 30 + }
+32
pkgs/by-name/kr/krunker/package.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + callPackage, 5 + }: 6 + 7 + let 8 + package = 9 + if stdenv.hostPlatform.isDarwin then callPackage ./darwin.nix { } else callPackage ./linux.nix { }; 10 + in 11 + 12 + package.overrideAttrs ( 13 + finalAttrs: oldAttrs: { 14 + passthru = { 15 + updateScript = ./update.sh; 16 + } // oldAttrs.passthru or { }; 17 + 18 + # Point `nix edit`, etc. to the file that defines the attribute, not this 19 + # entry point 20 + pos = builtins.unsafeGetAttrPos "pname" finalAttrs; 21 + 22 + meta = { 23 + description = "Easy to get into fully moddable First Person Shooter with advanced movement mechanics"; 24 + homepage = "https://krunker.io"; 25 + license = lib.licenses.unfree; 26 + maintainers = with lib.maintainers; [ getchoo ]; 27 + mainProgram = "krunker"; 28 + platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin; 29 + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 30 + } // oldAttrs.meta or { }; 31 + } 32 + )
+58
pkgs/by-name/kr/krunker/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #! nix-shell --pure -i bash -p bash cacert common-updater-scripts curl yq 3 + # shellcheck shell=bash 4 + set -euo pipefail 5 + 6 + root=$(readlink -f "$0" | xargs dirname) 7 + script_name="krunker-update" 8 + updater_url="client2.krunker.io" 9 + 10 + log() { 11 + echo "$script_name: $*" 12 + } 13 + 14 + panic() { 15 + log "$*" 16 + exit 1 17 + } 18 + 19 + update() { 20 + platform="${1:-}" 21 + if [ -z "$platform" ]; then 22 + panic "error: a platform must be supplied to \`update()\`!" 23 + fi 24 + 25 + nixfile="$root"/"$platform".nix 26 + if [ ! -f "$nixfile" ]; then 27 + panic "error: $platform is not supported!" 28 + fi 29 + 30 + electron_suffix="" 31 + system="x86_64-linux" 32 + if [ "$platform" == "darwin" ]; then 33 + electron_suffix="-mac" 34 + system="aarch64-darwin" 35 + elif [ "$platform" == "linux" ]; then 36 + electron_suffix="-linux" 37 + fi 38 + 39 + url="https://$updater_url/latest${electron_suffix}.yml" 40 + log "fetching update information from from $url" 41 + response="$(curl -sSL "$url")" 42 + version="$(yq --raw-output '.version' <<<"$response")" 43 + sha512="$(yq \ 44 + --raw-output \ 45 + '.files | map(select(.url | contains("dmg") or contains("AppImage"))) | first | .sha512' \ 46 + <<<"$response")" 47 + 48 + update-source-version krunker "$version" sha512-"$sha512" --file="$nixfile" --system="$system" 49 + } 50 + 51 + supported_platforms=( 52 + "darwin" 53 + "linux" 54 + ) 55 + 56 + for platform in "${supported_platforms[@]}"; do 57 + update "$platform" 58 + done