_choose_nix_systems() {
  # x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd
  gum choose --no-limit --ordered --height 15 {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} \
    | sed -E 's/^([^-]*)-([^-]*)$/\2-\1/'
}

mnix-build() {
  # TODO: somehow store the out-links
  _choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nix-build --keep-going --no-out-link
}
mnom-build() {
  # TODO: somehow store the out-links
  _choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nom-build --keep-going --no-out-link
}
mnixpkgs-review() {
  # TODO: use /run/user/...
  # mkdir -p /dev/shm/nixpkgs-review
  # ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review
  nixpkgs-review --systems "$(_choose_nix_systems | xargs)" "$@"
}
