forked from the-nix-way/nix-flake-dev-environments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
68 lines (59 loc) · 1.9 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
{
description = "Ruby on Rails development environment";
inputs = {
nixpkgs.url = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
};
outputs = { self, nixpkgs, flake-utils, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
(self: super: {
ruby = pkgs.ruby_3_1;
})
];
pkgs = import nixpkgs { inherit overlays system; };
rubyEnv = pkgs.bundlerEnv {
# The full app environment with dependencies
name = "rails-env";
inherit (pkgs) ruby;
gemdir = ./.; # Points to Gemfile.lock and gemset.nix
};
updateDeps = pkgs.writeScriptBin "update-deps" (builtins.readFile
(pkgs.substituteAll {
src = ./scripts/update.sh;
bundix = "${pkgs.bundix}/bin/bundix";
bundler = "${rubyEnv.bundler}/bin/bundler";
}));
in
{
apps.default = {
type = "app";
program = "${rubyEnv}/bin/rails";
};
devShells = rec {
default = run;
run = pkgs.mkShell {
buildInputs = [ rubyEnv rubyEnv.wrappedRuby updateDeps ];
shellHook = ''
${rubyEnv}/bin/rails --version
'';
};
};
packages = {
default = rubyEnv;
docker = pkgs.dockerTools.buildImage {
name = "rails-app";
tag = "latest";
fromImage = pkgs.dockerTools.pullImage {
imageName = "ubuntu";
finalImageTag = "20.04";
imageDigest = "sha256:a06ae92523384c2cd182dcfe7f8b2bf09075062e937d5653d7d0db0375ad2221";
sha256 = "sha256-d249m1ZqcV72jfEcHDUn+KuOCs8WPaBJRcZotJjVW0o=";
};
config.Cmd = [ "${rubyEnv}/bin/bundler" ];
};
};
});
}