-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
101 lines (87 loc) · 2.89 KB
/
flake.nix
File metadata and controls
101 lines (87 loc) · 2.89 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
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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
# This makes shell scripts that will run on MacOS a bit easier to write
coreutils-prefixed
# Languages
ruby_3_4
nodejs_22
yarn
# Databases
sqlite
# Process Managers
hivemind
overmind
# Other
libyaml
pkg-config
git-lfs
];
shellHook = ''
set -e
project_root=$(greadlink -f .)
api_root=$project_root/api
web_root=$project_root/web
data_dir=$project_root/.local
bin_dir=$project_root/bin
storage_dir=$api_root/storage
export PATH=$PATH:${pkgs.git-lfs}/bin
# Web app config
export API_HOST="127.0.0.1:3001"
export API_PATH="/api/v1"
export API_SCHEME="http"
if [ -z $GITPOD_WORKSPACE_URL ]; then
export NEXT_PUBLIC_API_URL="http://127.0.0.1:3001"
else
export NEXT_PUBLIC_API_URL=$(echo "$GITPOD_WORKSPACE_URL" | sed -e 's/https:\/\//https:\/\/3001-/')
fi
export GEM_HOME=$data_dir/gem
export PATH="$PATH:$bin_dir:$GEM_HOME/bin:$web_root/node_modules/.bin"
export BUNDLE_FORCE_RUBY_PLATFORM=true
# Required for non-NixOS installs. This should work for debian/arch based distros.
# I'm unsure about others.
locales=/usr/lib/locale/locale-archive
if [[ -f $locales ]]
then
export LOCALE_ARCHIVE=$locales
fi
if ! [[ -d $data_dir ]]
then
sudo rm -rf .git/lfs/tmp
git lfs install --local
git lfs fetch
git lfs checkout
mkdir -p $data_dir
pushd $api_root
bundle install
# rake db:setup
rake db:migrate
popd
pushd $web_root
yarn install
popd
fi
LOCAL_PROCFILE="Procfile.local"
if ! [[ -f "$LOCAL_PROCFILE" ]]
then
echo "# Next dev server clears the console at startup, the sleeps sidestep that " >> $LOCAL_PROCFILE
echo "api: sleep 1 && cd api && rails s -b 0.0.0.0 -p 3001" >> $LOCAL_PROCFILE
echo "web: cd web && yarn run dev -p 3002" >> $LOCAL_PROCFILE
fi
'';
};
});
}