-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
57 lines (46 loc) · 1.65 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
# 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_3;
llvm = pkgs.llvmPackages_16;
gcc = pkgs.gcc13;
in {
devShell = pkgs.llvm.stdenv.mkDerivation {
name = "devshell";
buildInputs = with pkgs; [
ruby
libyaml.dev
# TODO: some gems insist on using `gcc` on Linux, satisfy them for now:
# - json
# - protobuf
# - ruby-prof
gcc
];
shellHook = ''
# 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"
'';
};
}
);
}