devenv.nix 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. { inputs, pkgs, ... }:
  2. {
  3. # Configure packages to install.
  4. # Search for package names at https://search.nixos.org/packages?channel=unstable
  5. packages = with pkgs; [
  6. # Native dependencies for running Synapse.
  7. icu
  8. libffi
  9. libjpeg
  10. libpqxx
  11. libwebp
  12. libxml2
  13. libxslt
  14. sqlite
  15. # Native dependencies for unit tests (SyTest also requires OpenSSL).
  16. openssl
  17. # Native dependencies for running Complement.
  18. olm
  19. # Development tools.
  20. poetry
  21. ];
  22. # Activate (and create if necessary) a poetry virtualenv on startup.
  23. enterShell = ''
  24. . "$(dirname $(poetry run which python))/activate"
  25. '';
  26. # Install dependencies for the additional programming languages
  27. # involved with Synapse development. Python is already available
  28. # from poetry's virtual environment.
  29. #
  30. # * Rust is used for developing and running Synapse.
  31. # * Golang is needed to run the Complement test suite.
  32. # * Perl is needed to run the SyTest test suite.
  33. languages.go.enable = true;
  34. languages.rust.enable = true;
  35. languages.rust.version = "latest";
  36. languages.perl.enable = true;
  37. # Postgres is needed to run Synapse with postgres support and
  38. # to run certain unit tests that require postgres.
  39. services.postgres.enable = true;
  40. # On the first invocation of `devenv up`, create a database for
  41. # Syanpse to store data in.
  42. services.postgres.initdbArgs = ["--locale=C" "--encoding=UTF8"];
  43. services.postgres.initialDatabases = [
  44. { name = "synapse"; }
  45. ];
  46. # Redis is needed in order to run Synapse in worker mode.
  47. services.redis.enable = true;
  48. # We wrap `poetry` with a bash script that disables the download
  49. # of binary wheels for certain packages if the user is running
  50. # NixOS. NixOS is special in that you can have multiple versions
  51. # of packages installed at once, including your libc linker!
  52. #
  53. # Some binaries built for Linux expect those to be in a certain
  54. # filepath, but that is not the case on NixOS. In that case, we
  55. # force compiling those binaries locally instead.
  56. scripts.poetry.exec = ''
  57. if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
  58. # We are running on NixOS.
  59. #
  60. # Prevent poetry from downloading known problematic,
  61. # dynamically-linked binaries for python dependencies.
  62. POETRY_INSTALLER_NO_BINARY=ruff ${pkgs.poetry}/bin/poetry $@
  63. else
  64. ${pkgs.poetry}/bin/poetry $@
  65. fi
  66. '';
  67. # Define the perl modules we require to run SyTest.
  68. #
  69. # This list was compiled by cross-referencing https://metacpan.org/
  70. # with the modules defined in './cpanfile' and then finding the
  71. # corresponding nix packages on https://search.nixos.org/packages.
  72. #
  73. # This was done until `./install-deps.pl --dryrun` produced no output.
  74. env.PERL5LIB = "${with pkgs.perl536Packages; makePerlPath [
  75. DBI
  76. ClassMethodModifiers
  77. CryptEd25519
  78. DataDump
  79. DBDPg
  80. DigestHMAC
  81. DigestSHA1
  82. EmailAddressXS
  83. EmailMIME
  84. EmailSimple # required by Email::Mime
  85. EmailMessageID # required by Email::Mime
  86. EmailMIMEContentType # required by Email::Mime
  87. TextUnidecode # required by Email::Mime
  88. ModuleRuntime # required by Email::Mime
  89. EmailMIMEEncodings # required by Email::Mime
  90. FilePath
  91. FileSlurper
  92. Future
  93. GetoptLong
  94. HTTPMessage
  95. IOAsync
  96. IOAsyncSSL
  97. IOSocketSSL
  98. NetSSLeay
  99. JSON
  100. ListUtilsBy
  101. ScalarListUtils
  102. ModulePluggable
  103. NetAsyncHTTP
  104. MetricsAny # required by Net::Async::HTTP
  105. NetAsyncHTTPServer
  106. StructDumb
  107. URI
  108. YAMLLibYAML
  109. ]}";
  110. }