Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 fetchFromGitHub,
4 makeBinaryWrapper,
5 installShellFiles,
6 rustPlatform,
7 testers,
8 cachix,
9 nixVersions,
10 openssl,
11 dbus,
12 pkg-config,
13 glibcLocalesUtf8,
14 devenv, # required to run version test
15}:
16
17let
18 devenv_nix =
19 (nixVersions.git.overrideSource (fetchFromGitHub {
20 owner = "cachix";
21 repo = "nix";
22 rev = "031c3cf42d2e9391eee373507d8c12e0f9606779";
23 hash = "sha256-dOi/M6yNeuJlj88exI+7k154z+hAhFcuB8tZktiW7rg=";
24 })).overrideAttrs
25 (old: {
26 version = "2.30-devenv";
27 doCheck = false;
28 doInstallCheck = false;
29 # do override src, but the Nix way so the warning is unaware of it
30 __intentionallyOverridingVersion = true;
31 });
32
33 version = "1.8.1";
34in
35rustPlatform.buildRustPackage {
36 pname = "devenv";
37 inherit version;
38
39 src = fetchFromGitHub {
40 owner = "cachix";
41 repo = "devenv";
42 tag = "v${version}";
43 hash = "sha256-YsSFlVWUu4RSYnObqcBJ4Mr3bJVVhuFhaQAktHytBAI=";
44 };
45
46 cargoHash = "sha256-zJorGAsp5k5oBuXogYqEPVexcNsYCeiTmrQqySd1AGs=";
47
48 buildAndTestSubdir = "devenv";
49
50 nativeBuildInputs = [
51 installShellFiles
52 makeBinaryWrapper
53 pkg-config
54 ];
55
56 buildInputs = [
57 openssl
58 dbus
59 ];
60
61 postInstall =
62 let
63 setDefaultLocaleArchive = lib.optionalString (glibcLocalesUtf8 != null) ''
64 --set-default LOCALE_ARCHIVE ${glibcLocalesUtf8}/lib/locale/locale-archive
65 '';
66 in
67 ''
68 wrapProgram $out/bin/devenv \
69 --prefix PATH ":" "$out/bin:${cachix}/bin" \
70 --set DEVENV_NIX ${devenv_nix} \
71 ${setDefaultLocaleArchive}
72
73 # Generate manpages
74 cargo xtask generate-manpages --out-dir man
75 installManPage man/*
76
77 # Generate shell completions
78 compdir=./completions
79 for shell in bash fish zsh; do
80 cargo xtask generate-shell-completion $shell --out-dir $compdir
81 done
82
83 installShellCompletion --cmd devenv \
84 --bash $compdir/devenv.bash \
85 --fish $compdir/devenv.fish \
86 --zsh $compdir/_devenv
87 '';
88
89 passthru.tests = {
90 version = testers.testVersion {
91 package = devenv;
92 command = "export XDG_DATA_HOME=$PWD; devenv version";
93 };
94 };
95
96 meta = {
97 changelog = "https://github.com/cachix/devenv/releases/tag/v${version}";
98 description = "Fast, Declarative, Reproducible, and Composable Developer Environments";
99 homepage = "https://github.com/cachix/devenv";
100 license = lib.licenses.asl20;
101 mainProgram = "devenv";
102 maintainers = with lib.maintainers; [ domenkozar ];
103 };
104}