blob: 0f74a39add637e4f07cd9dd89756367e4711b1c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
{ lib
, stdenv
, ruby
, bundlerEnv
, buildPackages
, fetchFromGitHub
, makeBinaryWrapper
, nixosTests
, callPackage
}:
stdenv.mkDerivation (finalAttrs:
let
# Use bundlerEnvArgs from passthru to allow overriding bundlerEnv arguments.
rubyEnv = bundlerEnv finalAttrs.passthru.bundlerEnvArgs;
# We also need a separate nativeRubyEnv to precompile assets on the build
# host. If possible, reuse existing rubyEnv derivation.
nativeRubyEnv =
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then rubyEnv
else buildPackages.bundlerEnv finalAttrs.passthru.bundlerEnvArgs;
bundlerEnvArgs = {
name = "${finalAttrs.pname}-${finalAttrs.version}-gems";
gemdir = ./.;
};
in
{
pname = "pghero";
version = "3.5.0";
src = fetchFromGitHub {
owner = "pghero";
repo = "pghero";
rev = "v${finalAttrs.version}";
hash = "sha256-6JShYn3QfxPdAVcrJ7/kxzxa4dBEzSkUiLguIH+VCRQ=";
};
strictDeps = true;
nativeBuildInputs = [ nativeRubyEnv makeBinaryWrapper ];
inherit rubyEnv;
buildPhase = ''
runHook preBuild
DATABASE_URL=nulldb:/// RAILS_ENV=production rake assets:precompile
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p -- "$out"/{share,bin}
cp -a -- . "$out"/share/pghero
makeWrapper "$rubyEnv"/bin/puma "$out"/bin/pghero \
--add-flags -C \
--add-flags config/puma.rb \
--chdir "$out"/share/pghero
runHook postInstall
'';
passthru = {
inherit bundlerEnvArgs;
updateScript = callPackage ./update.nix { };
tests = {
inherit (nixosTests) pghero;
};
};
meta = {
homepage = "https://github.com/ankane/pghero";
description = "Performance dashboard for Postgres";
mainProgram = "pghero";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.tie ];
};
})
|