fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1# Adapted from Nixpkgs. 2 3{ config , lib , pkgs , ...} : 4 5with lib ; 6 7let 8cfg = config . programs . command-not-found ; 9commandNotFound = pkgs . substituteAll { 10name = "command-not-found" ; 11dir = "bin" ; 12src = ./command-not-found.pl ; 13isExecutable = true ; 14inherit ( cfg ) dbPath ; 15perl = pkgs . perl . withPackages ( p :[ p . DBDSQLite p . StringShellQuote ]); 16}; 17 18shInit = commandNotFoundHandlerName :'' 19# This function is called whenever a command is not found. 20${ commandNotFoundHandlerName } () { 21local p= ${ commandNotFound } /bin/command-not-found 22if [ -x $p -a -f ${ cfg . dbPath } ]; then 23# Run the helper program. 24$p "$@" 25else 26echo "$1: command not found" >&2 27return 127 28fi 29} 30'' ; 31 32in { 33options . programs . command-not-found = { 34enable = mkEnableOption "command-not-found hook for interactive shell" ; 35 36dbPath = mkOption { 37default = 38"/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ; 39description = '' 40Absolute path to {file}`programs.sqlite`. By 41default this file will be provided by your channel 42(nixexprs.tar.xz). 43'' ; 44type = types . path ; 45}; 46}; 47 48config = mkIf cfg . enable { 49programs . bash . initExtra = shInit "command_not_found_handle" ; 50programs . zsh . initExtra = shInit "command_not_found_handler" ; 51 52home . packages = [ commandNotFound ]; 53}; 54}