diff --git a/modules/home-manager/programs/nix-index/module.nix b/modules/home-manager/programs/nix-index/module.nix index a1ca372..f43281b 100644 --- a/modules/home-manager/programs/nix-index/module.nix +++ b/modules/home-manager/programs/nix-index/module.nix @@ -10,11 +10,14 @@ in { options.my.programs.nix-index = { enable = lib.mkDefaultEnableOption "nix-index"; package = lib.mkOption { - default = pkgs.nix-index; - defaultText = "pkgs.nix-index"; - description = '' - The nix-index package to use. - ''; + default = pkgs.nix-index.override (prev: { + nix-index-unwrapped = prev.nix-index-unwrapped.overrideAttrs (prevAttrs: { + patches = (prevAttrs.patches or []) ++ [ + # https://github.com/nix-community/nix-index/pull/243 + ./skip-fhs-by-default.patch + ]; + }); + }); type = with lib.types; package; }; @@ -24,6 +27,8 @@ in { my.persist.directories = [ "~/.cache/nix-index" ]; programs.command-not-found.enable = lib.mkForce false; - programs.nix-index.enable = true; + programs.nix-index = { + inherit (cfg) enable package; + }; }; } diff --git a/modules/home-manager/programs/nix-index/skip-fhs-by-default.patch b/modules/home-manager/programs/nix-index/skip-fhs-by-default.patch new file mode 100644 index 0000000..b357366 --- /dev/null +++ b/modules/home-manager/programs/nix-index/skip-fhs-by-default.patch @@ -0,0 +1,51 @@ +diff --git a/CHANGELOG.md b/CHANGELOG.md +index 3c09c04..25f62e8 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -3,6 +3,8 @@ + ### Fixed + ### Changed + ++* `--top-level` is now the default. To use the old default, add `--all`. ++ + ## 0.1.8 + ### Added + +diff --git a/command-not-found.sh b/command-not-found.sh +index 5f30bad..64457ef 100755 +--- a/command-not-found.sh ++++ b/command-not-found.sh +@@ -16,7 +16,7 @@ command_not_found_handle () { + + toplevel=nixpkgs # nixpkgs should always be available even in NixOS + cmd=$1 +- attrs=$(@out@/bin/nix-locate --minimal --no-group --type x --type s --top-level --whole-name --at-root "/bin/$cmd") ++ attrs=$(@out@/bin/nix-locate --minimal --no-group --type x --type s --whole-name --at-root "/bin/$cmd") + len=$(echo -n "$attrs" | grep -c "^") + + case $len in +diff --git a/src/bin/nix-locate.rs b/src/bin/nix-locate.rs +index 760d398..2c18747 100644 +--- a/src/bin/nix-locate.rs ++++ b/src/bin/nix-locate.rs +@@ -187,7 +187,7 @@ fn process_args(matches: Opts) -> result::Result { + file_type: matches + .r#type + .unwrap_or_else(|| files::ALL_FILE_TYPES.to_vec()), +- only_toplevel: matches.top_level, ++ only_toplevel: !matches.all, + color, + minimal: matches.minimal, + }; +@@ -255,9 +255,9 @@ struct Opts { + #[clap(long, name = "HASH")] + hash: Option, + +- /// Only print matches from packages that show up in `nix-env -qa`. ++ /// Print all matches, not only print from packages that show up in `nix-env -qa`. + #[clap(long)] +- top_level: bool, ++ all: bool, + + /// Only print matches for files that have this type. If the option is given multiple times, + /// a file will be printed if it has any of the given types.