···11+{ ... }:
22+{
33+ perSystem =
44+ { pkgs, ... }:
55+ {
66+ packages.menu =
77+ if pkgs.stdenv.hostPlatform.isDarwin then
88+ (pkgs.writeShellApplication {
99+ name = "menu";
1010+ runtimeInputs = [
1111+ pkgs.choose-gui
1212+ ];
1313+ text = ''
1414+ set -efu
1515+ # TODO check if a terminal is available and use fzf in that case
1616+ exec choose "$@"
1717+ '';
1818+ })
1919+ else if pkgs.stdenv.hostPlatform.isLinux then
2020+ (pkgs.writeShellApplication {
2121+ name = "menu";
2222+ runtimeInputs = [
2323+ pkgs.rofi
2424+ pkgs.wofi
2525+ ];
2626+ text = ''
2727+ set -efu
2828+ # TODO check if a terminal is available and use fzf in that case
2929+ if [[ -n $WAYLAND_DISPLAY ]]; then
3030+ exec wofi "$@"
3131+ elif [[ -n $DISPLAY ]]; then
3232+ exec rofi "$@"
3333+ fi
3434+ '';
3535+3636+ })
3737+ else
3838+ throw "unsupported system";
3939+ };
4040+}