init: devenv, pi
This commit is contained in:
7
.envrc
Normal file
7
.envrc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export DIRENV_WARN_TIMEOUT=20s
|
||||||
|
|
||||||
|
eval "$(devenv direnvrc)"
|
||||||
|
|
||||||
|
# The use_devenv function supports passing flags to the devenv command
|
||||||
|
# For example: use devenv --impure --option services.postgres.enable:bool true
|
||||||
|
use devenv
|
||||||
50
.gitignore
vendored
Normal file
50
.gitignore
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# To do list
|
||||||
|
/TODO.md
|
||||||
|
|
||||||
|
# Devenv/Direnv
|
||||||
|
.devenv*
|
||||||
|
devenv.local.nix
|
||||||
|
.direnv
|
||||||
|
/.env
|
||||||
|
.null-ls_*.nix
|
||||||
|
/result
|
||||||
|
|
||||||
|
# pre-commit
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
# The directory Mix will write compiled artifacts to.
|
||||||
|
/_build/
|
||||||
|
/.elixir_ls/
|
||||||
|
|
||||||
|
# If you run "mix test --cover", coverage assets end up here.
|
||||||
|
/cover/
|
||||||
|
|
||||||
|
# The directory Mix downloads your dependencies sources to.
|
||||||
|
/deps/
|
||||||
|
|
||||||
|
# Where 3rd-party dependencies like ExDoc output generated docs.
|
||||||
|
/doc/
|
||||||
|
|
||||||
|
# Ignore .fetch files in case you like to edit your project deps locally.
|
||||||
|
/.fetch
|
||||||
|
|
||||||
|
# If the VM crashes, it generates a dump, let's ignore it too.
|
||||||
|
erl_crash.dump
|
||||||
|
|
||||||
|
# Also ignore archive artifacts (built via "mix archive.build").
|
||||||
|
*.ez
|
||||||
|
|
||||||
|
# Temporary files, for example, from tests.
|
||||||
|
/tmp/
|
||||||
|
# draw.io temp files
|
||||||
|
.$*
|
||||||
|
|
||||||
|
# Ignore assets that are produced by build tools.
|
||||||
|
/priv/cldr/
|
||||||
|
|
||||||
|
# LLMs
|
||||||
|
**/.claude/settings.local.json
|
||||||
|
/.mcp.json
|
||||||
|
|
||||||
|
# OS specific
|
||||||
|
.DS_Store
|
||||||
|
/node_modules/
|
||||||
72
default.nix
Normal file
72
default.nix
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
beam,
|
||||||
|
pkg-config,
|
||||||
|
vips,
|
||||||
|
}: let
|
||||||
|
pname = "parrhesia";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
beamPackages = beam.packages.erlang_28.extend (
|
||||||
|
final: _prev: {
|
||||||
|
elixir = final.elixir_1_19;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
projectRoot = ./.;
|
||||||
|
|
||||||
|
src = lib.cleanSourceWith {
|
||||||
|
src = projectRoot;
|
||||||
|
filter = path: type: let
|
||||||
|
pathStr = toString path;
|
||||||
|
rootStr = toString projectRoot;
|
||||||
|
relPath =
|
||||||
|
if pathStr == rootStr
|
||||||
|
then "."
|
||||||
|
else lib.removePrefix "${rootStr}/" pathStr;
|
||||||
|
excluded = [
|
||||||
|
".git"
|
||||||
|
".devenv"
|
||||||
|
"_build"
|
||||||
|
"deps"
|
||||||
|
"node_modules"
|
||||||
|
"complement"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
lib.cleanSourceFilter path type
|
||||||
|
&& !(lib.any (prefix: relPath == prefix || lib.hasPrefix "${prefix}/" relPath) excluded);
|
||||||
|
};
|
||||||
|
|
||||||
|
mixFodDeps =
|
||||||
|
if builtins.pathExists ./mix.lock
|
||||||
|
then
|
||||||
|
beamPackages.fetchMixDeps {
|
||||||
|
pname = "${pname}-mix-deps";
|
||||||
|
inherit version src;
|
||||||
|
hash = "sha256-eAk6FVjVPGcJl3adBSoQvPIva7w4xz4GuZ+DZaz6SYY=";
|
||||||
|
}
|
||||||
|
else null;
|
||||||
|
in
|
||||||
|
beamPackages.mixRelease {
|
||||||
|
inherit pname version src mixFodDeps;
|
||||||
|
|
||||||
|
mixEnv = "prod";
|
||||||
|
removeCookie = false;
|
||||||
|
nativeBuildInputs = [pkg-config];
|
||||||
|
buildInputs = [vips];
|
||||||
|
|
||||||
|
preConfigure = ''
|
||||||
|
rm -rf deps _build
|
||||||
|
export HOME="$TMPDIR"
|
||||||
|
export XDG_CACHE_HOME="$TMPDIR/.cache"
|
||||||
|
mkdir -p "$XDG_CACHE_HOME"
|
||||||
|
export VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPS
|
||||||
|
export VIPS_WARNING=false
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Parrhesia Matrix homeserver";
|
||||||
|
license = licenses.asl20;
|
||||||
|
platforms = platforms.unix;
|
||||||
|
};
|
||||||
|
}
|
||||||
103
devenv.lock
Normal file
103
devenv.lock
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"devenv": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"lastModified": 1768736080,
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"rev": "efa86311444852d24137d14964b449075522d489",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1767039857,
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"git-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1767281941,
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "f0927703b7b1c8d97511c4116eb9b4ec6645a0fa",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"git-hooks",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1762808025,
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1767052823,
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"rev": "538a5124359f0b3d466e1160378c87887e3b51a4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"ref": "rolling",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": "devenv",
|
||||||
|
"git-hooks": "git-hooks",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"pre-commit-hooks": [
|
||||||
|
"git-hooks"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
176
devenv.nix
Normal file
176
devenv.nix
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
mcpServers = [
|
||||||
|
{
|
||||||
|
name = "sqldb";
|
||||||
|
command = "npx";
|
||||||
|
args = [
|
||||||
|
"-y"
|
||||||
|
"@modelcontextprotocol/server-postgres"
|
||||||
|
"\"postgresql:///$1?host=$PGHOST\""
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
renderMcpCommands = {
|
||||||
|
tool,
|
||||||
|
envPrefix,
|
||||||
|
}:
|
||||||
|
lib.strings.concatMapStringsSep "\n" (server: let
|
||||||
|
args = lib.strings.concatStringsSep " " (
|
||||||
|
if server ? args
|
||||||
|
then server.args
|
||||||
|
else []
|
||||||
|
);
|
||||||
|
usesDbArg =
|
||||||
|
if server ? url
|
||||||
|
then lib.strings.hasInfix "$1" server.url
|
||||||
|
else lib.strings.hasInfix "$1" args;
|
||||||
|
scope =
|
||||||
|
if tool == "claude"
|
||||||
|
then " --scope project"
|
||||||
|
else "";
|
||||||
|
remove =
|
||||||
|
if tool == "claude"
|
||||||
|
then "${envPrefix}${tool} mcp remove${scope} ${server.name} >/dev/null 2>&1 || true\n"
|
||||||
|
else "";
|
||||||
|
stdioCmd = "${remove}${envPrefix}${tool} mcp add${scope} ${server.name} -- ${server.command} ${args}";
|
||||||
|
httpCmd =
|
||||||
|
if tool == "claude"
|
||||||
|
then "${remove}${envPrefix}${tool} mcp add${scope} --transport http ${server.name} ${server.url}"
|
||||||
|
else "${remove}${envPrefix}${tool} mcp add${scope} ${server.name} --url ${server.url}";
|
||||||
|
cmd =
|
||||||
|
if server ? command
|
||||||
|
then stdioCmd
|
||||||
|
else if server ? url
|
||||||
|
then httpCmd
|
||||||
|
else throw "MCP server '${server.name}' must define either 'command' or 'url'";
|
||||||
|
in
|
||||||
|
if usesDbArg
|
||||||
|
then ''
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
${cmd}
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
else cmd)
|
||||||
|
mcpServers;
|
||||||
|
in {
|
||||||
|
# https://devenv.sh/basics/
|
||||||
|
# the pre-compiled VIPS library does not support HEIC format
|
||||||
|
env.VIX_COMPILATION_MODE = "PLATFORM_PROVIDED_LIBVIPS";
|
||||||
|
# disable warnings as long as mozjpeg-linked VIPS is not available everywhere
|
||||||
|
env.VIPS_WARNING = "false";
|
||||||
|
# Parallel deps compilation
|
||||||
|
env.MIX_OS_DEPS_COMPILE_PARTITION_COUNT = 8;
|
||||||
|
|
||||||
|
# https://devenv.sh/packages/
|
||||||
|
packages = let
|
||||||
|
# WIP Add mozjpeg additionally (does not build on x86 otherwise)
|
||||||
|
vips-mozjpeg = with pkgs;
|
||||||
|
vips.overrideAttrs (oldAttrs: {
|
||||||
|
buildInputs = oldAttrs.buildInputs ++ [mozjpeg];
|
||||||
|
});
|
||||||
|
in
|
||||||
|
with pkgs; [
|
||||||
|
just
|
||||||
|
git
|
||||||
|
# Nix code formatter
|
||||||
|
alejandra
|
||||||
|
# i18n
|
||||||
|
icu
|
||||||
|
# PostgreSQL client utilities
|
||||||
|
postgresql
|
||||||
|
# image processing library
|
||||||
|
vips-mozjpeg
|
||||||
|
# Mermaid diagram generator
|
||||||
|
mermaid-cli
|
||||||
|
];
|
||||||
|
|
||||||
|
# https://devenv.sh/tests/
|
||||||
|
# enterTest = ''
|
||||||
|
# echo "Running tests"
|
||||||
|
# git --version | grep "2.42.0"
|
||||||
|
# '';
|
||||||
|
|
||||||
|
# https://devenv.sh/languages/
|
||||||
|
languages = {
|
||||||
|
elixir = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.elixir_1_19;
|
||||||
|
};
|
||||||
|
|
||||||
|
# for Pi agent
|
||||||
|
javascript = {
|
||||||
|
enable = true;
|
||||||
|
npm.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# for Matrix Complement tests
|
||||||
|
go.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://devenv.sh/services/
|
||||||
|
services.postgres = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.postgresql_18;
|
||||||
|
initialDatabases = [{name = "parrhesia_dev";} {name = "parrhesia_test";}];
|
||||||
|
initialScript = ''
|
||||||
|
CREATE ROLE dev WITH LOGIN PASSWORD 'dev' SUPERUSER;
|
||||||
|
|
||||||
|
ALTER database template1 is_template=false;
|
||||||
|
|
||||||
|
DROP database template1;
|
||||||
|
|
||||||
|
CREATE DATABASE template1 WITH OWNER = agent
|
||||||
|
ENCODING = 'UTF8'
|
||||||
|
TABLESPACE = pg_default
|
||||||
|
LC_COLLATE = 'de_DE.UTF-8'
|
||||||
|
LC_CTYPE = 'de_DE.UTF-8'
|
||||||
|
CONNECTION LIMIT = -1
|
||||||
|
TEMPLATE template0;
|
||||||
|
|
||||||
|
ALTER database template1 is_template=true;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://devenv.sh/pre-commit-hooks/
|
||||||
|
# pre-commit.hooks.shellcheck.enable = true;
|
||||||
|
|
||||||
|
dotenv.enable = true;
|
||||||
|
devenv.warnOnNewVersion = false;
|
||||||
|
|
||||||
|
git-hooks.hooks = {
|
||||||
|
alejandra.enable = true;
|
||||||
|
check-added-large-files = {
|
||||||
|
enable = true;
|
||||||
|
args = ["--maxkb=16384"];
|
||||||
|
};
|
||||||
|
mix-format.enable = true;
|
||||||
|
mix-format.files = "\\.(ex|exs)$";
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://devenv.sh/scripts/
|
||||||
|
enterShell = ''
|
||||||
|
echo
|
||||||
|
elixir --version
|
||||||
|
echo
|
||||||
|
'';
|
||||||
|
|
||||||
|
scripts = {
|
||||||
|
parsrv.exec = "iex --sname dev -S mix parrhesia.server";
|
||||||
|
parrun.exec = "elixir --sname console --rpc-eval dev \"$@\"";
|
||||||
|
set-claude-mcp.exec = renderMcpCommands {
|
||||||
|
tool = "claude";
|
||||||
|
envPrefix = ''CLAUDE_CONFIG_DIR=~/.claude''${2:+-''${2}} '';
|
||||||
|
};
|
||||||
|
set-codex-mcp.exec = renderMcpCommands {
|
||||||
|
tool = "codex";
|
||||||
|
envPrefix = ''CODEX_HOME=$HOME/.codex''${2:+-''${2}} '';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# See full reference at https://devenv.sh/reference/options/
|
||||||
|
}
|
||||||
15
devenv.yaml
Normal file
15
devenv.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
|
||||||
|
inputs:
|
||||||
|
nixpkgs:
|
||||||
|
url: github:cachix/devenv-nixpkgs/rolling
|
||||||
|
|
||||||
|
# If you're using non-OSS software, you can set allowUnfree to true.
|
||||||
|
# allowUnfree: true
|
||||||
|
|
||||||
|
# If you're willing to use a package that's vulnerable
|
||||||
|
# permittedInsecurePackages:
|
||||||
|
# - "openssl-1.1.1w"
|
||||||
|
|
||||||
|
# If you have more than one devenv you can merge them
|
||||||
|
#imports:
|
||||||
|
# - ./backend
|
||||||
3913
package-lock.json
generated
Normal file
3913
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@mariozechner/pi-coding-agent": "^0.57.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user