-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
104 lines (93 loc) · 3.06 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
94
95
96
97
98
99
100
101
102
103
104
{
description = "trade-tariff-duty-calculator";
nixConfig = {
extra-substituters = "https://nixpkgs-ruby.cachix.org";
extra-trusted-public-keys = "nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?rev=205fd4226592cc83fd4c0885a3e4c9c400efabb5"; #
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 ];
config.allowUnfree = true;
};
rubyNix = ruby-nix.lib pkgs;
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 = { };
# Read Ruby version from the .ruby-version file
rubyVersion = builtins.readFile ./.ruby-version;
# Remove newline or extra whitespace characters
sanitizedRubyVersion = builtins.substring 0 (builtins.stringLength rubyVersion - 1) rubyVersion;
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-${sanitizedRubyVersion}";
# 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
'';
chrome = pkgs.writeShellScriptBin "chrome" ''
binary=$(find ${pkgs.google-chrome.outPath} -type f -name 'google-chrome-stable')
exec $binary "$@"
'';
in
rec {
inherit
(rubyNix {
inherit gemset ruby;
name = "trade-tariff-duty-calculator";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env
;
devShells = rec {
default = dev;
dev = pkgs.mkShell {
buildInputs =
[
env
bundixcli
bundleLock
bundleUpdate
chrome
]
++ (with pkgs; [
yarn
rufo
google-chrome
]);
};
};
}
);
}