nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 comma,
3 fetchFromGitHub,
4 installShellFiles,
5 fzy,
6 lib,
7 nix-index-unwrapped,
8 nix,
9 rustPlatform,
10 testers,
11}:
12
13rustPlatform.buildRustPackage rec {
14 pname = "comma";
15 version = "2.3.3";
16
17 src = fetchFromGitHub {
18 owner = "nix-community";
19 repo = "comma";
20 rev = "v${version}";
21 hash = "sha256-dNek1a8Yt3icWc8ZpVe1NGuG+eSoTDOmAAJbkYmMocU=";
22 };
23
24 cargoHash = "sha256-SJBfWjOVrv2WMIh/cQbaFK8jn3oSbmJpdJM7pkJppDs=";
25
26 nativeBuildInputs = [ installShellFiles ];
27
28 postPatch = ''
29 substituteInPlace ./src/main.rs \
30 --replace-fail '"nix-locate"' '"${lib.getExe' nix-index-unwrapped "nix-locate"}"' \
31 --replace-fail '"nix"' '"${lib.getExe nix}"' \
32 --replace-fail '"nix-env"' '"${lib.getExe' nix "nix-env"}"' \
33 --replace-fail '"fzy"' '"${lib.getExe fzy}"'
34 '';
35
36 postInstall = ''
37 ln -s $out/bin/comma $out/bin/,
38
39 mkdir -p $out/share/comma
40
41 cp $src/etc/command-not-found.sh $out/share/comma
42 cp $src/etc/command-not-found.nu $out/share/comma
43 cp $src/etc/command-not-found.fish $out/share/comma
44
45 patchShebangs $out/share/comma/command-not-found.sh
46 substituteInPlace \
47 "$out/share/comma/command-not-found.sh" \
48 "$out/share/comma/command-not-found.nu" \
49 "$out/share/comma/command-not-found.fish" \
50 --replace-fail "comma --ask" "$out/bin/comma --ask"
51
52 "$out/bin/comma" --mangen > comma.1
53 installManPage comma.1
54 '';
55
56 passthru.tests = {
57 version = testers.testVersion { package = comma; };
58 };
59
60 meta = with lib; {
61 homepage = "https://github.com/nix-community/comma";
62 description = "Runs programs without installing them";
63 license = licenses.mit;
64 mainProgram = "comma";
65 maintainers = with maintainers; [ artturin ];
66 };
67}