From 9fc6f816fb6213c2846ce5c708e255d55d5895ba Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Mon, 16 May 2022 15:01:15 -0400 Subject: [PATCH] Use nix-locate for command-not-found --- common/default.nix | 30 +++++++++++++++++++++++++----- common/flakes.nix | 3 +++ flake.lock | 38 ++++++++++++++++++++++++++++++++++++++ flake.nix | 7 ++++++- 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/common/default.nix b/common/default.nix index 6048752..f7a71cf 100644 --- a/common/default.nix +++ b/common/default.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: -{ +let + nix-locate = config.inputs.nix-locate.defaultPackage.${config.currentSystem}; +in { imports = [ ./flakes.nix ./pia.nix @@ -43,6 +45,7 @@ micro helix lm_sensors + nix-locate ]; nixpkgs.config.allowUnfree = true; @@ -63,8 +66,25 @@ nix.gc.automatic = true; - programs.fish.enable = true; - programs.fish.shellInit = '' - set fish_greeting - ''; + programs.command-not-found.enable = false; + + 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 + ''; + }; } diff --git a/common/flakes.nix b/common/flakes.nix index d3e4d2e..f15c5c9 100644 --- a/common/flakes.nix +++ b/common/flakes.nix @@ -16,6 +16,9 @@ in { # pin nixpkgs for system commands such as "nix shell" registry.nixpkgs.flake = config.inputs.nixpkgs; + + # pin system nixpkgs to the same version as the flake input + nixPath = [ "nixpkgs=${config.inputs.nixpkgs}" ]; }; }; } diff --git a/flake.lock b/flake.lock index ea025ea..fae80fd 100644 --- a/flake.lock +++ b/flake.lock @@ -82,6 +82,22 @@ "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": { "locked": { "lastModified": 1648297722, @@ -97,6 +113,27 @@ "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": { "locked": { "lastModified": 1649117019, @@ -191,6 +228,7 @@ "archivebox": "archivebox", "dailybuild_modules": "dailybuild_modules", "flake-utils": "flake-utils", + "nix-locate": "nix-locate", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "radio": "radio", diff --git a/flake.nix b/flake.nix index 73aca48..16fce60 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,9 @@ flake-utils.url = "github:numtide/flake-utils"; + nix-locate.url = "github:bennofs/nix-index"; + nix-locate.inputs.nixpkgs.follows = "nixpkgs"; + # mail server simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-21.11"; simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs"; @@ -43,7 +46,9 @@ inputs.dailybuild_modules.nixosModule inputs.archivebox.nixosModule ({ 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 options.inputs = lib.mkOption { default = inputs; };