summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ci/cider-2/package.nix
blob: fe6de60c3096ead3226453c122f5d592b0c87965 (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
{
  lib,
  stdenv,
  fetchurl,
  dpkg,
  autoPatchelfHook,
  makeWrapper,
  gsettings-desktop-schemas,
  dconf,

  # Required dependencies for autoPatchelfHook
  alsa-lib,
  gtk3,
  libgbm,
  libGL,
  nspr,
  nss,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "cider-2";
  version = "4.0.17";

  src = fetchurl {
    url = "https://repo.cider.sh/apt/pool/main/cider-v${finalAttrs.version}-linux-x64.deb";
    hash = "sha256-CanpS0yydWOkGKp/8SIVSJ7EavFUs9xBxUgmL9AUXJU=";
  };

  nativeBuildInputs = [
    dpkg
    autoPatchelfHook
    makeWrapper
  ];

  buildInputs = [
    alsa-lib
    gtk3
    libgbm
    nspr
    nss
  ];
  # appendRunpaths is applied to every ELF, including shared libraries.
  # runtimeDependencies wouldn't work here because autoPatchelfHook rewrites
  # the RPATH of dynamic executables only, not of shared libraries.
  appendRunpaths = lib.makeLibraryPath [
    libGL # libEGL.so.1 is dlopen'd by ANGLE from libGLESv2.so
  ];

  unpackPhase = ''
    runHook preUnpack
    dpkg-deb --fsys-tarfile $src | tar --extract
    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/{bin,share,lib}
    cp -r usr/share/* $out/share/
    cp -r usr/lib/* $out/lib/

    chmod +x $out/lib/cider/Cider

    # The prefixes that follow --add-flags are typically injected via wrapGAppsHook3.
    # We append them manually instead to avoid a double-wrapping.
    makeWrapper $out/lib/cider/Cider $out/bin/cider-2 \
      --add-flags "\$\{NIXOS_OZONE_WL:+\$\{WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true\}\}" \
      --add-flags "--no-sandbox --disable-gpu-sandbox" \
      --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
      --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}" \
      --prefix GIO_EXTRA_MODULES : "${dconf.lib}/lib/gio/modules" \
      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"

    runHook postInstall
  '';

  postFixup = ''
    mv $out/share/applications/cider.desktop $out/share/applications/cider-2.desktop
    substituteInPlace $out/share/applications/cider-2.desktop \
      --replace-fail Exec=cider Exec=cider-2 \
      --replace-fail Icon=cider Icon=cider-2

    install -Dm444 $out/share/pixmaps/cider.png \
      $out/share/icons/hicolor/256x256/apps/cider-2.png

    rm -r $out/share/{pixmaps,lintian}
    rm $out/lib/cider/resources/Cider{,.flatpak}.desktop
    rm $out/lib/cider/resources/public/icon{.icns,-osx-previous.icns,.ico}
  '';

  passthru.updateScript = ./updater.sh;

  meta = {
    description = "Powerful music player that allows you listen to your favorite tracks with style";
    homepage = "https://cider.sh";
    license = lib.licenses.unfree;
    mainProgram = "cider-2";
    maintainers = with lib.maintainers; [
      amadejkastelic
      antoineco
      l0r3v
    ];
    platforms = [ "x86_64-linux" ];
  };
})