summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/li/libresprite/package.nix
blob: 87df7ef2e689416a9af2ed55e21b11064e1d23b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
  lib,
  stdenv,
  fetchFromGitHub,

  cmake,
  pkg-config,
  ninja,
  gtest,
  curl,
  freetype,
  giflib,
  libjpeg,
  libpng,
  libwebp,
  libarchive,
  libx11,
  pixman,
  tinyxml-2,
  libxi,
  zlib,
  SDL2,
  SDL2_image,
  lua,

  nixosTests,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "libresprite";
  version = "1.2";

  src = fetchFromGitHub {
    owner = "LibreSprite";
    repo = "LibreSprite";
    tag = "v${finalAttrs.version}";
    fetchSubmodules = true;
    hash = "sha256-jXjrA859hR46Cp5qi6Z1C+hLWCUR7yGlASOGlTveeW8=";
  };
  patches = [
    # From https://github.com/LibreSprite/LibreSprite/pull/565
    ./cmake4.diff
    # Remove Homebrew-specific brew invocation for libarchive on Darwin;
    # Nix provides libarchive directly via buildInputs.
    ./no-brew.patch
  ];
  nativeBuildInputs = [
    cmake
    pkg-config
    ninja
    gtest
  ];

  buildInputs = [
    curl
    freetype
    giflib
    libjpeg
    libpng
    libwebp
    libarchive
    libx11
    pixman
    tinyxml-2
    zlib
    SDL2
    SDL2_image
    lua
    # no v8 due to missing libplatform and libbase
  ]
  ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
    libxi
  ];

  cmakeFlags = [
    "-DWITH_DESKTOP_INTEGRATION=ON"
    "-DWITH_WEBP_SUPPORT=ON"
    "-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
  ];

  hardeningDisable = lib.optional stdenv.hostPlatform.isDarwin "format";

  # Install mime icons. Note that the mimetype is still "x-aseprite"
  postInstall = ''
    src="$out/share/libresprite/data/icons"
    for size in 16 32 48 64; do
      dst="$out"/share/icons/hicolor/"$size"x"$size"
      install -Dm644 "$src"/doc"$size".png "$dst"/mimetypes/aseprite.png
    done

    substituteInPlace $out/share/thumbnailers/libresprite.thumbnailer \
      --replace-fail "TryExec=libresprite-thumbnailer" "TryExec=$out/bin/libresprite-thumbnailer" \
      --replace-fail "Exec=libresprite-thumbnailer" "Exec=$out/bin/libresprite-thumbnailer"
  '';

  passthru.tests = {
    libresprite-can-open-png = nixosTests.libresprite;
  };

  meta = {
    homepage = "https://libresprite.github.io/";
    description = "Animated sprite editor & pixel art tool, fork of Aseprite";
    license = lib.licenses.gpl2Only;
    longDescription = ''
      LibreSprite is a program to create animated sprites. Its main features are:

        - Sprites are composed by layers & frames (as separated concepts).
        - Supported color modes: RGBA, Indexed (palettes up to 256 colors), and Grayscale.
        - Load/save sequence of PNG files and GIF animations (and FLC, FLI, JPG, BMP, PCX, TGA).
        - Export/import animations to/from Sprite Sheets.
        - Tiled drawing mode, useful to draw patterns and textures.
        - Undo/Redo for every operation.
        - Real-time animation preview.
        - Multiple editors support.
        - Pixel-art specific tools like filled Contour, Polygon, Shading mode, etc.
        - Onion skinning.
    '';
    maintainers = with lib.maintainers; [ fgaz ];
    platforms = lib.platforms.all;
  };
})