1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{ depot, pkgs, ... }:

let
  unwrapped = depot.nix.buildGo.program {
    name = "monitor";
    srcs = [
      ./main.go
      ./parse.go
      ./layout.go
    ];
  };
in
# `xrandr` is looked up on PATH rather than baked in, so the tool stays usable
# when run by hand. The wrapper is what guarantees it is found when the tool is
# started from a keybinding, where PATH is only whatever the WM inherited.
pkgs.symlinkJoin {
  name = "monitor";
  paths = [ unwrapped ];
  buildInputs = [ pkgs.makeWrapper ];
  postBuild = ''
    wrapProgram $out/bin/monitor \
      --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.xrandr ]}
  '';
}