2024-02-29 20:09:43 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
version = "0.6.8";
|
|
|
|
pname = "nix-bash-completions";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "hedning";
|
|
|
|
repo = "nix-bash-completions";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1n5zs6xcnv4bv1hdaypmz7fv4j7dsr4a0ifah99iyj4p5j85i1bc";
|
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
patches = [
|
|
|
|
# Fix improper escaping: https://github.com/NixOS/nixpkgs/issues/284162
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/hedning/nix-bash-completions/pull/28/commits/ef2055aa28754fa9e009bbfebc1491972e4f4e67.patch";
|
|
|
|
hash = "sha256-TRkHrk7bX7DX0COzzYR+1pgTqLy7J55BcejNjRwthII=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Nix 2.4+ provides its own completion for the nix command, see https://github.com/hedning/nix-bash-completions/issues/20
|
2023-11-16 04:20:00 +00:00
|
|
|
# NixOS provides its own completions for nixos-rebuild now.
|
|
|
|
substituteInPlace _nix \
|
|
|
|
--replace 'nix nixos-option' 'nixos-option' \
|
|
|
|
--replace 'nixos-rebuild nixos-install' 'nixos-install'
|
2023-01-11 07:51:40 +00:00
|
|
|
'';
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
strictDeps = true;
|
2023-01-11 07:51:40 +00:00
|
|
|
# To enable lazy loading via bash-completion we need a symlink to the script
|
2020-04-24 23:36:52 +00:00
|
|
|
# from every command name.
|
|
|
|
installPhase = ''
|
2022-02-20 05:27:41 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
commands=$(
|
|
|
|
function complete() { shift 2; echo "$@"; }
|
|
|
|
shopt -s extglob
|
|
|
|
source _nix
|
|
|
|
)
|
|
|
|
install -Dm444 -t $out/share/bash-completion/completions _nix
|
|
|
|
cd $out/share/bash-completion/completions
|
|
|
|
for c in $commands; do
|
|
|
|
ln -s _nix $c
|
|
|
|
done
|
2022-02-20 05:27:41 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/hedning/nix-bash-completions";
|
|
|
|
description = "Bash completions for Nix, NixOS, and NixOps";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.all;
|
2023-01-11 07:51:40 +00:00
|
|
|
maintainers = with maintainers; [ hedning ncfavier ];
|
|
|
|
# Set a lower priority such that Nix wins in case of conflicts.
|
2021-12-06 16:07:01 +00:00
|
|
|
priority = 10;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|