summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/pi/pinnacle/package.nix
blob: ca86080c11775a874291cd166b7b73fd5f8c2d49 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
{
  rustPlatform,
  stdenv,
  lib,
  pkg-config,
  wayland,
  lua54Packages,
  lua5_4,
  extraLuaPackages ? (ps: [ ]),
  protobuf,
  seatd,
  systemdLibs,
  libxkbcommon,
  mesa,
  xwayland,
  libinput,
  libdisplay-info_0_3,
  git,
  libgbm,
  rustc,
  cargo,
  makeWrapper,
  callPackage,
  libglvnd,
  autoPatchelfHook,
  installShellFiles,
  libxcursor,
  libxi,
  libxrandr,
  libx11,
  fetchFromGitHub,
  writableTmpDirAsHomeHook,
}:
let
  version = "0.2.4";
  pinnacle-src = fetchFromGitHub {
    owner = "pinnacle-comp";
    repo = "pinnacle";
    tag = "v${version}";
    sha256 = "sha256-T8wZjgOTzYKfYUV1ShLBIi2xoCdVn9I7sux/pDH+8ic=";
  };
  buildRustConfig = callPackage ./pinnacle-config.nix { inherit pinnacle-src; };

  meta = {
    description = "A WIP Smithay-based Wayland compositor, inspired by AwesomeWM and configured in Lua or Rust";
    homepage = "https://pinnacle-comp.github.io/pinnacle/";
    license = lib.licenses.gpl3;
    mainProgram = "pinnacle";
    platforms = lib.platforms.linux;
    badPlatforms = [
      # tests fail https://hydra.nixos.org/build/337493260
      "aarch64-linux"
    ];
    maintainers = with lib.maintainers; [ cassandracomar ];
  };

  lua-client-api = lua54Packages.buildLuarocksPackage rec {
    inherit meta version;
    pname = "pinnacle-client-api";
    src = pinnacle-src;
    sourceRoot = "${src.name}/api/lua";
    knownRockspec = "${pinnacle-src}/api/lua/rockspecs/pinnacle-api-0.2.4-1.rockspec";

    postConfigure = ''
      substituteInPlace "$rockspecFilename" \
        --replace-fail '"compat53 ~> 0.14"' '"compat53 >= 0.14"'
    '';

    propagatedBuildInputs = with lua54Packages; [
      cqueues
      http
      lua-protobuf
      compat53
      luaposix
    ];

    postInstall = ''
      mkdir -p $out/share/pinnacle/protobuf/pinnacle
      cp -rL --no-preserve ownership,mode ../../api/protobuf/pinnacle $out/share/pinnacle/protobuf
      mkdir -p $out/share/pinnacle/snowcap/protobuf/snowcap
      cp -rL --no-preserve ownership,mode ../../snowcap/api/protobuf/snowcap $out/share/pinnacle/snowcap/protobuf
      mkdir -p $out/share/pinnacle/protobuf/google
      cp -rL --no-preserve ownership,mode ../../api/protobuf/google $out/share/pinnacle/protobuf
      mkdir -p $out/share/pinnacle/snowcap/protobuf/google
      cp -rL --no-preserve ownership,mode ../../snowcap/api/protobuf/google $out/share/pinnacle/snowcap/protobuf
    '';
  };
in
rustPlatform.buildRustPackage (finalAttrs: {
  inherit meta version;

  pname = "pinnacle-server";
  src = pinnacle-src;
  cargoHash = "sha256-hM19RB2+ejC+OFU4keH+PKWYf5NRUXJ1W33eSUhKR/g=";

  buildInputs = [
    wayland

    # libs
    seatd.dev
    systemdLibs.dev
    libxkbcommon
    libinput
    mesa
    xwayland
    libdisplay-info_0_3
    libgbm
    lua5_4

    # winit on x11
    libxcursor
    libxrandr
    libxi
    libx11
  ];

  nativeBuildInputs = [
    pkg-config
    protobuf
    lua54Packages.luarocks
    lua5_4
    lua-client-api
    git
    wayland
    makeWrapper
    autoPatchelfHook
    installShellFiles
    writableTmpDirAsHomeHook
  ];

  checkFeatures = [ "testing" ];
  checkNoDefaultFeatures = true;
  cargoTestFlags = [
    "--exclude"
    "wlcs_pinnacle"
    "--all"
    "--"
    "--skip"
    "process_spawn"
  ];

  preCheck = ''
    export LD_LIBRARY_PATH="${lib.makeLibraryPath [ wayland ]}";
    export XDG_RUNTIME_DIR=$(mktemp -d)
  '';

  postInstall = ''
    wrapProgram $out/bin/pinnacle --prefix PATH ":" ${
      lib.makeBinPath [
        rustc
        cargo
        finalAttrs.passthru.luaEnv
        xwayland
      ]
    }
    install -m755 ./resources/pinnacle-session $out/bin/pinnacle-session
    mkdir -p $out/share/wayland-sessions
    install -m644 ./resources/pinnacle.desktop $out/share/wayland-sessions/pinnacle.desktop
    patchShebangs $out/bin/pinnacle-session
    mkdir -p $out/share/xdg-desktop-portal
    install -m644 ./resources/pinnacle-portals.conf $out/share/xdg-desktop-portal/pinnacle-portals.conf
    install -m644 ./resources/pinnacle-portals.conf $out/share/xdg-desktop-portal/pinnacle-uwsm-portals.conf
  ''
  + lib.optionalString (stdenv.hostPlatform.canExecute stdenv.buildPlatform) ''
    installShellCompletion --cmd pinnacle \
      --bash <($out/bin/pinnacle gen-completions --shell bash) \
      --fish <($out/bin/pinnacle gen-completions --shell fish) \
      --zsh <($out/bin/pinnacle gen-completions --shell zsh)
  '';

  runtimeDependencies = [
    wayland
    mesa
    libglvnd # libEGL
  ];

  passthru = {
    luaEnv = lua5_4.withPackages (
      ps:
      [
        finalAttrs.passthru.lua-client-api
        ps.cjson
      ]
      ++ (extraLuaPackages ps)
    );
    inherit buildRustConfig;
    providedSessions = [ "pinnacle" ];
    lua-client-api = lua-client-api;
  };
  __structuredAttrs = true;
})