nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchFromGitHub,
6 installShellFiles,
7 pkg-config,
8 alsa-lib,
9 versionCheckHook,
10 bacon,
11 buildPackages,
12 nix-update-script,
13
14 withSound ? false,
15}:
16
17let
18 soundDependencies =
19 lib.optionals stdenv.hostPlatform.isLinux [
20 alsa-lib
21 ]
22 ++ lib.optionals stdenv.hostPlatform.isDarwin [
23 # bindgenHook is only included on darwin as it is needed to build `coreaudio-sys`, a darwin-specific crate
24 rustPlatform.bindgenHook
25 ];
26in
27
28rustPlatform.buildRustPackage (finalAttrs: {
29 pname = "bacon";
30 version = "3.22.0";
31
32 src = fetchFromGitHub {
33 owner = "Canop";
34 repo = "bacon";
35 tag = "v${finalAttrs.version}";
36 hash = "sha256-eHMpzFKweKGI0REPudyy4veFTXDZc+AX626ylSN2yvU=";
37 };
38
39 cargoHash = "sha256-nUO9xVQ51dNWB5fxDZBLlzOWNE5HDAh6xYa5OdBPr4M=";
40
41 buildFeatures = lib.optionals withSound [
42 "sound"
43 ];
44
45 nativeBuildInputs = [
46 installShellFiles
47 ]
48 ++ lib.optionals withSound [
49 pkg-config
50 ];
51
52 buildInputs = lib.optionals withSound soundDependencies;
53
54 nativeInstallCheckInputs = [ versionCheckHook ];
55 doInstallCheck = true;
56
57 postInstall =
58 let
59 bacon = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/bacon";
60 in
61 lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
62 installShellCompletion --cmd bacon \
63 --bash <(COMPLETE=bash ${bacon}) \
64 --fish <(COMPLETE=fish ${bacon}) \
65 --zsh <(COMPLETE=zsh ${bacon})
66 '';
67
68 passthru = {
69 tests = {
70 withSound = bacon.override { withSound = true; };
71 };
72 updateScript = nix-update-script { };
73 };
74
75 meta = {
76 description = "Background rust code checker";
77 mainProgram = "bacon";
78 homepage = "https://github.com/Canop/bacon";
79 changelog = "https://github.com/Canop/bacon/blob/${finalAttrs.src.tag}/CHANGELOG.md";
80 license = lib.licenses.agpl3Only;
81 maintainers = with lib.maintainers; [
82 FlorianFranzen
83 matthiasbeyer
84 ];
85 };
86})