mirror of
https://github.com/nix-community/comma.git
synced 2024-09-11 12:05:28 +03:00
60a4cf8ec5
The nix-index database offered in the derivation may be more out of date than what is present on the system. In fact, prefer any local nix-index database to the prebuilt database included with comma
59 lines
1.6 KiB
Nix
59 lines
1.6 KiB
Nix
{ pkgs ? import <nixpkgs> { }
|
|
|
|
, 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
|
|
, 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
|
|
|
|
# nix-index takes a little while to run and the contents don't change
|
|
# meaningfully very often. This is generated by running `nix-index` and
|
|
# uploading `~/.cache/nix-index/files` to, well, anywhere.
|
|
indexCache = fetchurl {
|
|
url = "https://s3.amazonaws.com/burkelibbey/nix-index-files";
|
|
sha256 = "06p58f82wipd0a8wbc7j3l0p8iaxvdibgshmc9dbxkjf0hmln3kx";
|
|
};
|
|
|
|
# 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
|
|
caseCondition = lib.concatStringsSep "|" (overlayPackages ++ [ "--placeholder--" ]);
|
|
in ''
|
|
mkdir -p $out/bin
|
|
sed -e 's/@OVERLAY_PACKAGES@/${caseCondition}/' < , > $out/bin/,
|
|
chmod +x $out/bin/,
|
|
wrapProgram $out/bin/, \
|
|
--set PREBUILT_NIX_INDEX_DB ${nixIndexDB} \
|
|
--prefix PATH : ${nix-index}/bin \
|
|
--prefix PATH : ${nix}/bin \
|
|
--prefix PATH : ${fzy}/bin
|
|
|
|
ln -s $out/bin/, $out/bin/comma
|
|
'';
|
|
}
|