-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby.nix
65 lines (61 loc) · 1.64 KB
/
ruby.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
{ flake-utils, gitignore, devshell, nix-filter }: { nixpkgs, dir, name, version }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
gems = pkgs.bundlerEnv {
name = "gems-for-github-linguist";
gemdir = dir;
};
in
{
# here's a good dev shell with all gems compiled
devShells.default = pkgs.devshell.mkShell {
packages = with pkgs; [
bundix
openssl
#gems
#gems.wrappedRuby
];
commands = [
{
name = "update-deps";
help = "Update ruby gems";
command = ''
bundix
'';
}
];
};
# this package includes our ruby application with pre-compiled gems
packages.default = pkgs.stdenv.mkDerivation {
inherit version;
pname = name;
src = nix-filter.lib {
root = dir;
include = [ (nix-filter.lib.matchExt "rb") ];
};
buildInputs = [ gems pkgs.ruby ];
installPhase = ''
mkdir -p $out/{bin,share}
cp -r ./*.rb $out/share
bin=$out/bin/entrypoint
cat > $bin <<EOF
#!${pkgs.bash}/bin/bash -e
exec ${gems}/bin/bundle exec ${pkgs.ruby}/bin/ruby $out/share/main.rb "\$@"
EOF
chmod +x $bin
'';
meta = {
mainProgram = "entrypoint";
};
};
# if we just want to distribute a binary from another gem (no ruby code of our own), this would do it!
packages.just-app = pkgs.bundlerApp {
pname = "github-linguist";
gemdir = dir;
exes = [ "github-linguist" ];
};
})