From cd0f4852eaac1adf26fadbc1dda4b98bc79d0f2c Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 15 Apr 2022 15:02:05 +0300 Subject: [PATCH] remove prebuilt cache it increases the closure size and limits the system we support in the future we can implement this better in the script --- , | 12 +----------- README.md | 5 +++++ default.nix | 33 --------------------------------- flake.nix | 8 -------- update-index.nix | 27 --------------------------- 5 files changed, 6 insertions(+), 79 deletions(-) delete mode 100644 update-index.nix diff --git a/, b/, index a07cd4d..a59571f 100755 --- a/, +++ b/, @@ -25,20 +25,10 @@ fi if [[ "$1" == "--install" ]] || [[ "$1" == "-i" ]]; then install=1 shift -elif [[ "$1" == "--update" ]] || [[ "$1" == "-u" ]]; then - ${UPDATE_SCRIPT} - exit else install="" fi -# if a nix-index exists locally; use that as it's likely much more recent -# than the prebuilt one. -database=$PREBUILT_NIX_INDEX_DB -if [ -f "${HOME}/.cache/nix-index/files" ]; then - database="${HOME}/.cache/nix-index" -fi - argv0=$1; shift case "${argv0}" in @@ -46,7 +36,7 @@ case "${argv0}" in attr="${argv0}" ;; *) - attr="$(nix-locate --db "${database}" --top-level --minimal --at-root --whole-name "/bin/${argv0}")" + attr="$(nix-locate --top-level --minimal --at-root --whole-name "/bin/${argv0}")" if [[ "$(echo "${attr}" | wc -l)" -ne 1 ]]; then attr="$(echo "${attr}" | "${picker}")" fi diff --git a/README.md b/README.md index e7a1596..849d656 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,8 @@ YouTube](https://www.youtube.com/watch?v=VUM3Km_4gUg&list=PLRGI9KQ3_HP_OFRG6R-p4 ```bash , cowsay neato ``` + + +## Prebuilt index + +https://github.com/Mic92/nix-index-database diff --git a/default.nix b/default.nix index 8e16a2b..5fe9a69 100644 --- a/default.nix +++ b/default.nix @@ -3,13 +3,9 @@ , stdenv ? pkgs.stdenv , lib ? pkgs.lib , fetchurl ? pkgs.fetchurl -, nix-index ? pkgs.nix-index , nix ? pkgs.nix , fzy ? pkgs.fzy , makeWrapper ? pkgs.makeWrapper -, runCommand ? pkgs.runCommand -, updateScript ? import ./update-index.nix { inherit pkgs; } -, linkFarm ? pkgs.linkFarm # We use this to add matchers for stuff that's not in upstream nixpkgs, but is # in our own overlay. No fuzzy matching from multiple options here, it's just: @@ -17,36 +13,11 @@ , overlayPackages ? [] }: -let - indexCaches = { - x86_64-linux = fetchurl { - url = "https://github.com/Mic92/nix-index-database/releases/download/2021-12-12/index-x86_64-linux"; - hash = "sha256-+SoG5Qz2KWA/nIWXE6SLpdi8MDqTs8LY90fGZxGKOiA="; - }; - - x86_64-darwin = fetchurl { - url = "https://github.com/Mic92/nix-index-database/releases/download/2022-02-27/index-x86_64-darwin"; - hash = "sha256-sHGUSjd6EOpzdWtS5FGtTkS9KEKvDCGMHTYVwxOkZIo="; - }; - }; - - # nix-index takes a little while to run and the contents don't change - # meaningfully very often. - indexCache = indexCaches.${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}"); - - # nix-locate needs the --db argument to be a directory containing a file - # named "files". - nixIndexDB = linkFarm "nix-index-cache" [ - { name = "files"; path = indexCache; } - ]; - -in stdenv.mkDerivation rec { name = "comma"; src = ./.; - buildInputs = [ nix-index nix fzy ]; nativeBuildInputs = [ makeWrapper ]; installPhase = let @@ -56,10 +27,6 @@ stdenv.mkDerivation rec { sed -e 's/@OVERLAY_PACKAGES@/${caseCondition}/' < , > $out/bin/, chmod +x $out/bin/, wrapProgram $out/bin/, \ - --set PREBUILT_NIX_INDEX_DB ${nixIndexDB} \ - --set NIXPKGS ${pkgs.path} \ - --set UPDATE_SCRIPT ${updateScript} \ - --prefix PATH : ${nix-index}/bin \ --prefix PATH : ${nix}/bin \ --prefix PATH : ${fzy}/bin diff --git a/flake.nix b/flake.nix index 8bf4926..01bb93f 100644 --- a/flake.nix +++ b/flake.nix @@ -19,18 +19,10 @@ (system: pkgs: { comma = import ./default.nix { inherit pkgs; - updateScript = apps."${system}".update-index.program; }; }); defaultPackage = forAllSystems (system: pkgs: packages."${system}".comma); - apps = forAllSystems - (system: pkgs: { - update-index = { - type = "app"; - program = b.toString (pkgs.callPackage ./update-index.nix {}); - }; - }); }; } diff --git a/update-index.nix b/update-index.nix deleted file mode 100644 index 47a89dc..0000000 --- a/update-index.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - pkgs ? import {}, - - coreutils ? pkgs.coreutils, - gnugrep ? pkgs.gnugrep, - lib ? pkgs.lib, - nix-index ? pkgs.nix-index, - writeScript ? pkgs.writeScript, -}: - -writeScript "update-index" '' - PATH=${lib.makeBinPath [ - coreutils - gnugrep - nix-index - ]} - - # on flake based installations nixpkgs is specified via - # flake input and therefore NIX_PATH might be unset - if echo $NIX_PATH | grep -q "nixpkgs="; then - nixpkgs="" - else - nixpkgs="-I nixpkgs=${pkgs.path}" - fi - - nix-index -d $HOME/.cache/nix-index -f $nixpkgs -''