copy mobilizonConfig at setup, use writeShellApplication for better runtime checks
This commit is contained in:
parent
ec4b6abc4d
commit
6f373f5ea8
121
flake.nix
121
flake.nix
|
@ -95,6 +95,38 @@
|
||||||
let
|
let
|
||||||
pkgs = nixpkgsFor.${system};
|
pkgs = nixpkgsFor.${system};
|
||||||
settingsFormat = pkgs.formats.elixirConf { };
|
settingsFormat = pkgs.formats.elixirConf { };
|
||||||
|
mobilizonConfig = settingsFormat.generate "runtime.exs" {
|
||||||
|
":mobilizon" = {
|
||||||
|
"Mobilizon.Web.Endpoint" = {
|
||||||
|
server = true;
|
||||||
|
url.host = "mobilizon.dev";
|
||||||
|
http = {
|
||||||
|
ip = settingsFormat.lib.mkTuple [ 0 0 0 0 0 0 0 1 ];
|
||||||
|
port = 4000;
|
||||||
|
};
|
||||||
|
secret_key_base =
|
||||||
|
"2q/l1WDx3RQQy7gZ1k001//6nc66moWUEJQyGuMK/z3zPLYW6FYtIgCkUzGP0+X/";
|
||||||
|
};
|
||||||
|
"Mobilizon.Web.Auth.Guardian" = {
|
||||||
|
secret_key = "N8x7/tf0kInLFS2poO22g6OGPiMjSrDEhmk29nFqV35q7hQ0DtBt/cRYCsqBNp2L";
|
||||||
|
};
|
||||||
|
":instance" = {
|
||||||
|
name = "Mobilizon";
|
||||||
|
description = "Change this to a proper description of your instance";
|
||||||
|
hostname = "mobilizon.dev";
|
||||||
|
registrations_open = true;
|
||||||
|
email_from = "noreply@mobilizon.dev";
|
||||||
|
email_reply_to = "noreply@mobilizon.dev";
|
||||||
|
};
|
||||||
|
"Mobilizon.Storage.Repo" = {
|
||||||
|
adapter = settingsFormat.lib.mkAtom "Ecto.Adapters.Postgres";
|
||||||
|
pool_size = 10;
|
||||||
|
username = "mobilizon";
|
||||||
|
database = "mobilizon";
|
||||||
|
socket_dir = "/var/run/postgresql";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
default =
|
default =
|
||||||
|
@ -102,38 +134,6 @@
|
||||||
MIX_ENV = "dev";
|
MIX_ENV = "dev";
|
||||||
PGUSER = "mobilizon";
|
PGUSER = "mobilizon";
|
||||||
PGDATABASE = "mobilizon";
|
PGDATABASE = "mobilizon";
|
||||||
MOBILIZON_CONFIG_PATH = settingsFormat.generate "runtime.exs" {
|
|
||||||
":mobilizon" = {
|
|
||||||
"Mobilizon.Web.Endpoint" = {
|
|
||||||
server = true;
|
|
||||||
url.host = "mobilizon.dev";
|
|
||||||
http = {
|
|
||||||
ip = settingsFormat.lib.mkTuple [ 0 0 0 0 0 0 0 1 ];
|
|
||||||
port = 4000;
|
|
||||||
};
|
|
||||||
secret_key_base =
|
|
||||||
"2q/l1WDx3RQQy7gZ1k001//6nc66moWUEJQyGuMK/z3zPLYW6FYtIgCkUzGP0+X/";
|
|
||||||
};
|
|
||||||
"Mobilizon.Web.Auth.Guardian" = {
|
|
||||||
secret_key = "N8x7/tf0kInLFS2poO22g6OGPiMjSrDEhmk29nFqV35q7hQ0DtBt/cRYCsqBNp2L";
|
|
||||||
};
|
|
||||||
":instance" = {
|
|
||||||
name = "Mobilizon";
|
|
||||||
description = "Change this to a proper description of your instance";
|
|
||||||
hostname = "mobilizon.dev";
|
|
||||||
registrations_open = true;
|
|
||||||
email_from = "noreply@mobilizon.dev";
|
|
||||||
email_reply_to = "noreply@mobilizon.dev";
|
|
||||||
};
|
|
||||||
"Mobilizon.Storage.Repo" = {
|
|
||||||
adapter = settingsFormat.lib.mkAtom "Ecto.Adapters.Postgres";
|
|
||||||
pool_size = 10;
|
|
||||||
username = "mobilizon";
|
|
||||||
database = "mobilizon";
|
|
||||||
socket_dir = "/var/run/postgresql";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
with pkgs; [
|
with pkgs; [
|
||||||
elixir
|
elixir
|
||||||
|
@ -142,26 +142,43 @@
|
||||||
imagemagick
|
imagemagick
|
||||||
nodejs
|
nodejs
|
||||||
inotify-tools
|
inotify-tools
|
||||||
(pkgs.writeShellScriptBin "build" ''
|
(pkgs.writeShellApplication {
|
||||||
${elixir}/bin/mix deps.get
|
name = "build";
|
||||||
${elixir}/bin/mix deps.compile
|
runtimeInputs = [ elixir nodejs ];
|
||||||
${elixir}/bin/mix phx.digest
|
text = ''
|
||||||
${nodejs}/bin/npm install
|
mix deps.get
|
||||||
${nodejs}/bin/npm run build
|
mix deps.compile
|
||||||
'')
|
mix phx.digest
|
||||||
(pkgs.writeShellScriptBin "setup" ''
|
npm install
|
||||||
# We assume the database already exists
|
npm run build
|
||||||
sudo -u postgres ${postgresql}/bin/psql -d mobilizon -c "create extension if not exists postgis; create extension if not exists unaccent; create extension if not exists pg_trgm;"
|
'';
|
||||||
${elixir}/bin/mix ecto.migrate
|
})
|
||||||
'')
|
(pkgs.writeShellApplication {
|
||||||
(pkgs.writeShellScriptBin "start" ''
|
name = "setup";
|
||||||
${elixir}/bin/mix phx.server
|
runtimeInputs = [ elixir postgresql ];
|
||||||
'')
|
text = ''
|
||||||
(pkgs.writeShellScriptBin "clean" ''
|
cat ${mobilizonConfig} > config/runtime.exs
|
||||||
rm -rf deps/ _build/ node_modules/
|
# We assume the database already exists
|
||||||
sudo -u postgres ${postgresql}/bin/psql -c "DROP DATABASE mobilizon;"
|
sudo -u postgres psql -d mobilizon -c "create extension if not exists postgis; create extension if not exists unaccent; create extension if not exists pg_trgm;"
|
||||||
sudo systemctl restart postgresql.service
|
mix ecto.migrate
|
||||||
'')
|
'';
|
||||||
|
})
|
||||||
|
(pkgs.writeShellApplication {
|
||||||
|
name = "start";
|
||||||
|
runtimeInputs = [ elixir ];
|
||||||
|
text = ''
|
||||||
|
mix phx.server
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
(pkgs.writeShellApplication {
|
||||||
|
name = "clean";
|
||||||
|
runtimeInputs = [ postgresql ];
|
||||||
|
text = ''
|
||||||
|
rm -rf deps/ _build/ node_modules/
|
||||||
|
sudo -u postgres psql -c "DROP DATABASE mobilizon;"
|
||||||
|
sudo systemctl restart postgresql.service
|
||||||
|
'';
|
||||||
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue