summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/al/alda/package.nix
blob: 6e45ac10679a807f31e3b80af1c4992726dfc7d2 (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
{
  lib,
  stdenv,
  fetchFromGitHub,
  buildGoModule,
  gradle,
  makeWrapper,
  jre,
  symlinkJoin,
}:
let
  pname = "alda";
  version = "2.3.2";
  src = fetchFromGitHub {
    owner = "alda-lang";
    repo = "alda";
    tag = "release-${version}";
    hash = "sha256-qOEYBWU9xL62MyLSsJ0wtNea2eRhd/3ZT27j3gmNzQI=";
  };
  license = lib.licenses.epl20;

  alda_client = buildGoModule {
    pname = "alda-client";
    inherit version src;

    sourceRoot = "${src.name}/client";
    vendorHash = "sha256-h09w6ZLirLNxYv/ibeN5pCnXSvT+1FGiXiYNReZBMXI=";

    preBuild = ''
      go generate main.go
    '';

    env.CGO_ENABLED = 0;
    ldflags = [
      "-w"
      "-extldflags '-static'"
    ];
    tags = [ "netgo" ];
    subPackages = [ "." ];

    postInstall = ''
      mv $out/bin/client $out/bin/alda
    '';

    meta = {
      inherit license;
      homepage = "https://github.com/alda-lang/alda/tree/master/client";
      broken = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
      maintainers = [ lib.maintainers.ericdallo ];
      platforms = lib.platforms.unix;
    };
  };
  alda_player = stdenv.mkDerivation {
    pname = "alda-player";
    inherit version src;

    sourceRoot = "${src.name}/player";
    nativeBuildInputs = [
      gradle
      makeWrapper
    ];

    mitmCache = gradle.fetchDeps {
      inherit pname;
      data = ./deps.json;
    };
    __darwinAllowLocalNetworking = true;

    gradleBuildTask = "fatJar";

    installPhase = ''
      runHook preInstall

      mkdir -p $out/{bin,share}
      cp build/libs/alda-player-fat.jar $out/share

      makeWrapper ${lib.getExe jre} $out/bin/alda-player \
        --add-flags "-jar $out/share/alda-player-fat.jar"

      runHook postInstall
    '';

    meta = {
      inherit license;
      homepage = "https://github.com/alda-lang/alda/tree/master/player";
      maintainers = [ lib.maintainers.ericdallo ];
      platforms = lib.platforms.unix;
    };
  };
in
symlinkJoin {
  inherit pname version;
  paths = [
    alda_client
    alda_player
  ];

  meta = {
    inherit license;
    description = "Music programming language for musicians";
    homepage = "https://alda.io";
    sourceProvenance = with lib.sourceTypes; [
      fromSource
      binaryBytecode
    ];
    maintainers = [ lib.maintainers.ericdallo ];
    platforms = lib.platforms.unix;
  };
}