{ lib
, config
, pkgs
, ...
}:

with lib;
let
  cfg = config.my.programs.nix-edit;
in
{
  options.my.programs.nix-edit.enable = mkEnableOption "nix-edit";

  config = mkIf cfg.enable {
    environment.systemPackages =
      let
        nix-edit = pkgs.writeShellApplication {
          name = "nix-edit";
          runtimeInputs = with pkgs; [ nix gnugrep ];
          text = builtins.readFile ./nix-edit.sh;
        };
      in
      [ nix-edit ];
  };

}
