From 53f007f48a5a45aa85bf47fb4e4247559cf9b368 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 4 Dec 2023 12:34:44 +0100 Subject: [PATCH] feat: add flake-friendly nix-index overlay See: https://github.com/nix-community/nix-index/pull/227 --- modules/terminal-life/bash/default.nix | 2 +- modules/terminal-life/default.nix | 4 ++++ overlays/default.nix | 1 + overlays/nix-index.nix | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 overlays/nix-index.nix diff --git a/modules/terminal-life/bash/default.nix b/modules/terminal-life/bash/default.nix index 6df4aa09..df9ee43a 100644 --- a/modules/terminal-life/bash/default.nix +++ b/modules/terminal-life/bash/default.nix @@ -24,7 +24,7 @@ in { PROMPT_COMMAND='echo -e -n "\e]2;$(basename "$PWD" | sed "s/${psCfg.user.name}/~/")\e\\"' # If a command is not found, show me where it is - source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh + source ${pkgs.nix-index}/etc/profile.d/command-not-found.bash # Helps you navigate directories faster # https://github.com/gsamokovarov/jump diff --git a/modules/terminal-life/default.nix b/modules/terminal-life/default.nix index ceddc62e..43ed55a8 100644 --- a/modules/terminal-life/default.nix +++ b/modules/terminal-life/default.nix @@ -21,6 +21,10 @@ in { config = { programs.command-not-found.enable = false; + programs.nix-index.enable = true; + # We do this manually in modules/terminal-life/bash/default.nix + # until https://github.com/nix-community/nix-index/pull/227 is merged + programs.nix-index.enableBashIntegration = false; users.users."${psCfg.user.name}".packages = with pkgs; [ ack diff --git a/overlays/default.nix b/overlays/default.nix index 51a63c51..20240edd 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -27,6 +27,7 @@ (import ../pkgs) (import ./blesh.nix) (import ./mdbook-multilang.nix inputs) + (import ./nix-index.nix) (import ./prr.nix) (import ./neovim-plugins.nix) (import ./element-desktop.nix) diff --git a/overlays/nix-index.nix b/overlays/nix-index.nix new file mode 100644 index 00000000..2d915648 --- /dev/null +++ b/overlays/nix-index.nix @@ -0,0 +1,24 @@ +final: prev: { + nix-index-unwrapped = prev.nix-index-unwrapped.overrideAttrs (oldAttrs: rec { + inherit (oldAttrs) pname; + src = prev.fetchFromGitHub { + owner = "teutat3s"; + repo = "nix-index"; + rev = "e2d1917f474083f6d5a2c3368a6073f6427c19e4"; + hash = "sha256-3nTphxyqI6Hci7yJ2bKLcgdRl2qOY3BzUqoIl1YmmsA="; + }; + version = "unstable-2023-11-25"; + + cargoDeps = oldAttrs.cargoDeps.overrideAttrs (prev.lib.const { + name = "${pname}-vendor.tar.gz"; + inherit src; + outputHash = "sha256-x4oejbS1/L3WkN2S6PzvJni9UasRTP3TVVp3Ur9ge8U="; + }); + + postInstall = '' + substituteInPlace etc/command-not-found.* \ + --subst-var out + install -Dm444 etc/command-not-found.* -t $out/etc/profile.d + ''; + }); +}