mirror of
https://github.com/matrix-org/synapse.git
synced 2025-01-12 19:27:55 +00:00
Migrate Synapse flake to vector-im/nix-flakes
This commit is contained in:
parent
e9069c9f91
commit
0b4aa2d91e
84
flake.lock
generated
84
flake.lock
generated
@ -22,6 +22,27 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"element-nix-flakes": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": "devenv",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1698246692,
|
||||||
|
"narHash": "sha256-NTpKGliwEptK84WI3N+6ndXZdi9bwQLZrkLzU7rbE+g=",
|
||||||
|
"owner": "vector-im",
|
||||||
|
"repo": "nix-flakes",
|
||||||
|
"rev": "118713d4c11e5ca9665f51d699435ae12ecbf2a2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "vector-im",
|
||||||
|
"repo": "nix-flakes",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -39,15 +60,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1685518550,
|
"lastModified": 1667395993,
|
||||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -58,7 +76,7 @@
|
|||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_2": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems_2"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681202837,
|
"lastModified": 1681202837,
|
||||||
@ -77,6 +95,7 @@
|
|||||||
"gitignore": {
|
"gitignore": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
"element-nix-flakes",
|
||||||
"devenv",
|
"devenv",
|
||||||
"pre-commit-hooks",
|
"pre-commit-hooks",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
@ -116,6 +135,7 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"lowdown-src": "lowdown-src",
|
"lowdown-src": "lowdown-src",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
"element-nix-flakes",
|
||||||
"devenv",
|
"devenv",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
@ -170,32 +190,32 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-stable": {
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1685801374,
|
"lastModified": 1678872516,
|
||||||
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
|
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
|
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-23.05",
|
"ref": "nixos-22.11",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1690535733,
|
"lastModified": 1697456312,
|
||||||
"narHash": "sha256-WgjUPscQOw3cB8yySDGlyzo6cZNihnRzUwE9kadv/5I=",
|
"narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8cacc05fbfffeaab910e8c2c9e2a7c6b32ce881a",
|
"rev": "ca012a02bf8327be9e488546faecae5e05d7d749",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "master",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@ -219,23 +239,25 @@
|
|||||||
"pre-commit-hooks": {
|
"pre-commit-hooks": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": [
|
||||||
|
"element-nix-flakes",
|
||||||
"devenv",
|
"devenv",
|
||||||
"flake-compat"
|
"flake-compat"
|
||||||
],
|
],
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"gitignore": "gitignore",
|
"gitignore": "gitignore",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
"element-nix-flakes",
|
||||||
"devenv",
|
"devenv",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1688056373,
|
"lastModified": 1686050334,
|
||||||
"narHash": "sha256-2+SDlNRTKsgo3LBRiMUcoEUb6sDViRNQhzJquZ4koOI=",
|
"narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "5843cf069272d92b60c3ed9e55b7a8989c01d4c7",
|
"rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -246,10 +268,7 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"devenv": "devenv",
|
"element-nix-flakes": "element-nix-flakes"
|
||||||
"nixpkgs": "nixpkgs_2",
|
|
||||||
"rust-overlay": "rust-overlay",
|
|
||||||
"systems": "systems_3"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
@ -258,11 +277,11 @@
|
|||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1693966243,
|
"lastModified": 1697767917,
|
||||||
"narHash": "sha256-a2CA1aMIPE67JWSVIGoGtD3EGlFdK9+OlJQs0FOWCKY=",
|
"narHash": "sha256-9+FjCVE1Y7iUKohBF43yD05KoQB+FPcw/XL2rlKkjqY=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "a8b4bb4cbb744baaabc3e69099f352f99164e2c1",
|
"rev": "679ea0878edc749f23516ea6d7ffa974c6304bf5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -300,21 +319,6 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
228
flake.nix
228
flake.nix
@ -39,224 +39,18 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
# Use the master/unstable branch of nixpkgs. Used to fetch the latest
|
# A repository of nix development environment flakes.
|
||||||
# available versions of packages.
|
element-nix-flakes.url = "github:vector-im/nix-flakes";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
|
||||||
# Output a development shell for x86_64/aarch64 Linux/Darwin (MacOS).
|
|
||||||
systems.url = "github:nix-systems/default";
|
|
||||||
# A development environment manager built on Nix. See https://devenv.sh.
|
|
||||||
devenv.url = "github:cachix/devenv/v0.6.3";
|
|
||||||
# Rust toolchain.
|
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, devenv, systems, rust-overlay, ... } @ inputs:
|
outputs = { self, element-nix-flakes, ... }:
|
||||||
let
|
{
|
||||||
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
# Use the `composeShell` function provided by nix-flakes
|
||||||
in {
|
# and specify the projects we'd like dependencies for.
|
||||||
devShells = forEachSystem (system:
|
devShells = element-nix-flakes.outputs.composeShell [
|
||||||
let
|
"complement"
|
||||||
overlays = [ (import rust-overlay) ];
|
"synapse"
|
||||||
pkgs = import nixpkgs {
|
"sytest"
|
||||||
inherit system overlays;
|
];
|
||||||
};
|
|
||||||
in {
|
|
||||||
# Everything is configured via devenv - a Nix module for creating declarative
|
|
||||||
# developer environments. See https://devenv.sh/reference/options/ for a list
|
|
||||||
# of all possible options.
|
|
||||||
default = devenv.lib.mkShell {
|
|
||||||
inherit inputs pkgs;
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
# Make use of the Starship command prompt when this development environment
|
|
||||||
# is manually activated (via `nix develop --impure`).
|
|
||||||
# See https://starship.rs/ for details on the prompt itself.
|
|
||||||
starship.enable = true;
|
|
||||||
|
|
||||||
# Configure packages to install.
|
|
||||||
# Search for package names at https://search.nixos.org/packages?channel=unstable
|
|
||||||
packages = with pkgs; [
|
|
||||||
# The rust toolchain and related tools.
|
|
||||||
# This will install the "default" profile of rust components.
|
|
||||||
# https://rust-lang.github.io/rustup/concepts/profiles.html
|
|
||||||
#
|
|
||||||
# NOTE: We currently need to set the Rust version unnecessarily high
|
|
||||||
# in order to work around https://github.com/matrix-org/synapse/issues/15939
|
|
||||||
(rust-bin.stable."1.71.1".default.override {
|
|
||||||
# Additionally install the "rust-src" extension to allow diving into the
|
|
||||||
# Rust source code in an IDE (rust-analyzer will also make use of it).
|
|
||||||
extensions = [ "rust-src" ];
|
|
||||||
})
|
|
||||||
# The rust-analyzer language server implementation.
|
|
||||||
rust-analyzer
|
|
||||||
|
|
||||||
# GCC includes a linker; needed for building `ruff`
|
|
||||||
gcc
|
|
||||||
# Needed for building `ruff`
|
|
||||||
gnumake
|
|
||||||
|
|
||||||
# Native dependencies for running Synapse.
|
|
||||||
icu
|
|
||||||
libffi
|
|
||||||
libjpeg
|
|
||||||
libpqxx
|
|
||||||
libwebp
|
|
||||||
libxml2
|
|
||||||
libxslt
|
|
||||||
sqlite
|
|
||||||
|
|
||||||
# Native dependencies for unit tests (SyTest also requires OpenSSL).
|
|
||||||
openssl
|
|
||||||
xmlsec
|
|
||||||
|
|
||||||
# Native dependencies for running Complement.
|
|
||||||
olm
|
|
||||||
|
|
||||||
# For building the Synapse documentation website.
|
|
||||||
mdbook
|
|
||||||
|
|
||||||
# For releasing Synapse
|
|
||||||
debian-devscripts # (`dch` for manipulating the Debian changelog)
|
|
||||||
libnotify # (the release script uses `notify-send` to tell you when CI jobs are done)
|
|
||||||
];
|
|
||||||
|
|
||||||
# Install Python and manage a virtualenv with Poetry.
|
|
||||||
languages.python.enable = true;
|
|
||||||
languages.python.poetry.enable = true;
|
|
||||||
# Automatically activate the poetry virtualenv upon entering the shell.
|
|
||||||
languages.python.poetry.activate.enable = true;
|
|
||||||
# Install all extra Python dependencies; this is needed to run the unit
|
|
||||||
# tests and utilitise all Synapse features.
|
|
||||||
languages.python.poetry.install.arguments = ["--extras all"];
|
|
||||||
# Install the 'matrix-synapse' package from the local checkout.
|
|
||||||
languages.python.poetry.install.installRootPackage = true;
|
|
||||||
|
|
||||||
# This is a work-around for NixOS systems. NixOS is special in
|
|
||||||
# that you can have multiple versions of packages installed at
|
|
||||||
# once, including your libc linker!
|
|
||||||
#
|
|
||||||
# Some binaries built for Linux expect those to be in a certain
|
|
||||||
# filepath, but that is not the case on NixOS. In that case, we
|
|
||||||
# force compiling those binaries locally instead.
|
|
||||||
env.POETRY_INSTALLER_NO_BINARY = "ruff";
|
|
||||||
|
|
||||||
# Install dependencies for the additional programming languages
|
|
||||||
# involved with Synapse development.
|
|
||||||
#
|
|
||||||
# * Golang is needed to run the Complement test suite.
|
|
||||||
# * Perl is needed to run the SyTest test suite.
|
|
||||||
# * Rust is used for developing and running Synapse.
|
|
||||||
# It is installed manually with `packages` above.
|
|
||||||
languages.go.enable = true;
|
|
||||||
languages.perl.enable = true;
|
|
||||||
|
|
||||||
# Postgres is needed to run Synapse with postgres support and
|
|
||||||
# to run certain unit tests that require postgres.
|
|
||||||
services.postgres.enable = true;
|
|
||||||
|
|
||||||
# On the first invocation of `devenv up`, create a database for
|
|
||||||
# Synapse to store data in.
|
|
||||||
services.postgres.initdbArgs = ["--locale=C" "--encoding=UTF8"];
|
|
||||||
services.postgres.initialDatabases = [
|
|
||||||
{ name = "synapse"; }
|
|
||||||
];
|
|
||||||
# Create a postgres user called 'synapse_user' which has ownership
|
|
||||||
# over the 'synapse' database.
|
|
||||||
services.postgres.initialScript = ''
|
|
||||||
CREATE USER synapse_user;
|
|
||||||
ALTER DATABASE synapse OWNER TO synapse_user;
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Redis is needed in order to run Synapse in worker mode.
|
|
||||||
services.redis.enable = true;
|
|
||||||
|
|
||||||
# Configure and start Synapse. Before starting Synapse, this shell code:
|
|
||||||
# * generates a default homeserver.yaml config file if one does not exist, and
|
|
||||||
# * ensures a directory containing two additional homeserver config files exists;
|
|
||||||
# one to configure using the development environment's PostgreSQL as the
|
|
||||||
# database backend and another for enabling Redis support.
|
|
||||||
process.before = ''
|
|
||||||
python -m synapse.app.homeserver -c homeserver.yaml --generate-config --server-name=synapse.dev --report-stats=no
|
|
||||||
mkdir -p homeserver-config-overrides.d
|
|
||||||
cat > homeserver-config-overrides.d/database.yaml << EOF
|
|
||||||
## Do not edit this file. This file is generated by flake.nix
|
|
||||||
database:
|
|
||||||
name: psycopg2
|
|
||||||
args:
|
|
||||||
user: synapse_user
|
|
||||||
database: synapse
|
|
||||||
host: $PGHOST
|
|
||||||
cp_min: 5
|
|
||||||
cp_max: 10
|
|
||||||
EOF
|
|
||||||
cat > homeserver-config-overrides.d/redis.yaml << EOF
|
|
||||||
## Do not edit this file. This file is generated by flake.nix
|
|
||||||
redis:
|
|
||||||
enabled: true
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
# Start synapse when `devenv up` is run.
|
|
||||||
processes.synapse.exec = "poetry run python -m synapse.app.homeserver -c homeserver.yaml -c homeserver-config-overrides.d";
|
|
||||||
|
|
||||||
# Define the perl modules we require to run SyTest.
|
|
||||||
#
|
|
||||||
# This list was compiled by cross-referencing https://metacpan.org/
|
|
||||||
# with the modules defined in './cpanfile' and then finding the
|
|
||||||
# corresponding Nix packages on https://search.nixos.org/packages.
|
|
||||||
#
|
|
||||||
# This was done until `./install-deps.pl --dryrun` produced no output.
|
|
||||||
env.PERL5LIB = "${with pkgs.perl536Packages; makePerlPath [
|
|
||||||
DBI
|
|
||||||
ClassMethodModifiers
|
|
||||||
CryptEd25519
|
|
||||||
DataDump
|
|
||||||
DBDPg
|
|
||||||
DigestHMAC
|
|
||||||
DigestSHA1
|
|
||||||
EmailAddressXS
|
|
||||||
EmailMIME
|
|
||||||
EmailSimple # required by Email::Mime
|
|
||||||
EmailMessageID # required by Email::Mime
|
|
||||||
EmailMIMEContentType # required by Email::Mime
|
|
||||||
TextUnidecode # required by Email::Mime
|
|
||||||
ModuleRuntime # required by Email::Mime
|
|
||||||
EmailMIMEEncodings # required by Email::Mime
|
|
||||||
FilePath
|
|
||||||
FileSlurper
|
|
||||||
Future
|
|
||||||
GetoptLong
|
|
||||||
HTTPMessage
|
|
||||||
IOAsync
|
|
||||||
IOAsyncSSL
|
|
||||||
IOSocketSSL
|
|
||||||
NetSSLeay
|
|
||||||
JSON
|
|
||||||
ListUtilsBy
|
|
||||||
ScalarListUtils
|
|
||||||
ModulePluggable
|
|
||||||
NetAsyncHTTP
|
|
||||||
MetricsAny # required by Net::Async::HTTP
|
|
||||||
NetAsyncHTTPServer
|
|
||||||
StructDumb
|
|
||||||
URI
|
|
||||||
YAMLLibYAML
|
|
||||||
]}";
|
|
||||||
|
|
||||||
# Clear the LD_LIBRARY_PATH environment variable on shell init.
|
|
||||||
#
|
|
||||||
# By default, devenv will set LD_LIBRARY_PATH to point to .devenv/profile/lib. This causes
|
|
||||||
# issues when we include `gcc` as a dependency to build C libraries, as the version of glibc
|
|
||||||
# that the development environment's cc compiler uses may differ from that of the system.
|
|
||||||
#
|
|
||||||
# When LD_LIBRARY_PATH is set, system tools will attempt to use the development environment's
|
|
||||||
# libraries. Which, when built against a different glibc version lead, to "version 'GLIBC_X.YY'
|
|
||||||
# not found" errors.
|
|
||||||
enterShell = ''
|
|
||||||
unset LD_LIBRARY_PATH
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user