copy mobilizonConfig at setup, use writeShellApplication for better runtime checks
This commit is contained in:
parent
ec4b6abc4d
commit
6f373f5ea8
67
flake.nix
67
flake.nix
|
@ -95,14 +95,7 @@
|
|||
let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
settingsFormat = pkgs.formats.elixirConf { };
|
||||
in
|
||||
{
|
||||
default =
|
||||
pkgs.mkShell {
|
||||
MIX_ENV = "dev";
|
||||
PGUSER = "mobilizon";
|
||||
PGDATABASE = "mobilizon";
|
||||
MOBILIZON_CONFIG_PATH = settingsFormat.generate "runtime.exs" {
|
||||
mobilizonConfig = settingsFormat.generate "runtime.exs" {
|
||||
":mobilizon" = {
|
||||
"Mobilizon.Web.Endpoint" = {
|
||||
server = true;
|
||||
|
@ -134,6 +127,13 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
default =
|
||||
pkgs.mkShell {
|
||||
MIX_ENV = "dev";
|
||||
PGUSER = "mobilizon";
|
||||
PGDATABASE = "mobilizon";
|
||||
buildInputs =
|
||||
with pkgs; [
|
||||
elixir
|
||||
|
@ -142,26 +142,43 @@
|
|||
imagemagick
|
||||
nodejs
|
||||
inotify-tools
|
||||
(pkgs.writeShellScriptBin "build" ''
|
||||
${elixir}/bin/mix deps.get
|
||||
${elixir}/bin/mix deps.compile
|
||||
${elixir}/bin/mix phx.digest
|
||||
${nodejs}/bin/npm install
|
||||
${nodejs}/bin/npm run build
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "setup" ''
|
||||
(pkgs.writeShellApplication {
|
||||
name = "build";
|
||||
runtimeInputs = [ elixir nodejs ];
|
||||
text = ''
|
||||
mix deps.get
|
||||
mix deps.compile
|
||||
mix phx.digest
|
||||
npm install
|
||||
npm run build
|
||||
'';
|
||||
})
|
||||
(pkgs.writeShellApplication {
|
||||
name = "setup";
|
||||
runtimeInputs = [ elixir postgresql ];
|
||||
text = ''
|
||||
cat ${mobilizonConfig} > config/runtime.exs
|
||||
# We assume the database already exists
|
||||
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.writeShellScriptBin "start" ''
|
||||
${elixir}/bin/mix phx.server
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "clean" ''
|
||||
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;"
|
||||
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 ${postgresql}/bin/psql -c "DROP DATABASE mobilizon;"
|
||||
sudo -u postgres psql -c "DROP DATABASE mobilizon;"
|
||||
sudo systemctl restart postgresql.service
|
||||
'')
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue