-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
93 lines (84 loc) · 2.5 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
85
86
87
88
89
90
91
92
93
{
description = "A simple ruby app demo";
nixConfig = {
extra-substituters = "https://nixpkgs-ruby.cachix.org";
extra-trusted-public-keys = "nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
};
inputs = {
nixpkgs.url = "nixpkgs";
ruby-nix.url = "github:inscapist/ruby-nix";
# a fork that supports platform dependant gem
bundix = {
url = "github:inscapist/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
fu.url = "github:numtide/flake-utils";
bob-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
bob-ruby.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
fu,
ruby-nix,
bundix,
bob-ruby,
}:
with fu.lib;
eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ bob-ruby.overlays.default ];
};
rubyNix = ruby-nix.lib pkgs;
# TODO generate gemset.nix with bundix
gemset = if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };
# If you want to override gem build config, see
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix
gemConfig = { };
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-3.3.1";
# Running bundix would regenerate `gemset.nix`
bundixcli = bundix.packages.${system}.default;
# Use these instead of the original `bundle <mutate>` commands
bundleLock = pkgs.writeShellScriptBin "bundle-lock" ''
export BUNDLE_PATH=vendor/bundle
bundle lock
'';
bundleUpdate = pkgs.writeShellScriptBin "bundle-update" ''
export BUNDLE_PATH=vendor/bundle
bundle lock --update
'';
in
rec {
inherit
(rubyNix {
inherit gemset ruby;
name = "my-rails-app";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env
;
devShells = rec {
default = dev;
dev = pkgs.mkShell {
buildInputs =
[
env
bundixcli
bundleLock
bundleUpdate
]
++ (with pkgs; [
yarn
rufo
# more packages here
]);
};
};
}
);
}