-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathflake.nix
84 lines (62 loc) · 2.17 KB
/
flake.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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
# cross-platform convenience
flake-utils.url = "github:numtide/flake-utils";
# backwards compatibility with nix-build and nix-shell
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = { self, nixpkgs, flake-utils, flake-compat }:
# resolve for all platforms in turn
flake-utils.lib.eachDefaultSystem (system:
let
# packages for this system platform
pkgs = nixpkgs.legacyPackages.${system};
# control versions
ruby = pkgs.ruby_3_4;
llvm = pkgs.llvmPackages_19;
gcc = pkgs.gcc14;
hook = ''
# get major.minor.0 ruby version
export RUBY_VERSION="$(ruby -e 'puts RUBY_VERSION.gsub(/\d+$/, "0")')"
# make gem install work in-project, compatibly with bundler
export GEM_HOME="$(pwd)/vendor/bundle/ruby/$RUBY_VERSION"
# make bundle work in-project
export BUNDLE_PATH="$(pwd)/vendor/bundle"
# enable calling gem scripts without bundle exec
export PATH="$GEM_HOME/bin:$PATH"
# enable implicitly resolving gems to bundled version
export RUBYGEMS_GEMDEPS="$(pwd)/Gemfile"
'';
deps = [
pkgs.libyaml.dev
# TODO: some gems insist on using `gcc` on Linux, satisfy them for now:
# - json
# - protobuf
# - ruby-prof
gcc
];
in {
devShells.default = llvm.stdenv.mkDerivation {
name = "devshell";
buildInputs = [ ruby ] ++ deps;
shellHook = hook;
};
devShells.ruby33 = llvm.stdenv.mkDerivation {
name = "devshell";
buildInputs = [ pkgs.ruby_3_3 ] ++ deps;
shellHook = hook;
};
devShells.ruby32 = llvm.stdenv.mkDerivation {
name = "devshell";
buildInputs = [ pkgs.ruby_3_2 ] ++ deps;
shellHook = hook;
};
devShells.ruby31 = llvm.stdenv.mkDerivation {
name = "devshell";
buildInputs = [ pkgs.ruby_3_1 ] ++ deps;
shellHook = hook;
};
}
);
}