forked from rubyforgood/casa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
97 lines (85 loc) · 2.63 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
{
description = "A Ruby dev environment for Casa Development";
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";
inputs.nixpkgs.follows = "nixpkgs";
};
bundix = {
url = "github:inscapist/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
fu.url = "github:numtide/flake-utils";
bob-ruby = {
url = "github:bobvanderlinden/nixpkgs-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;
gemset =
if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-3.2.2";
bundixcli = bundix.packages.${system}.default;
in rec {
inherit (rubyNix {
inherit gemset ruby;
name = "ruby-env-casa";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env;
devShells = rec {
default = dev;
dev = pkgs.mkShell {
BUNDLE_PATH = "~/.gems";
shellHook = ''
export PS1='\n\[\033[1;34m\][💎:\w]\$\[\033[0m\] '
# Setup postgres database
export PGHOST=$HOME/postgres
export PGDATA=$PGHOST/data
export PGDATABASE=postgres
export PGLOG=$PGHOST/postgres.log
mkdir -p $PGHOST
if [ ! -d $PGDATA ]; then
initdb --auth=trust --no-locale --encoding=UTF8
fi
if ! pg_ctl status
then
pg_ctl start -l $PGLOG -o "--unix_socket_directories='$PGHOST'"
fi
'';
buildInputs = [
env
pkgs.bundix
pkgs.bundler-audit
pkgs.direnv
pkgs.git
pkgs.gnumake
pkgs.libpcap
pkgs.libpqxx
pkgs.libxml2
pkgs.libxslt
pkgs.nodejs-18_x
pkgs.pkg-config
pkgs.postgresql
pkgs.sqlite
pkgs.yarn
];
};
};
});
}