diff --git a/changelog.d/15613.doc b/changelog.d/15613.doc new file mode 100644 index 000000000000..15cd983ace45 --- /dev/null +++ b/changelog.d/15613.doc @@ -0,0 +1 @@ +Flake.nix: warn users that at least 3.75GB of space is needed. diff --git a/changelog.d/15613.feature b/changelog.d/15613.feature new file mode 100644 index 000000000000..11924da602cb --- /dev/null +++ b/changelog.d/15613.feature @@ -0,0 +1 @@ +Flake.nix: `devenv up` now automatically starts synapse, configured to use redis and postgresql. diff --git a/flake.nix b/flake.nix index 7351571e61de..0df7f43f2c9b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,19 +1,21 @@ -# A nix flake that sets up a complete Synapse development environment. Dependencies +# A Nix flake that sets up a complete Synapse development environment. Dependencies # for the SyTest (https://github.com/matrix-org/sytest) and Complement # (https://github.com/matrix-org/complement) Matrix homeserver test suites are also # installed automatically. # -# You must have already installed nix (https://nixos.org) on your system to use this. -# nix can be installed on Linux or MacOS; NixOS is not required. Windows is not -# directly supported, but nix can be installed inside of WSL2 or even Docker +# You must have already installed Nix (https://nixos.org) on your system to use this. +# Nix can be installed on Linux or MacOS; NixOS is not required. Windows is not +# directly supported, but Nix can be installed inside of WSL2 or even Docker # containers. Please refer to https://nixos.org/download for details. # # You must also enable support for flakes in Nix. See the following for how to # do so permanently: https://nixos.wiki/wiki/Flakes#Enable_flakes # +# Be warned: you'll need over 3.75 GB of free space to download all the dependencies. +# # Usage: # -# With nix installed, navigate to the directory containing this flake and run +# With Nix installed, navigate to the directory containing this flake and run # `nix develop --impure`. The `--impure` is necessary in order to store state # locally from "services", such as PostgreSQL and Redis. # @@ -66,7 +68,7 @@ let pkgs = nixpkgs.legacyPackages.${system}; in { - # Everything is configured via devenv - a nix module for creating declarative + # 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 { @@ -153,11 +155,35 @@ # Redis is needed in order to run Synapse in worker mode. services.redis.enable = true; + # We are now ready to start Synapse. + + 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 + ''; + processes.synapse.exec = "poetry run python -m synapse.app.homeserver -c homeserver.yaml --config-directory 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. + # 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 [