-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
56 lines (49 loc) · 1.44 KB
/
flake.nix
File metadata and controls
56 lines (49 loc) · 1.44 KB
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
{
description = "Dev shell with Nix-managed Bundler 4";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Define Bundler 4 as a direct input
bundler-pkg = {
url = "https://rubygems.org/downloads/bundler-4.0.8.gem";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
bundler-pkg,
}:
let
system = "x86_64-linux"; # or "aarch64-linux", etc.
pkgs = import nixpkgs { inherit system; };
# Override the default bundler with our input
bundler4 = pkgs.bundler.overrideAttrs (old: {
pname = "bundler";
version = "4.0.8";
src = pkgs.runCommand "bundler-4.0.8.gem" {} ''
cp ${bundler-pkg} $out
'';
});
in
{
devShells.${system}.default = pkgs.mkShell {
buildInputs = [
pkgs.ruby_3_4
bundler4
];
shellHook = ''
# Isolate gems to the local project and add their binaries to PATH
export GEM_HOME="$PWD/.gem"
export GEM_PATH="$GEM_HOME:$GEM_PATH"
export PATH="$GEM_HOME/bin:$PATH"
echo "Environment loaded: $(bundle --version) (Managed by Nix)"
# Automatically install missing gems if Gemfile.lock doesn't match local .gem/
bundle check >/dev/null 2>&1 || {
echo "Gems are missing or out of date. Running bundle install..."
bundle install
}
'';
};
};
}