mirror of
https://github.com/nix-community/comma.git
synced 2024-09-11 12:05:28 +03:00
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
This commit is contained in:
parent
67f26046b9
commit
cd0f4852ea
12
,
12
,
@ -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
|
||||
|
@ -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
default.nix
33
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
|
||||
|
||||
|
@ -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 {});
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
|
||||
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
|
||||
''
|
Loading…
Reference in New Issue
Block a user