Unverified Commit 662f1d70 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

nixos/fish: allow disabling completion generation (#418328)

parents b18bbc99 dbf39b7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ in
    # The lessopen package pulls in Perl.
    less.lessopen = mkDefault null;
    command-not-found.enable = mkDefault false;
    fish.generateCompletions = mkDefault false;
  };

  # This pulls in nixos-containers which depends on Perl.
+24 −16
Original line number Diff line number Diff line
@@ -72,6 +72,11 @@ in
        '';
      };

      generateCompletions = lib.mkEnableOption "generating completion files from man pages" // {
        default = true;
        example = false;
      };

      vendor.config.enable = lib.mkOption {
        type = lib.types.bool;
        default = true;
@@ -247,7 +252,7 @@ in
        '';
      }

      {
      (lib.mkIf cfg.generateCompletions {
        etc."fish/generated_completions".source =
          let
            patchedGenerator = pkgs.stdenv.mkDerivation {
@@ -297,7 +302,7 @@ in
            ignoreCollisions = true;
            paths = builtins.map generateCompletions config.environment.systemPackages;
          };
      }
      })

      # include programs that bring their own completions
      {
@@ -318,7 +323,8 @@ in
      }
    ];

    programs.fish.interactiveShellInit = ''
    programs.fish.interactiveShellInit =
      lib.optionalString cfg.generateCompletions ''
        # add completions generated by NixOS to $fish_complete_path
        begin
          # joins with null byte to accommodate all characters in paths, then respectively gets all paths before (exclusive) / after (inclusive) the first one including "generated_completions",
@@ -327,6 +333,8 @@ in
          set -l post (string join0 $fish_complete_path | string match --regex "[^\x00]*generated_completions.*" | string split0 | string match -er ".")
          set fish_complete_path $prev "/etc/fish/generated_completions" $post
        end
      ''
      + ''
        # prevent fish from generating completions on first run
        if not test -d $__fish_user_data_dir/generated_completions
          ${pkgs.coreutils}/bin/mkdir $__fish_user_data_dir/generated_completions