Use nix-locate for command-not-found

This commit is contained in:
Zuckerberg 2022-05-16 15:01:15 -04:00
parent 63902fcb46
commit 9fc6f816fb
4 changed files with 72 additions and 6 deletions

View File

@ -1,6 +1,8 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ let
nix-locate = config.inputs.nix-locate.defaultPackage.${config.currentSystem};
in {
imports = [ imports = [
./flakes.nix ./flakes.nix
./pia.nix ./pia.nix
@ -43,6 +45,7 @@
micro micro
helix helix
lm_sensors lm_sensors
nix-locate
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@ -63,8 +66,25 @@
nix.gc.automatic = true; nix.gc.automatic = true;
programs.fish.enable = true; programs.command-not-found.enable = false;
programs.fish.shellInit = ''
programs.fish = {
enable = true;
shellInit = let
wrapper = pkgs.writeScript "command-not-found" ''
#!${pkgs.bash}/bin/bash
source ${nix-locate}/etc/profile.d/command-not-found.sh
command_not_found_handle "$@"
'';
in ''
# use nix-locate for command-not-found functionality
function __fish_command_not_found_handler --on-event fish_command_not_found
${wrapper} $argv
end
# disable annoying fish shell greeting
set fish_greeting set fish_greeting
''; '';
};
} }

View File

@ -16,6 +16,9 @@ in {
# pin nixpkgs for system commands such as "nix shell" # pin nixpkgs for system commands such as "nix shell"
registry.nixpkgs.flake = config.inputs.nixpkgs; registry.nixpkgs.flake = config.inputs.nixpkgs;
# pin system nixpkgs to the same version as the flake input
nixPath = [ "nixpkgs=${config.inputs.nixpkgs}" ];
}; };
}; };
} }

38
flake.lock generated
View File

@ -82,6 +82,22 @@
"url": "https://git.neet.dev/zuckerberg/dailybuild_modules.git" "url": "https://git.neet.dev/zuckerberg/dailybuild_modules.git"
} }
}, },
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1648297722, "lastModified": 1648297722,
@ -97,6 +113,27 @@
"type": "github" "type": "github"
} }
}, },
"nix-locate": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1647808006,
"narHash": "sha256-aBlJcylH7/MDiu0RVEiUwV1XufGfVk4OvsFutImCszY=",
"owner": "bennofs",
"repo": "nix-index",
"rev": "e7c66ba52fcfba6bfe51adb5400c29a9622664a2",
"type": "github"
},
"original": {
"owner": "bennofs",
"repo": "nix-index",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1649117019, "lastModified": 1649117019,
@ -191,6 +228,7 @@
"archivebox": "archivebox", "archivebox": "archivebox",
"dailybuild_modules": "dailybuild_modules", "dailybuild_modules": "dailybuild_modules",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nix-locate": "nix-locate",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"radio": "radio", "radio": "radio",

View File

@ -5,6 +5,9 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
nix-locate.url = "github:bennofs/nix-index";
nix-locate.inputs.nixpkgs.follows = "nixpkgs";
# mail server # mail server
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-21.11"; simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-21.11";
simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs"; simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs";
@ -43,7 +46,9 @@
inputs.dailybuild_modules.nixosModule inputs.dailybuild_modules.nixosModule
inputs.archivebox.nixosModule inputs.archivebox.nixosModule
({ lib, ... }: { ({ lib, ... }: {
config.environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ]; config.environment.systemPackages = [
inputs.agenix.defaultPackage.${system}
];
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way # because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
options.inputs = lib.mkOption { default = inputs; }; options.inputs = lib.mkOption { default = inputs; };