summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c9a048ac0728407cb935e2a738ced34126231b17 (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
pkgname=waft-git
pkgver=r0.0000000
pkgrel=1
pkgdesc="Waft central daemon and plugin ecosystem (entity-based Wayland desktop services)"
arch=('x86_64' 'aarch64')
url="https://github.com/readyplayernan/waft"
license=('MIT')
depends=('gcc-libs' 'glibc' 'dbus')
makedepends=('cargo' 'git' 'rust')
optdepends=(
  'brightnessctl: laptop backlight control (brightness plugin)'
  'ddcutil: external monitor brightness control (brightness plugin)'
  'networkmanager: WiFi/Ethernet/VPN management (networkmanager plugin)'
  'bluez: Bluetooth device management (bluez plugin)'
  'bluez-utils: Bluetooth CLI tooling (bluez plugin)'
  'pipewire-pulse: audio device control via pactl (audio plugin)'
  'libpulse: audio device control via pactl (audio plugin)'
  'upower: battery monitoring (battery plugin)'
  'evolution-data-server: calendar integration (eds plugin)'
  'gnome-online-accounts: online account integration (gnome-online-accounts plugin)'
  'gsettings-desktop-schemas: GTK appearance configuration (gsettings plugin)'
  'darkman: dark mode toggle (darkman plugin)'
  'sunsetr: night light control (sunsetr plugin)'
  'syncthing: file sync service toggle (syncthing plugin)'
  'niri: niri compositor integration (niri plugin)'
)
provides=('waft')
conflicts=('waft')
options=('!lto')
source=("$pkgname::git+https://github.com/readyplayernan/waft.git")
sha256sums=('SKIP')

# Discover plugin daemon binaries from plugins/*/Cargo.toml at build time.
# Any [[bin]] target declared under plugins/<name>/ is bundled with waft.
_discover_plugin_bins() {
  awk '
    /^\[\[bin\]\]/ { in_bin = 1; next }
    /^\[/          { in_bin = 0 }
    in_bin && /^name[[:space:]]*=/ {
      sub(/^[^"]*"/, "")
      sub(/".*$/,   "")
      print
    }
  ' "$srcdir/$pkgname"/plugins/*/Cargo.toml
}

pkgver() {
  cd "$srcdir/$pkgname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/$pkgname"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd "$srcdir/$pkgname"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target

  mapfile -t _plugin_bins < <(_discover_plugin_bins)

  local bin_args=(--bin waft)
  local b
  for b in "${_plugin_bins[@]}"; do
    bin_args+=(--bin "$b")
  done

  cargo build --frozen --release "${bin_args[@]}"
}

check() {
  cd "$srcdir/$pkgname"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo test --frozen -p waft -p waft-protocol -p waft-plugin
}

package() {
  cd "$srcdir/$pkgname"

  mapfile -t _plugin_bins < <(_discover_plugin_bins)

  install -Dm755 "target/release/waft" "$pkgdir/usr/bin/waft"

  local b
  for b in "${_plugin_bins[@]}"; do
    install -Dm755 "target/release/$b" "$pkgdir/usr/bin/$b"
  done

  install -Dm644 "data/org.waft.Daemon.service" \
    "$pkgdir/usr/share/dbus-1/services/org.waft.Daemon.service"
  install -Dm644 "data/waft.service" \
    "$pkgdir/usr/lib/systemd/user/waft.service"
  install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}