starsector: generate desktop file

+27 -4
+27 -4
pkgs/games/starsector/default.nix
··· 6 6 , openjdk 7 7 , stdenv 8 8 , xorg 9 + , copyDesktopItems 10 + , makeDesktopItem 9 11 }: 10 12 11 13 stdenv.mkDerivation rec { ··· 17 19 sha256 = "sha256-/5ij/079aOad7otXSFFcmVmiYQnMX/0RXGOr1j0rkGY="; 18 20 }; 19 21 20 - nativeBuildInputs = [ makeWrapper ]; 22 + nativeBuildInputs = [ 23 + copyDesktopItems 24 + makeWrapper 25 + ]; 21 26 buildInputs = with xorg; [ 22 27 alsa-lib 23 28 libXxf86vm ··· 25 30 26 31 dontBuild = true; 27 32 33 + desktopItems = [ 34 + (makeDesktopItem { 35 + name = "starsector"; 36 + exec = "starsector"; 37 + icon = "starsector"; 38 + comment = meta.description; 39 + genericName = "starsector"; 40 + desktopName = "Starsector"; 41 + categories = "Game;"; 42 + }) 43 + ]; 44 + 28 45 # need to cd into $out in order for classpath to pick up correct jar files 29 46 installPhase = '' 47 + runHook preInstall 48 + 30 49 mkdir -p $out/bin 31 50 rm -r jre_linux # remove jre7 32 51 rm starfarer.api.zip 33 52 cp -r ./* $out 53 + 54 + mkdir -p $out/share/icons/hicolor/64x64/apps 55 + ln -s $out/graphics/ui/s_icon64.png $out/share/icons/hicolor/64x64/apps/starsector.png 34 56 35 57 wrapProgram $out/starsector.sh \ 36 58 --prefix PATH : ${lib.makeBinPath [ openjdk ]} \ 37 59 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \ 38 - --run "mkdir -p \$XDG_DATA_HOME/starsector; cd $out" 60 + --run 'mkdir -p ''${XDG_DATA_HOME:-~/.local/share}/starsector; cd '"$out" 39 61 ln -s $out/starsector.sh $out/bin/starsector 62 + 63 + runHook postInstall 40 64 ''; 41 65 42 66 # it tries to run everything with relative paths, which makes it CWD dependent ··· 44 68 postPatch = '' 45 69 substituteInPlace starsector.sh \ 46 70 --replace "./jre_linux/bin/java" "${openjdk}/bin/java" \ 47 - --replace "./native/linux" "$out/native/linux" \ 48 - --replace "./" "\$XDG_DATA_HOME/starsector/" 71 + --replace "./native/linux" "$out/native/linux" 49 72 ''; 50 73 51 74 meta = with lib; {