summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/audio/midas/generic.nix
blob: fdb60633f2dce4e3ad3d5b4620783803c6fc0edc (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
{
  stdenv,
  fetchurl,
  lib,
  brand,
  type,
  version,
  homepage,
  url,
  hash,
  runCommand,
  dpkg,
  vmTools,
  runtimeShell,
  bubblewrap,
  ...
}:
let
  debian =
    let
      debs = lib.flatten (import ./deps.nix { inherit fetchurl; });
    in
    runCommand "x32edit-debian" { nativeBuildInputs = [ dpkg ]; } (
      lib.concatMapStringsSep "\n" (deb: ''
        dpkg-deb -x ${deb} $out
      '') debs
    );
in
stdenv.mkDerivation (finalAttrs: {
  pname = "${lib.toLower type}-edit";
  inherit version;

  src = fetchurl {
    inherit url hash;
  };

  sourceRoot = ".";
  dontBuild = true;
  dontStrip = true;

  installPhase = ''
    mkdir -p $out/bin
    cp ${type}-Edit $out/bin/.${finalAttrs.pname}

    cat >$out/bin/${finalAttrs.pname} <<EOF
    #!${runtimeShell} -eu
    exec ${lib.getExe bubblewrap} \
      --dev-bind / / \
      --ro-bind "${debian}/lib" /lib \
      --ro-bind "${debian}/lib64" /lib64 \
      --tmpfs /usr \
      --ro-bind "${debian}/usr/lib" /usr/lib \
      $out/bin/.${finalAttrs.pname}
    EOF
    chmod 755 $out/bin/${finalAttrs.pname}
  '';

  passthru.deps =
    let
      distro = vmTools.debDistros.debian12x86_64;
    in
    vmTools.debClosureGenerator {
      name = "x32edit-dependencies";
      inherit (distro) urlPrefix;
      packagesLists = [ distro.packagesLists ];
      packages = [
        "libstdc++6"
        "libcurl4"
        "libfreetype6"
        "libasound2"
        "libx11-6"
        "libxext6"
      ];
    };

  meta = {
    inherit homepage;
    description = "Editor for the ${brand} ${type} digital mixer";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.unfree;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ magnetophon ];
  };
})