diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2023-01-04 21:00:25 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2023-01-18 15:36:35 +0000 |
commit | 1e64f9c255082976a75b7fc5002a92326cb13318 (patch) | |
tree | 0d6ea736e8c3437b5a5d193246b4a4df1153923f | |
parent | Remove outdated commands from the code style doc & point to the contributing ... (diff) | |
download | synapse-github/anoa/devenv.tar.xz |
Add support for devenv developer environments github/anoa/devenv anoa/devenv
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | devenv.lock | 177 | ||||
-rw-r--r-- | devenv.nix | 122 | ||||
-rw-r--r-- | devenv.yaml | 8 |
4 files changed, 312 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 6937de88bc..67a329a07e 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,8 @@ book/ # Don't include users' poetry configs /poetry.toml + +# Devenv +.devenv* +devenv.local.nix + diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000000..9aa0cc57b2 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,177 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1673960114, + "narHash": "sha256-YNCok1a8cy71nP0idJds2Dwn2B1T6zGw9+2H1A0lNa0=", + "owner": "cachix", + "repo": "devenv", + "rev": "0960585a7221e6ede718cc9a2c2eade7ce75c229", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1674023045, + "narHash": "sha256-btQC+gTeVLmX9cYl/6Kig7BuDltVWJEh7TrITAc6QjA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "75dbe699bc57323cdef636b82bcfef6028bd1530", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1673947312, + "narHash": "sha256-xx/2nRwRy3bXrtry6TtydKpJpqHahjuDB5sFkQ/XNDE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d38b664b4400335086a713a0036aafaa002c003", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1671271954, + "narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1674046351, + "narHash": "sha256-vNErPj4gfO/G1vHuOh5/IbjLaydwePcRlD0fXlnUbmI=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "756cc26afb75b0f8bfec48bbc54a8836a04953fb", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "fenix": "fenix", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1673979364, + "narHash": "sha256-ecgQENol9XhhcYF+M9B8FMrsWYQ/ZvRsvgEWi8HI6D0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "3a7271336536f2cd558498755254ae8c0e73baa7", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000000..8874df3a94 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,122 @@ +{ inputs, pkgs, ... }: + +{ + # Configure packages to install. + # Search for package names at https://search.nixos.org/packages?channel=unstable + packages = with pkgs; [ + # Native dependencies for running Synapse. + icu + libffi + libjpeg + libpqxx + libwebp + libxml2 + libxslt + sqlite + + # Native dependencies for unit tests (SyTest also requires OpenSSL). + openssl + + # Native dependencies for running Complement. + olm + + # Development tools. + poetry + ]; + + # Activate (and create if necessary) a poetry virtualenv on startup. + enterShell = '' + . "$(dirname $(poetry run which python))/activate" + ''; + + # Install dependencies for the additional programming languages + # involved with Synapse development. Python is already available + # from poetry's virtual environment. + # + # * Rust is used for developing and running Synapse. + # * Golang is needed to run the Complement test suite. + # * Perl is needed to run the SyTest test suite. + languages.go.enable = true; + languages.rust.enable = true; + languages.rust.version = "latest"; + 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 + # Syanpse to store data in. + services.postgres.initdbArgs = ["--locale=C" "--encoding=UTF8"]; + services.postgres.initialDatabases = [ + { name = "synapse"; } + ]; + + # Redis is needed in order to run Synapse in worker mode. + services.redis.enable = true; + + # We wrap `poetry` with a bash script that disables the download + # of binary wheels for certain packages if the user is running + # NixOS. 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. + scripts.poetry.exec = '' + if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then + # We are running on NixOS. + # + # Prevent poetry from downloading known problematic, + # dynamically-linked binaries for python dependencies. + POETRY_INSTALLER_NO_BINARY=ruff ${pkgs.poetry}/bin/poetry $@ + else + ${pkgs.poetry}/bin/poetry $@ + fi + ''; + + # 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 + ]}"; + +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000000..87a8faa412 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,8 @@ +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable + fenix: + url: github:nix-community/fenix + inputs: + nixpkgs: + follows: nixpkgs \ No newline at end of file |