Skip to content

Commit

Permalink
nix - increase compatibility for command-not-found
Browse files Browse the repository at this point in the history
- fallback to `nix-index` on darwin
- also simulate `command-not-found` with alias
  • Loading branch information
ryuheechul committed Apr 24, 2023
1 parent c1e117e commit 333f22e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nix/home/programs/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, ... }:

let
shells = import ./shells.nix { config = config; };
shells = import ./shells.nix { config = config; pkgs = pkgs; };
terminals = import ./terminals.nix { pkgs = pkgs; };
in
{
Expand Down
14 changes: 11 additions & 3 deletions nix/home/programs/shells.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, ... }:
{ config, pkgs, ... }:

let
env-vars = config.home.sessionVariables;
Expand All @@ -20,7 +20,7 @@ in
# I don't like that these goes after $PATH not before - let me think about a workaround
# and of course the related issues can be found here! - https://github.com/nix-community/home-manager/issues/3324
home.sessionPath = [
"$XDG_CONFIG_HOME/dfs-rhc/bin/path/default"
''''${XDG_CONFIG_HOME}/dfs-rhc/bin/path/default''
];

# only the super basic ones that should be shared across shells
Expand All @@ -30,7 +30,15 @@ in
printpath = ''echo ''${PATH} | tr ":" "\n"'';
};

programs.command-not-found.enable = true;
programs.command-not-found = {
enable = ! pkgs.stdenv.isDarwin;
};

# fallback to nix-index on darwin in place of command-not-found
# https://github.com/bennofs/nix-index#usage-as-a-command-not-found-replacement
programs.nix-index = {
enable = pkgs.stdenv.isDarwin;
};

programs.bash = {
# https://nix-community.github.io/home-manager/options.html#opt-programs.bash.enable
Expand Down
3 changes: 3 additions & 0 deletions zsh/my_addons/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,6 @@ inspect-home-manager ()
}

alias inspect-bash='/bin/bash -lixc exit 2>&1 | sed -n "s/^+* \(source\|\.\) //p"' # via https://stackoverflow.com/a/65922714/1570165

# mimic `command-not-found` via `nix-index` shell hook when it's not available
test -z "${commands[command-not-found]}" && alias command-not-found='bash -ic '

0 comments on commit 333f22e

Please sign in to comment.