2023-03-15 21:57:31 +01:00
|
|
|
{
|
2023-08-03 16:49:50 +02:00
|
|
|
description = "Mobilizon fork for potsda.mn";
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2023-08-09 15:48:22 +02:00
|
|
|
inputs = {
|
2023-09-10 10:52:50 +02:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2023-08-09 15:48:22 +02:00
|
|
|
nix-filter.url = "github:numtide/nix-filter";
|
2023-11-21 16:38:36 +01:00
|
|
|
napalm.url = "github:nix-community/napalm";
|
|
|
|
napalm.inputs.nixpkgs.follows = "nixpkgs";
|
2023-08-09 15:48:22 +02:00
|
|
|
};
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2023-11-21 16:38:36 +01:00
|
|
|
outputs = { self, nixpkgs, nix-filter, napalm }:
|
2023-08-09 15:28:38 +02:00
|
|
|
let
|
2023-11-06 17:56:12 +01:00
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs
|
|
|
|
[ "x86_64-linux" "aarch64-linux" ]
|
|
|
|
(system: f system);
|
|
|
|
nixpkgsFor = forAllSystems (
|
|
|
|
system:
|
|
|
|
import nixpkgs { inherit system; }
|
|
|
|
);
|
2023-08-09 15:48:22 +02:00
|
|
|
filter = nix-filter.lib;
|
2023-08-09 15:28:38 +02:00
|
|
|
in
|
|
|
|
{
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2023-11-06 17:56:12 +01:00
|
|
|
packages = forAllSystems (system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgsFor.${system};
|
2023-11-23 19:32:46 +01:00
|
|
|
# Directories that are neither needed for building the frontend nor the backend.
|
|
|
|
# For better build caching.
|
|
|
|
unrelatedDirs = [
|
2023-12-01 20:49:47 +01:00
|
|
|
"flake.lock"
|
|
|
|
(filter.matchExt "nix")
|
2023-11-23 19:32:46 +01:00
|
|
|
"docs"
|
|
|
|
"docker"
|
|
|
|
"docker-compose.test.yml"
|
|
|
|
"docker-compose.yml"
|
|
|
|
"generate-test-data"
|
|
|
|
];
|
2023-11-06 17:56:12 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
mobilizon = pkgs.callPackage ./. {
|
|
|
|
src = filter {
|
|
|
|
root = ./.;
|
|
|
|
exclude = [
|
2023-11-21 16:38:36 +01:00
|
|
|
"src"
|
|
|
|
(filter.matchExt "js")
|
2023-11-23 19:32:46 +01:00
|
|
|
(filter.matchExt "ts")
|
|
|
|
(filter.matchExt "json")
|
|
|
|
"tests"
|
|
|
|
"scripts"
|
|
|
|
"public"
|
|
|
|
] ++ unrelatedDirs;
|
2023-11-06 17:56:12 +01:00
|
|
|
};
|
|
|
|
src-config = ./config;
|
2023-11-22 12:38:33 +01:00
|
|
|
mobilizon-js = self.packages."${system}".mobilizon-frontend;
|
2023-08-09 16:03:20 +02:00
|
|
|
};
|
2023-08-03 17:26:07 +02:00
|
|
|
|
2023-11-21 16:38:36 +01:00
|
|
|
mobilizon-frontend =
|
|
|
|
napalm.legacyPackages."${system}".buildPackage
|
|
|
|
(filter {
|
|
|
|
root = ./.;
|
|
|
|
exclude = [
|
|
|
|
"lib"
|
|
|
|
"config"
|
2023-11-23 19:32:46 +01:00
|
|
|
"test"
|
|
|
|
"rel"
|
|
|
|
"support"
|
|
|
|
] ++ unrelatedDirs;
|
2023-11-21 16:38:36 +01:00
|
|
|
})
|
|
|
|
{
|
2024-03-01 15:06:46 +01:00
|
|
|
inherit (pkgs) nodejs;
|
2023-11-21 16:38:36 +01:00
|
|
|
nativeBuildInputs = [ pkgs.imagemagick ];
|
|
|
|
npmCommands = [ "npm install" "npm run build" ];
|
2024-02-08 19:33:57 +01:00
|
|
|
# Keep this in sync with the content of ./patches/
|
|
|
|
customPatchPackages = {
|
|
|
|
vue-i18n-extract."2.0.7" = pkgs: prev: {
|
|
|
|
preConfigure = ''
|
|
|
|
${pkgs.git}/bin/git apply -p3 ${./patches/vue-i18n-extract+2.0.7.patch}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2023-11-21 16:38:36 +01:00
|
|
|
};
|
2023-08-09 16:03:20 +02:00
|
|
|
|
2023-11-22 12:38:33 +01:00
|
|
|
default = self.packages."${system}".mobilizon;
|
2023-08-09 16:03:20 +02:00
|
|
|
|
2023-11-06 17:56:12 +01:00
|
|
|
# Update local Mobilizon definition
|
|
|
|
update =
|
|
|
|
pkgs.writeShellScriptBin "update" ''
|
|
|
|
set -eou pipefail
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2023-11-06 17:56:12 +01:00
|
|
|
${pkgs.mix2nix}/bin/mix2nix ./mix.lock > mix.nix
|
|
|
|
'';
|
|
|
|
});
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2023-11-06 17:56:12 +01:00
|
|
|
devShells = forAllSystems (system:
|
2024-03-05 17:10:04 +01:00
|
|
|
let
|
|
|
|
pkgs = nixpkgsFor.${system};
|
|
|
|
settingsFormat = pkgs.formats.elixirConf { };
|
2024-03-07 13:00:22 +01:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-03-05 17:10:04 +01:00
|
|
|
in
|
|
|
|
{
|
2023-11-06 17:56:12 +01:00
|
|
|
default =
|
|
|
|
pkgs.mkShell {
|
2024-03-05 17:10:04 +01:00
|
|
|
MIX_ENV = "dev";
|
|
|
|
PGUSER = "mobilizon";
|
|
|
|
PGDATABASE = "mobilizon";
|
|
|
|
buildInputs =
|
|
|
|
with pkgs; [
|
|
|
|
elixir
|
|
|
|
mix2nix
|
|
|
|
cmake
|
|
|
|
imagemagick
|
|
|
|
nodejs
|
|
|
|
inotify-tools
|
2024-03-07 13:00:22 +01:00
|
|
|
(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 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 psql -c "DROP DATABASE mobilizon;"
|
|
|
|
sudo systemctl restart postgresql.service
|
|
|
|
'';
|
|
|
|
})
|
2024-03-05 17:10:04 +01:00
|
|
|
];
|
2023-11-06 17:56:12 +01:00
|
|
|
};
|
|
|
|
});
|
2023-03-15 21:57:31 +01:00
|
|
|
|
2024-03-05 17:10:04 +01:00
|
|
|
nixosModules.devSetup = { config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.mobilizonDevEnvironment;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options.mobilizonDevEnvironment = {
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ "mobilizon" ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "mobilizon";
|
|
|
|
ensureDBOwnership = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
extraPlugins = with config.services.postgresql.package.pkgs; [ postgis ];
|
|
|
|
identMap = ''
|
|
|
|
map-mobilizon ${cfg.user} mobilizon
|
|
|
|
'';
|
|
|
|
authentication = ''
|
|
|
|
local all mobilizon ident map=map-mobilizon
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-11-22 12:23:00 +01:00
|
|
|
overlays.default = final: prev: {
|
|
|
|
inherit (self.packages."${prev.system}") mobilizon;
|
|
|
|
};
|
|
|
|
|
2023-11-06 17:56:12 +01:00
|
|
|
checks = forAllSystems (system: {
|
|
|
|
inherit (self.packages.${system}) mobilizon update;
|
2023-11-22 12:23:00 +01:00
|
|
|
nixosTest =
|
|
|
|
let
|
|
|
|
pkgsMobilizon = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ self.overlays.default ];
|
|
|
|
};
|
|
|
|
certs = import "${nixpkgs}/nixos/tests/common/acme/server/snakeoil-certs.nix";
|
2024-03-06 00:04:15 +01:00
|
|
|
test = import ./integration-test.nix { inherit certs; };
|
2023-11-22 12:23:00 +01:00
|
|
|
in
|
|
|
|
pkgsMobilizon.nixosTest test;
|
2023-11-06 17:56:12 +01:00
|
|
|
});
|
2023-10-20 11:48:09 +02:00
|
|
|
|
2023-10-20 11:50:11 +02:00
|
|
|
lib = {
|
2023-11-02 16:52:24 +01:00
|
|
|
# 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:
|
2023-10-20 11:50:11 +02:00
|
|
|
let
|
|
|
|
inherit (icons) logo favicon;
|
|
|
|
in
|
2023-11-02 16:52:24 +01:00
|
|
|
old: {
|
|
|
|
postPatch = ''
|
|
|
|
cp '${logo}' src/assets/logo.svg
|
2023-10-20 20:43:18 +02:00
|
|
|
|
2023-10-20 11:50:11 +02:00
|
|
|
magick convert \
|
|
|
|
-resize x16 \
|
|
|
|
-gravity center \
|
|
|
|
-crop 16x16+0+0 \
|
|
|
|
-flatten \
|
|
|
|
-colors 256 \
|
|
|
|
'${favicon}' \
|
2023-11-02 16:52:24 +01:00
|
|
|
public/img/icons/favicon-16x16.png
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
magick convert \
|
|
|
|
-resize x32 \
|
|
|
|
-gravity center \
|
|
|
|
-crop 32x32+0+0 \
|
|
|
|
-flatten \
|
|
|
|
-colors 256 \
|
|
|
|
'${favicon}' \
|
2023-11-02 16:52:24 +01:00
|
|
|
public/img/icons/favicon-32x32.png
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-11-02 16:52:24 +01:00
|
|
|
magick convert \
|
|
|
|
favicon-16x16.ico \
|
|
|
|
favicon-32x32.ico \
|
|
|
|
favicon-48x48.ico \
|
|
|
|
public/favicon.ico
|
|
|
|
|
2023-10-20 11:50:11 +02:00
|
|
|
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
|
|
|
|
2023-11-02 16:52:24 +01:00
|
|
|
cp '${favicon}' public/img/icons/favicon.svg
|
|
|
|
cp '${favicon}' public/img/icons/safari-pinned-tab.svg
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
magick convert \
|
|
|
|
'${favicon}' \
|
|
|
|
-gravity center \
|
|
|
|
-extent 630x350 \
|
2023-11-02 16:52:24 +01:00
|
|
|
public/img/mobilizon_default_card.png
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
magick convert \
|
|
|
|
-background '#e08c96' \
|
|
|
|
'${logo}' \
|
|
|
|
-resize 366x108 \
|
2023-11-02 16:52:24 +01:00
|
|
|
public/img/mobilizon_logo.png
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
'' + nixpkgs.lib.concatMapStrings
|
|
|
|
({ resize, filename }: ''
|
|
|
|
magick convert \
|
|
|
|
-resize x${resize} \
|
|
|
|
'${favicon}' \
|
2023-11-02 16:52:24 +01:00
|
|
|
public/img/icons/${filename}
|
2023-10-20 11:50:11 +02:00
|
|
|
|
|
|
|
'')
|
|
|
|
[
|
|
|
|
{ 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"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-08-09 15:28:38 +02:00
|
|
|
};
|
2023-03-15 21:57:31 +01:00
|
|
|
}
|