{ pkgs, ... }:
pkgs.writeShellApplication {
  name = "find-flake-root";
  runtimeInputs = [ pkgs.uutils-coreutils-noprefix ];
  text = ''
    while [[ ! -f "$(pwd)/flake.nix" ]]; do
      if [[ "$(pwd)" == "/" ]]; then
        echo "Could not find flake root" 1>&2
        exit 1
      fi
      cd ..
    done
    pwd
    exit 0
  '';
}
