k3s: format with nixfmt-rfc-style
[NixPkgs.git] / pkgs / games / sgt-puzzles / default.nix
blob304c0f9b27c7872fc4bb6f2df6533a51be06c234
1 { lib, stdenv, fetchurl, desktop-file-utils
2 , gtk3, libX11, cmake, imagemagick
3 , pkg-config, perl, wrapGAppsHook3, nixosTests, writeScript
4 , isMobile ? false
5 }:
7 stdenv.mkDerivation rec {
8   pname = "sgt-puzzles";
9   version = "20240330.fd304c5";
11   src = fetchurl {
12     url = "http://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles-${version}.tar.gz";
13     hash = "sha256-usEgCfbeKOkAg/sHpRxuMcPGHxb+J5+r92aO4Ar7iUA=";
14   };
16   sgt-puzzles-menu = fetchurl {
17     url = "https://raw.githubusercontent.com/gentoo/gentoo/720e614d0107e86fc1e520bac17726578186843d/games-puzzle/sgt-puzzles/files/sgt-puzzles.menu";
18     sha256 = "088w0x9g3j8pn725ix8ny8knhdsfgjr3hpswsh9fvfkz5vlg2xkm";
19   };
21   nativeBuildInputs = [
22     cmake
23     desktop-file-utils
24     imagemagick
25     perl
26     pkg-config
27     wrapGAppsHook3
28   ];
30   env.NIX_CFLAGS_COMPILE = lib.optionalString isMobile "-DSTYLUS_BASED";
32   buildInputs = [ gtk3 libX11 ];
34   postInstall = ''
35     for i in  $(basename -s $out/bin/*); do
37       ln -s $out/bin/$i $out/bin/sgt-puzzle-$i
38       install -Dm644 icons/$i-96d24.png -t $out/share/icons/hicolor/96x96/apps/
40       # Generate/validate/install .desktop files.
41       echo "[Desktop Entry]" > $i.desktop
42       desktop-file-install --dir $out/share/applications \
43         --set-key Type --set-value Application \
44         --set-key Exec --set-value $i \
45         --set-key Name --set-value $i \
46         --set-key Comment --set-value "${meta.description}" \
47         --set-key Categories --set-value "Game;LogicGame;X-sgt-puzzles;" \
48         --set-key Icon --set-value $out/share/icons/hicolor/96x96/apps/$i-96d24.png \
49         $i.desktop
50     done
52     echo "[Desktop Entry]" > sgt-puzzles.directory
53     desktop-file-install --dir $out/share/desktop-directories \
54       --set-key Type --set-value Directory \
55       --set-key Name --set-value Puzzles \
56       --set-key Icon --set-value $out/share/icons/hicolor/48x48/apps/sgt-puzzles_map \
57       sgt-puzzles.directory
59     install -Dm644 ${sgt-puzzles-menu} -t $out/etc/xdg/menus/applications-merged/
60   '';
62   passthru = {
63     tests.sgt-puzzles = nixosTests.sgt-puzzles;
64     updateScript = writeScript "update-sgt-puzzles" ''
65       #!/usr/bin/env nix-shell
66       #!nix-shell -i bash -p curl pcre common-updater-scripts
68       set -eu -o pipefail
70       version="$(curl -sI 'https://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles.tar.gz' | grep -Fi Location: | pcregrep -o1 'puzzles-([0-9a-f.]*).tar.gz')"
71       update-source-version sgt-puzzles "$version"
72     '';
73   };
75   meta = with lib; {
76     description = "Simon Tatham's portable puzzle collection";
77     license = licenses.mit;
78     maintainers = with maintainers; [ raskin tomfitzhenry ];
79     platforms = platforms.linux;
80     homepage = "https://www.chiark.greenend.org.uk/~sgtatham/puzzles/";
81   };