nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 84 lines 2.3 kB view raw
1{ 2 lib, 3 callPackage, 4 writeShellApplication, 5}: 6let 7 assets = callPackage ./assets.nix { }; 8 quakec = callPackage ./quakec.nix { }; 9 fteqw = callPackage ./fteqw.nix { }; 10 11 # We use the youngest version of all of the dependencies as the version number. 12 # This is similar to what upstream uses, except ours is a bit more accurate 13 # since we don't rely on a CI to run at an arbitrary time. 14 dateString = 15 lib.pipe 16 [ 17 assets 18 fteqw 19 quakec 20 ] 21 [ 22 # Find the youngest (most recently updated) version 23 (lib.foldl' (acc: p: if lib.versionOlder acc p.version then p.version else acc) "") 24 (lib.splitString "-") 25 (lib.sublist 2 6) # drop the first two segments (0 and unstable) and only keep the date 26 lib.concatStrings 27 ]; 28 29 version = "2.0.0-indev+${dateString}"; 30in 31writeShellApplication { 32 name = "nzportable"; 33 34 text = '' 35 runDir=''${XDG_DATA_HOME:-$HOME/.local/share}/nzportable 36 data=${assets.pc} 37 38 relinkGameFiles() { 39 mkdir -p "$runDir"/nzp 40 41 # Remove existing links 42 find "$runDir" -type l -exec rm {} + 43 44 # Link game files 45 ln -s $data/default.fmf "$runDir" 46 ln -st "$runDir"/nzp $data/nzp/* ${quakec.fte}/* 47 48 # Write current version 49 echo "${version}" > "$runDir"/nzp/version.txt 50 } 51 52 if [[ ! -d $runDir ]]; then 53 echo "Game directory $runDir not found. Assuming first launch" 54 echo "Linking game files" 55 relinkGameFiles 56 else 57 currentVersion=$(<"$runDir"/nzp/version.txt) 58 if [[ "${version}" != "$currentVersion" ]]; then 59 echo "Version mismatch! (saved version $currentVersion != current version ${version})" 60 echo "Relinking game files" 61 relinkGameFiles 62 fi 63 fi 64 65 exec ${lib.getExe fteqw} -basedir "$runDir" "$@" 66 ''; 67 68 derivationArgs = { 69 inherit version; 70 passthru = { 71 updateScript = callPackage ./update.nix { }; 72 inherit assets quakec fteqw; 73 }; 74 }; 75 76 meta = { 77 inherit (fteqw.meta) platforms; 78 description = "Call of Duty: Zombies demake, powered by various Quake sourceports (PC version)"; 79 homepage = "https://docs.nzp.gay"; 80 license = lib.licenses.gpl2Plus; 81 maintainers = with lib.maintainers; [ pluiedev ]; 82 mainProgram = "nzportable"; 83 }; 84}