format all nix code by using nix fmt
This commit is contained in:
parent
656bbd46c0
commit
435cbd0d6b
58
default.nix
58
default.nix
|
@ -1,12 +1,13 @@
|
|||
{ lib
|
||||
, beam_nox
|
||||
, fetchFromGitHub
|
||||
, git
|
||||
, cmake
|
||||
, nixosTests
|
||||
, src
|
||||
, src-config
|
||||
, mobilizon-js
|
||||
{
|
||||
lib,
|
||||
beam_nox,
|
||||
fetchFromGitHub,
|
||||
git,
|
||||
cmake,
|
||||
nixosTests,
|
||||
src,
|
||||
src-config,
|
||||
mobilizon-js,
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -25,21 +26,20 @@ mixRelease rec {
|
|||
# This circumvents a startup error for now
|
||||
stripDebug = false;
|
||||
|
||||
nativeBuildInputs = [ git cmake ];
|
||||
nativeBuildInputs = [
|
||||
git
|
||||
cmake
|
||||
];
|
||||
|
||||
# Update deps.nix by running `mix deps.nix`
|
||||
mixNixDeps = import ./deps.nix {
|
||||
inherit lib;
|
||||
beamPackages = beam_nox.packages.erlang;
|
||||
overrides = (final: prev:
|
||||
(lib.mapAttrs
|
||||
(_: value: value.override {
|
||||
appConfigPath = src-config;
|
||||
})
|
||||
prev) // {
|
||||
fast_html = prev.fast_html.override {
|
||||
nativeBuildInputs = [ cmake ];
|
||||
};
|
||||
overrides = (
|
||||
final: prev:
|
||||
(lib.mapAttrs (_: value: value.override { appConfigPath = src-config; }) prev)
|
||||
// {
|
||||
fast_html = prev.fast_html.override { nativeBuildInputs = [ cmake ]; };
|
||||
ex_cldr = prev.ex_cldr.overrideAttrs (old: {
|
||||
# We have to use the GitHub sources, as it otherwise tries to download
|
||||
# the locales at build time.
|
||||
|
@ -47,7 +47,8 @@ mixRelease rec {
|
|||
owner = "elixir-cldr";
|
||||
repo = "cldr";
|
||||
rev = "v${old.version}";
|
||||
sha256 = assert old.version == "2.37.5";
|
||||
sha256 =
|
||||
assert old.version == "2.37.5";
|
||||
"sha256-T5Qvuo+xPwpgBsqHNZYnTCA4loToeBn1LKTMsDcCdYs=";
|
||||
};
|
||||
postInstall = ''
|
||||
|
@ -55,7 +56,8 @@ mixRelease rec {
|
|||
'';
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
preConfigure = ''
|
||||
|
@ -63,11 +65,10 @@ mixRelease rec {
|
|||
'';
|
||||
|
||||
# Install the compiled js part
|
||||
preBuild =
|
||||
''
|
||||
cp -a "${mobilizon-js}/_napalm-install/priv/static" ./priv
|
||||
chmod 770 -R ./priv
|
||||
'';
|
||||
preBuild = ''
|
||||
cp -a "${mobilizon-js}/_napalm-install/priv/static" ./priv
|
||||
chmod 770 -R ./priv
|
||||
'';
|
||||
|
||||
postBuild = ''
|
||||
mix phx.digest --no-deps-check
|
||||
|
@ -89,6 +90,9 @@ mixRelease rec {
|
|||
description = "Mobilizon is an online tool to help manage your events, your profiles and your groups";
|
||||
homepage = "https://joinmobilizon.org/";
|
||||
license = licenses.agpl3Plus;
|
||||
maintainers = with maintainers; [ minijackson erictapen ];
|
||||
maintainers = with maintainers; [
|
||||
minijackson
|
||||
erictapen
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
459
flake.nix
459
flake.nix
|
@ -8,20 +8,27 @@
|
|||
napalm.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nix-filter, napalm }:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
nix-filter,
|
||||
napalm,
|
||||
}:
|
||||
let
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs
|
||||
[ "x86_64-linux" "aarch64-linux" ]
|
||||
(system: f system);
|
||||
nixpkgsFor = forAllSystems (
|
||||
system:
|
||||
import nixpkgs { inherit system; }
|
||||
);
|
||||
forAllSystems =
|
||||
f:
|
||||
nixpkgs.lib.genAttrs [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
] (system: f system);
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
filter = nix-filter.lib;
|
||||
in
|
||||
{
|
||||
|
||||
packages = forAllSystems (system:
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
# Directories that are neither needed for building the frontend nor the backend.
|
||||
|
@ -69,7 +76,10 @@
|
|||
{
|
||||
inherit (pkgs) nodejs;
|
||||
nativeBuildInputs = [ pkgs.imagemagick ];
|
||||
npmCommands = [ "npm install" "npm run build" ];
|
||||
npmCommands = [
|
||||
"npm install"
|
||||
"npm run build"
|
||||
];
|
||||
# Keep this in sync with the content of ./patches/
|
||||
customPatchPackages = {
|
||||
vue-i18n-extract."2.0.7" = pkgs: prev: {
|
||||
|
@ -81,9 +91,11 @@
|
|||
};
|
||||
|
||||
default = self.packages."${system}".mobilizon;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forAllSystems (system:
|
||||
devShells = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
settingsFormat = pkgs.formats.elixirConf { };
|
||||
|
@ -93,11 +105,19 @@
|
|||
server = true;
|
||||
url.host = "mobilizon.dev";
|
||||
http = {
|
||||
ip = settingsFormat.lib.mkTuple [ 0 0 0 0 0 0 0 1 ];
|
||||
ip = settingsFormat.lib.mkTuple [
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
];
|
||||
port = 4000;
|
||||
};
|
||||
secret_key_base =
|
||||
"2q/l1WDx3RQQy7gZ1k001//6nc66moWUEJQyGuMK/z3zPLYW6FYtIgCkUzGP0+X/";
|
||||
secret_key_base = "2q/l1WDx3RQQy7gZ1k001//6nc66moWUEJQyGuMK/z3zPLYW6FYtIgCkUzGP0+X/";
|
||||
};
|
||||
"Mobilizon.Web.Auth.Guardian" = {
|
||||
secret_key = "N8x7/tf0kInLFS2poO22g6OGPiMjSrDEhmk29nFqV35q7hQ0DtBt/cRYCsqBNp2L";
|
||||
|
@ -121,73 +141,83 @@
|
|||
};
|
||||
in
|
||||
{
|
||||
default =
|
||||
pkgs.mkShell {
|
||||
MIX_ENV = "dev";
|
||||
PGUSER = "mobilizon";
|
||||
PGDATABASE = "mobilizon";
|
||||
buildInputs =
|
||||
with pkgs; [
|
||||
default = pkgs.mkShell {
|
||||
MIX_ENV = "dev";
|
||||
PGUSER = "mobilizon";
|
||||
PGDATABASE = "mobilizon";
|
||||
buildInputs = with pkgs; [
|
||||
elixir
|
||||
cmake
|
||||
imagemagick
|
||||
nodejs
|
||||
inotify-tools
|
||||
(pkgs.writeShellApplication {
|
||||
name = "build";
|
||||
runtimeInputs = [
|
||||
elixir
|
||||
cmake
|
||||
imagemagick
|
||||
nodejs
|
||||
inotify-tools
|
||||
(pkgs.writeShellApplication {
|
||||
name = "build";
|
||||
runtimeInputs = [ elixir nodejs ];
|
||||
text = ''
|
||||
mix deps.get
|
||||
mix deps.nix
|
||||
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 psql -d mobilizon << SQL
|
||||
create extension if not exists postgis;
|
||||
create extension if not exists unaccent;
|
||||
create extension if not exists pg_trgm;
|
||||
SQL
|
||||
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
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
});
|
||||
text = ''
|
||||
mix deps.get
|
||||
mix deps.nix
|
||||
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 psql -d mobilizon << SQL
|
||||
create extension if not exists postgis;
|
||||
create extension if not exists unaccent;
|
||||
create extension if not exists pg_trgm;
|
||||
SQL
|
||||
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
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
nixosModules.devSetup = { config, lib, pkgs, ... }:
|
||||
nixosModules.devSetup =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.mobilizonDevEnvironment;
|
||||
in
|
||||
{
|
||||
|
||||
options.mobilizonDevEnvironment = {
|
||||
enable = lib.mkEnableOption
|
||||
(lib.mdDoc "development environment for Mobilizon");
|
||||
enable = lib.mkEnableOption (lib.mdDoc "development environment for Mobilizon");
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Unix user that runs the backend application to connect to the database";
|
||||
|
@ -217,9 +247,7 @@
|
|||
|
||||
};
|
||||
|
||||
overlays.default = final: prev: {
|
||||
inherit (self.packages."${prev.system}") mobilizon;
|
||||
};
|
||||
overlays.default = final: prev: { inherit (self.packages."${prev.system}") mobilizon; };
|
||||
|
||||
checks = forAllSystems (system: {
|
||||
inherit (self.packages.${system}) mobilizon;
|
||||
|
@ -238,120 +266,197 @@
|
|||
lib = {
|
||||
# Patch the logos in the source tree of a mobilizon-frontend package before building.
|
||||
# Can be used to construct the argument for .overrideAttrs on mobilizon-frontend.
|
||||
mobilizonLogosOverride = icons:
|
||||
mobilizonLogosOverride =
|
||||
icons:
|
||||
let
|
||||
inherit (icons) logo favicon;
|
||||
in
|
||||
old: {
|
||||
postPatch = ''
|
||||
cp '${logo}' src/assets/logo.svg
|
||||
postPatch =
|
||||
''
|
||||
cp '${logo}' src/assets/logo.svg
|
||||
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
public/img/icons/favicon-16x16.png
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
public/img/icons/favicon-32x32.png
|
||||
|
||||
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-16x16.ico
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-32x32.ico
|
||||
|
||||
magick convert \
|
||||
-resize x48 \
|
||||
-gravity center \
|
||||
-crop 48x48+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-48x48.ico
|
||||
|
||||
magick convert \
|
||||
favicon-16x16.ico \
|
||||
favicon-32x32.ico \
|
||||
favicon-48x48.ico \
|
||||
public/favicon.ico
|
||||
|
||||
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
||||
|
||||
cp '${favicon}' public/img/icons/favicon.svg
|
||||
cp '${favicon}' public/img/icons/safari-pinned-tab.svg
|
||||
|
||||
magick convert \
|
||||
'${favicon}' \
|
||||
-gravity center \
|
||||
-extent 630x350 \
|
||||
public/img/mobilizon_default_card.png
|
||||
|
||||
magick convert \
|
||||
-background '#e08c96' \
|
||||
'${logo}' \
|
||||
-resize 366x108 \
|
||||
public/img/mobilizon_logo.png
|
||||
|
||||
'' + nixpkgs.lib.concatMapStrings
|
||||
({ resize, filename }: ''
|
||||
magick convert \
|
||||
-resize x${resize} \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
public/img/icons/${filename}
|
||||
public/img/icons/favicon-16x16.png
|
||||
|
||||
'')
|
||||
[
|
||||
{ resize = "180"; filename = "apple-touch-icon.png"; }
|
||||
{ resize = "180"; filename = "apple-touch-icon-180x180.png"; }
|
||||
{ resize = "152"; filename = "apple-touch-icon-152x152.png"; }
|
||||
{ resize = "120"; filename = "apple-touch-icon-120x120.png"; }
|
||||
{ resize = "76"; filename = "apple-touch-icon-76x76.png"; }
|
||||
{ resize = "60"; filename = "apple-touch-icon-60x60.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-512x512.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
||||
{ resize = "128"; filename = "badge-128x128.png"; }
|
||||
{ resize = "144"; filename = "icon-144x144.png"; }
|
||||
{ resize = "168"; filename = "icon-168x168.png"; }
|
||||
{ resize = "256"; filename = "icon-256x256.png"; }
|
||||
{ resize = "48"; filename = "icon-48x48.png"; }
|
||||
{ resize = "72"; filename = "icon-72x72.png"; }
|
||||
{ resize = "96"; filename = "icon-96x96.png"; }
|
||||
{ resize = "144"; filename = "msapplication-icon-144x144.png"; }
|
||||
{ resize = "150"; filename = "mstile-150x150.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-512x512.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
||||
];
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
public/img/icons/favicon-32x32.png
|
||||
|
||||
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-16x16.ico
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-32x32.ico
|
||||
|
||||
magick convert \
|
||||
-resize x48 \
|
||||
-gravity center \
|
||||
-crop 48x48+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-48x48.ico
|
||||
|
||||
magick convert \
|
||||
favicon-16x16.ico \
|
||||
favicon-32x32.ico \
|
||||
favicon-48x48.ico \
|
||||
public/favicon.ico
|
||||
|
||||
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
||||
|
||||
cp '${favicon}' public/img/icons/favicon.svg
|
||||
cp '${favicon}' public/img/icons/safari-pinned-tab.svg
|
||||
|
||||
magick convert \
|
||||
'${favicon}' \
|
||||
-gravity center \
|
||||
-extent 630x350 \
|
||||
public/img/mobilizon_default_card.png
|
||||
|
||||
magick convert \
|
||||
-background '#e08c96' \
|
||||
'${logo}' \
|
||||
-resize 366x108 \
|
||||
public/img/mobilizon_logo.png
|
||||
|
||||
''
|
||||
+
|
||||
nixpkgs.lib.concatMapStrings
|
||||
(
|
||||
{ resize, filename }:
|
||||
''
|
||||
magick convert \
|
||||
-resize x${resize} \
|
||||
'${favicon}' \
|
||||
public/img/icons/${filename}
|
||||
|
||||
''
|
||||
)
|
||||
[
|
||||
{
|
||||
resize = "180";
|
||||
filename = "apple-touch-icon.png";
|
||||
}
|
||||
{
|
||||
resize = "180";
|
||||
filename = "apple-touch-icon-180x180.png";
|
||||
}
|
||||
{
|
||||
resize = "152";
|
||||
filename = "apple-touch-icon-152x152.png";
|
||||
}
|
||||
{
|
||||
resize = "120";
|
||||
filename = "apple-touch-icon-120x120.png";
|
||||
}
|
||||
{
|
||||
resize = "76";
|
||||
filename = "apple-touch-icon-76x76.png";
|
||||
}
|
||||
{
|
||||
resize = "60";
|
||||
filename = "apple-touch-icon-60x60.png";
|
||||
}
|
||||
{
|
||||
resize = "192";
|
||||
filename = "android-chrome-192x192.png";
|
||||
}
|
||||
{
|
||||
resize = "512";
|
||||
filename = "android-chrome-512x512.png";
|
||||
}
|
||||
{
|
||||
resize = "192";
|
||||
filename = "android-chrome-maskable-192x192.png";
|
||||
}
|
||||
{
|
||||
resize = "512";
|
||||
filename = "android-chrome-maskable-512x512.png";
|
||||
}
|
||||
{
|
||||
resize = "128";
|
||||
filename = "badge-128x128.png";
|
||||
}
|
||||
{
|
||||
resize = "144";
|
||||
filename = "icon-144x144.png";
|
||||
}
|
||||
{
|
||||
resize = "168";
|
||||
filename = "icon-168x168.png";
|
||||
}
|
||||
{
|
||||
resize = "256";
|
||||
filename = "icon-256x256.png";
|
||||
}
|
||||
{
|
||||
resize = "48";
|
||||
filename = "icon-48x48.png";
|
||||
}
|
||||
{
|
||||
resize = "72";
|
||||
filename = "icon-72x72.png";
|
||||
}
|
||||
{
|
||||
resize = "96";
|
||||
filename = "icon-96x96.png";
|
||||
}
|
||||
{
|
||||
resize = "144";
|
||||
filename = "msapplication-icon-144x144.png";
|
||||
}
|
||||
{
|
||||
resize = "150";
|
||||
filename = "mstile-150x150.png";
|
||||
}
|
||||
{
|
||||
resize = "192";
|
||||
filename = "android-chrome-192x192.png";
|
||||
}
|
||||
{
|
||||
resize = "512";
|
||||
filename = "android-chrome-512x512.png";
|
||||
}
|
||||
{
|
||||
resize = "192";
|
||||
filename = "android-chrome-maskable-192x192.png";
|
||||
}
|
||||
{
|
||||
resize = "512";
|
||||
filename = "android-chrome-maskable-512x512.png";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ in
|
|||
|
||||
{
|
||||
name = "mobilizon";
|
||||
meta.maintainers = with lib.maintainers; [ minijackson erictapen ];
|
||||
meta.maintainers = with lib.maintainers; [
|
||||
minijackson
|
||||
erictapen
|
||||
];
|
||||
|
||||
nodes.server =
|
||||
{ pkgs, ... }:
|
||||
|
|
Loading…
Reference in a new issue