Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove prebuilt cache #18

Merged
merged 1 commit into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions ,
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@ 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
@OVERLAY_PACKAGES@)
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
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 0 additions & 33 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,21 @@
, 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:
# Was the command `, mything`? Run `nixpkgs.mything`.
, 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
Expand All @@ -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

Expand Down
8 changes: 0 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {});
};
});
};
}
27 changes: 0 additions & 27 deletions update-index.nix

This file was deleted.