mirror of
https://github.com/nix-community/comma.git
synced 2024-09-11 12:05:28 +03:00
Merge pull request #7 from fzakaria/check-local-index
This commit is contained in:
commit
cc48cc9b40
9
,
9
,
@ -18,6 +18,13 @@ else
|
|||||||
install=""
|
install=""
|
||||||
fi
|
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
|
argv0=$1; shift
|
||||||
|
|
||||||
case "${argv0}" in
|
case "${argv0}" in
|
||||||
@ -25,7 +32,7 @@ case "${argv0}" in
|
|||||||
attr="${argv0}"
|
attr="${argv0}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
attr="$(nix-locate --db "${NIX_INDEX_DB}" --top-level --minimal --at-root --whole-name "/bin/${argv0}")"
|
attr="$(nix-locate --db "${database}" --top-level --minimal --at-root --whole-name "/bin/${argv0}")"
|
||||||
if [[ "$(echo "${attr}" | wc -l)" -ne 1 ]]; then
|
if [[ "$(echo "${attr}" | wc -l)" -ne 1 ]]; then
|
||||||
attr="$(echo "${attr}" | fzy)"
|
attr="$(echo "${attr}" | fzy)"
|
||||||
fi
|
fi
|
||||||
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# ignore nix-build result folder
|
||||||
|
result
|
19
default.nix
19
default.nix
@ -8,6 +8,7 @@
|
|||||||
, fzy ? pkgs.fzy
|
, fzy ? pkgs.fzy
|
||||||
, makeWrapper ? pkgs.makeWrapper
|
, makeWrapper ? pkgs.makeWrapper
|
||||||
, runCommand ? pkgs.runCommand
|
, runCommand ? pkgs.runCommand
|
||||||
|
, linkFarm ? pkgs.linkFarm
|
||||||
|
|
||||||
# We use this to add matchers for stuff that's not in upstream nixpkgs, but is
|
# 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:
|
# in our own overlay. No fuzzy matching from multiple options here, it's just:
|
||||||
@ -27,19 +28,17 @@ let
|
|||||||
|
|
||||||
# nix-locate needs the --db argument to be a directory containing a file
|
# nix-locate needs the --db argument to be a directory containing a file
|
||||||
# named "files".
|
# named "files".
|
||||||
nixIndexDB = runCommand "nix-index-cache" {} ''
|
nixIndexDB = linkFarm "nix-index-cache" [
|
||||||
mkdir $out
|
{ name = "files"; path = indexCache; }
|
||||||
ln -s ${indexCache.out} $out/files
|
];
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "comma";
|
name = "comma";
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
buildInputs = [ nix-index.out nix.out fzy.out ];
|
buildInputs = [ nix-index nix fzy ];
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
installPhase = let
|
installPhase = let
|
||||||
@ -49,10 +48,10 @@ stdenv.mkDerivation rec {
|
|||||||
sed -e 's/@OVERLAY_PACKAGES@/${caseCondition}/' < , > $out/bin/,
|
sed -e 's/@OVERLAY_PACKAGES@/${caseCondition}/' < , > $out/bin/,
|
||||||
chmod +x $out/bin/,
|
chmod +x $out/bin/,
|
||||||
wrapProgram $out/bin/, \
|
wrapProgram $out/bin/, \
|
||||||
--set NIX_INDEX_DB ${nixIndexDB.out} \
|
--set PREBUILT_NIX_INDEX_DB ${nixIndexDB} \
|
||||||
--prefix PATH : ${nix-index.out}/bin \
|
--prefix PATH : ${nix-index}/bin \
|
||||||
--prefix PATH : ${nix.out}/bin \
|
--prefix PATH : ${nix}/bin \
|
||||||
--prefix PATH : ${fzy.out}/bin
|
--prefix PATH : ${fzy}/bin
|
||||||
|
|
||||||
ln -s $out/bin/, $out/bin/comma
|
ln -s $out/bin/, $out/bin/comma
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user