forked from arch-community/qbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
84 lines (69 loc) · 1.96 KB
/
default.nix
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
75
76
77
78
79
80
81
82
83
84
{ stdenv, lib, symlinkJoin, makeWrapper
, pkg-config, git
, ruby_3_0, bundler, bundix, defaultGemConfig, bundlerEnv
, libsodium, libopus, ffmpeg, youtube-dl
, imagemagick7, pango
, sqlite, zlib, shared-mime-info, libxml2, libiconv
, figlet }:
let
ruby' = ruby_3_0;
bundler' = bundler.override { ruby = ruby'; };
bundix' = bundix.override { bundler = bundler'; };
bundlerEnv' = bundlerEnv.override {
ruby = ruby';
bundler = bundler';
};
imagemagick7' = imagemagick7.overrideAttrs (oa: with oa; {
buildInputs = oa.buildInputs ++ [ pango ];
});
env = bundlerEnv' {
name = "qbot-bundler-env";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
gemdir = ./.;
ruby = ruby';
bundler = bundler';
gemConfig = defaultGemConfig // {
nokogiri = attrs: {
buildInputs = [ pkg-config zlib.dev ];
};
mimemagic = attrs: {
FREEDESKTOP_MIME_TYPES_PATH = "${shared-mime-info}/share/mime/packages/freedesktop.org.xml";
};
rmagick = attrs: {
buildInputs = [ pkg-config imagemagick7' ];
};
};
};
in stdenv.mkDerivation rec {
name = "qbot";
src = builtins.filterSource
(path: type:
type != "directory" ||
baseNameOf path != "vendor" &&
baseNameOf path != ".git" &&
baseNameOf path != ".bundle")
./.;
buildInputs = [
env bundix' git
sqlite libxml2 zlib.dev zlib libiconv
libopus libsodium ffmpeg youtube-dl
imagemagick7'
];
LD_LIBRARY_PATH = lib.makeLibraryPath [ libsodium libopus ];
FONTCONFIG_FILE = "${src}/lib/resources/tokipona/fc-config.xml";
installPhase = ''
mkdir -p $out/{bin,share/qbot}
cp -r * $out/share/qbot
bin=$out/bin/qbot
cat >$bin <<EOF
#!/bin/sh -e
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export FONTCONFIG_FILE=${FONTCONFIG_FILE}
cd $out/share/qbot
exec ${env}/bin/bundle exec ${env.wrappedRuby}/bin/ruby $out/share/qbot/qbot "\$@"
EOF
chmod +x $bin
'';
}