diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66ecdce8c2f43d8d5d60dc63dac017899affe25b..9def2cf95bc86d05735372007acff3d37a945bce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,11 @@ env: # Custom nix binary cache if fork is being used ATTIC_ENDPOINT: ${{ vars.ATTIC_ENDPOINT }} ATTIC_PUBLIC_KEY: ${{ vars.ATTIC_PUBLIC_KEY }} - # Get error output from nix that we can actually use - NIX_CONFIG: show-trace = true + # Get error output from nix that we can actually use, and use our binary caches for the earlier CI steps + NIX_CONFIG: | + show-trace = true + extra-substituters = https://attic.kennel.juneis.dog/conduit https://attic.kennel.juneis.dog/conduwuit https://cache.lix.systems https://conduwuit.cachix.org + extra-trusted-public-keys = conduit:eEKoUwlQGDdYmAI/Q/0slVlegqh/QmAvQd7HBSm21Wk= conduwuit:BbycGUgTISsltcmH0qNjFR9dbrQNYgdIAcmViSGoVTE= cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o= conduwuit.cachix.org-1:MFRm6jcnfTf0jSAbmvLfhO3KBMt4px+1xaereWXp8Xg= permissions: packages: write @@ -115,7 +118,7 @@ jobs: - name: Prepare build environment run: | echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc" - nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv + nix profile install --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv direnv allow nix develop .#all-features --command true @@ -237,7 +240,7 @@ jobs: - name: Prepare build environment run: | echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc" - nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv + nix profile install --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv direnv allow nix develop .#all-features --command true diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ed0e898dd32f0fe44b40f738701ef6edcff07a26..c6f9133a9262114b4116f0e43fa86d188f1171cc 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -21,8 +21,11 @@ env: # Custom nix binary cache if fork is being used ATTIC_ENDPOINT: ${{ vars.ATTIC_ENDPOINT }} ATTIC_PUBLIC_KEY: ${{ vars.ATTIC_PUBLIC_KEY }} - # Get error output from nix that we can actually use - NIX_CONFIG: show-trace = true + # Get error output from nix that we can actually use, and use our binary caches for the earlier CI steps + NIX_CONFIG: | + show-trace = true + extra-substituters = https://attic.kennel.juneis.dog/conduit https://attic.kennel.juneis.dog/conduwuit https://cache.lix.systems https://conduwuit.cachix.org + extra-trusted-public-keys = conduit:eEKoUwlQGDdYmAI/Q/0slVlegqh/QmAvQd7HBSm21Wk= conduwuit:BbycGUgTISsltcmH0qNjFR9dbrQNYgdIAcmViSGoVTE= cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o= conduwuit.cachix.org-1:MFRm6jcnfTf0jSAbmvLfhO3KBMt4px+1xaereWXp8Xg= # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. @@ -98,7 +101,7 @@ jobs: - name: Prepare build environment run: | echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc" - nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv + nix profile install --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv direnv allow nix develop --command true diff --git a/Cargo.lock b/Cargo.lock index 7f8e3f77416405a4d60ee0e63bc7acd173124941..61cf48bdda15955678bd562ba79baefc7e85bf67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -769,7 +769,7 @@ dependencies = [ "regex", "reqwest", "ruma", - "ruma-identifiers-validation 0.9.5 (git+https://github.com/girlbossceo/ruwuma?rev=fd686e77950680462377c9105dfb4136dd49c7a0)", + "ruma-identifiers-validation", "rustyline-async", "serde", "serde_json", @@ -2988,7 +2988,7 @@ dependencies = [ "percent-encoding", "rand", "regex", - "ruma-identifiers-validation 0.9.5 (git+https://github.com/girlbossceo/ruwuma?rev=c51ccb2c68d2e3557eb12b1a49036531711ec0e5)", + "ruma-identifiers-validation", "ruma-macros", "serde", "serde_html_form", @@ -3015,7 +3015,7 @@ dependencies = [ "pulldown-cmark", "regex", "ruma-common", - "ruma-identifiers-validation 0.9.5 (git+https://github.com/girlbossceo/ruwuma?rev=c51ccb2c68d2e3557eb12b1a49036531711ec0e5)", + "ruma-identifiers-validation", "ruma-macros", "serde", "serde_json", @@ -3046,15 +3046,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "ruma-identifiers-validation" -version = "0.9.5" -source = "git+https://github.com/girlbossceo/ruwuma?rev=fd686e77950680462377c9105dfb4136dd49c7a0#fd686e77950680462377c9105dfb4136dd49c7a0" -dependencies = [ - "js_int", - "thiserror", -] - [[package]] name = "ruma-identity-service-api" version = "0.9.0" @@ -3074,7 +3065,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "ruma-identifiers-validation 0.9.5 (git+https://github.com/girlbossceo/ruwuma?rev=c51ccb2c68d2e3557eb12b1a49036531711ec0e5)", + "ruma-identifiers-validation", "serde", "syn 2.0.71", "toml", @@ -3138,8 +3129,8 @@ dependencies = [ [[package]] name = "rust-librocksdb-sys" -version = "0.23.1+9.3.1" -source = "git+https://github.com/zaidoon1/rust-rocksdb?rev=db1ba33c2b78ad228e2525e8902d059c24fc81a1#db1ba33c2b78ad228e2525e8902d059c24fc81a1" +version = "0.24.0+9.4.0" +source = "git+https://github.com/zaidoon1/rust-rocksdb?rev=4056a3b0f823013fec49f6d0b3e5698856e6476a#4056a3b0f823013fec49f6d0b3e5698856e6476a" dependencies = [ "bindgen", "bzip2-sys", @@ -3155,8 +3146,8 @@ dependencies = [ [[package]] name = "rust-rocksdb" -version = "0.27.1" -source = "git+https://github.com/zaidoon1/rust-rocksdb?rev=db1ba33c2b78ad228e2525e8902d059c24fc81a1#db1ba33c2b78ad228e2525e8902d059c24fc81a1" +version = "0.28.0" +source = "git+https://github.com/zaidoon1/rust-rocksdb?rev=4056a3b0f823013fec49f6d0b3e5698856e6476a#4056a3b0f823013fec49f6d0b3e5698856e6476a" dependencies = [ "libc", "rust-librocksdb-sys", @@ -4250,7 +4241,7 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" version = "0.1.40" -source = "git+https://github.com/girlbossceo/tracing?rev=b348dca742af641c47bc390261f60711c2af573c#b348dca742af641c47bc390261f60711c2af573c" +source = "git+https://github.com/girlbossceo/tracing?rev=4d78a14a5e03f539b8c6b475aefa08bb14e4de91#4d78a14a5e03f539b8c6b475aefa08bb14e4de91" dependencies = [ "log", "pin-project-lite", @@ -4261,7 +4252,7 @@ dependencies = [ [[package]] name = "tracing-attributes" version = "0.1.27" -source = "git+https://github.com/girlbossceo/tracing?rev=b348dca742af641c47bc390261f60711c2af573c#b348dca742af641c47bc390261f60711c2af573c" +source = "git+https://github.com/girlbossceo/tracing?rev=4d78a14a5e03f539b8c6b475aefa08bb14e4de91#4d78a14a5e03f539b8c6b475aefa08bb14e4de91" dependencies = [ "proc-macro2", "quote", @@ -4271,7 +4262,7 @@ dependencies = [ [[package]] name = "tracing-core" version = "0.1.32" -source = "git+https://github.com/girlbossceo/tracing?rev=b348dca742af641c47bc390261f60711c2af573c#b348dca742af641c47bc390261f60711c2af573c" +source = "git+https://github.com/girlbossceo/tracing?rev=4d78a14a5e03f539b8c6b475aefa08bb14e4de91#4d78a14a5e03f539b8c6b475aefa08bb14e4de91" dependencies = [ "once_cell", "valuable", @@ -4291,7 +4282,7 @@ dependencies = [ [[package]] name = "tracing-log" version = "0.2.0" -source = "git+https://github.com/girlbossceo/tracing?rev=b348dca742af641c47bc390261f60711c2af573c#b348dca742af641c47bc390261f60711c2af573c" +source = "git+https://github.com/girlbossceo/tracing?rev=4d78a14a5e03f539b8c6b475aefa08bb14e4de91#4d78a14a5e03f539b8c6b475aefa08bb14e4de91" dependencies = [ "log", "once_cell", @@ -4319,7 +4310,7 @@ dependencies = [ [[package]] name = "tracing-subscriber" version = "0.3.18" -source = "git+https://github.com/girlbossceo/tracing?rev=b348dca742af641c47bc390261f60711c2af573c#b348dca742af641c47bc390261f60711c2af573c" +source = "git+https://github.com/girlbossceo/tracing?rev=4d78a14a5e03f539b8c6b475aefa08bb14e4de91#4d78a14a5e03f539b8c6b475aefa08bb14e4de91" dependencies = [ "matchers", "nu-ansi-term", diff --git a/Cargo.toml b/Cargo.toml index f9696252bd2cbec71a7f89a781698ab38026e7cc..7c17d0f7bef7fe5d6adc7ab86186707990992f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,7 @@ features = [ [workspace.dependencies.ruma-identifiers-validation] git = "https://github.com/girlbossceo/ruwuma" -rev = "fd686e77950680462377c9105dfb4136dd49c7a0" +rev = "c51ccb2c68d2e3557eb12b1a49036531711ec0e5" [workspace.dependencies.rust-rocksdb] path = "deps/rust-rocksdb" @@ -405,8 +405,8 @@ features = [ ] [workspace.dependencies.rustyline-async] -git = "https://github.com/girlbossceo/rustyline-async" -rev = "de26100b0db03e419a3d8e1dd26895d170d1fe50" +version = "0.4.2" +default-features = false [workspace.dependencies.termimad] version = "0.29.4" @@ -425,16 +425,16 @@ version = "0.1" # https://github.com/girlbossceo/tracing/commit/b348dca742af641c47bc390261f60711c2af573c [patch.crates-io.tracing-subscriber] git = "https://github.com/girlbossceo/tracing" -rev = "b348dca742af641c47bc390261f60711c2af573c" +rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91" [patch.crates-io.tracing] git = "https://github.com/girlbossceo/tracing" -rev = "b348dca742af641c47bc390261f60711c2af573c" +rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91" [patch.crates-io.tracing-core] git = "https://github.com/girlbossceo/tracing" -rev = "b348dca742af641c47bc390261f60711c2af573c" +rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91" [patch.crates-io.tracing-log] git = "https://github.com/girlbossceo/tracing" -rev = "b348dca742af641c47bc390261f60711c2af573c" +rev = "4d78a14a5e03f539b8c6b475aefa08bb14e4de91" # fixes hyper graceful shutdowns [https://github.com/programatik29/axum-server/issues/114] # https://github.com/girlbossceo/axum-server/commit/8e3368d899079818934e61cc9c839abcbbcada8a @@ -442,6 +442,12 @@ rev = "b348dca742af641c47bc390261f60711c2af573c" git = "https://github.com/girlbossceo/axum-server" rev = "8e3368d899079818934e61cc9c839abcbbcada8a" +# adds a tab completion callback: https://github.com/girlbossceo/rustyline-async/commit/de26100b0db03e419a3d8e1dd26895d170d1fe50 +# adds event for CTRL+\: https://github.com/girlbossceo/rustyline-async/commit/67d8c49aeac03a5ef4e818f663eaa94dd7bf339b +[patch.crates-io.rustyline-async] +git = "https://github.com/girlbossceo/rustyline-async" +rev = "de26100b0db03e419a3d8e1dd26895d170d1fe50" + # # Our crates # diff --git a/conduwuit-example.toml b/conduwuit-example.toml index ea095bfa11451c0b5457cb336a86e2488fb13915..57093128104805c648c9d1197998f83209b6b0d0 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -421,8 +421,11 @@ allow_profile_lookup_federation_requests = true # Set this to any float value to multiply conduwuit's in-memory LRU caches with. # May be useful if you have significant memory to spare to increase performance. +# +# This was previously called `conduit_cache_capacity_modifier` +# # Defaults to 1.0. -#conduit_cache_capacity_modifier = 1.0 +#cache_capacity_modifier = 1.0 # Set this to any float value in megabytes for conduwuit to tell the database engine that this much memory is available for database-related caches. # May be useful if you have significant memory to spare to increase performance. diff --git a/deps/rust-rocksdb/Cargo.toml b/deps/rust-rocksdb/Cargo.toml index 57b714912bae67ae90d80665ab135ea2a5e633f5..cf49e1adbe5bc1f75719167b331bb9082e3d0c74 100644 --- a/deps/rust-rocksdb/Cargo.toml +++ b/deps/rust-rocksdb/Cargo.toml @@ -27,7 +27,7 @@ malloc-usable-size = ["rust-rocksdb/malloc-usable-size"] [dependencies.rust-rocksdb] git = "https://github.com/zaidoon1/rust-rocksdb" -rev = "db1ba33c2b78ad228e2525e8902d059c24fc81a1" +rev = "4056a3b0f823013fec49f6d0b3e5698856e6476a" #branch = "master" default-features = false diff --git a/docs/deploying/generic.md b/docs/deploying/generic.md index 75b285d1273d45d882a39a8018c8ac92ad14f74b..0cbd8ef856838417ed912571589c89471ddef384 100644 --- a/docs/deploying/generic.md +++ b/docs/deploying/generic.md @@ -23,7 +23,7 @@ ## Adding a conduwuit user While conduwuit can run as any user it is better to use dedicated users for different services. This also allows you to make sure that the file permissions are correctly set up. -In Debian or RHEL, you can use this command to create a conduwuit user: +In Debian or Fedora/RHEL, you can use this command to create a conduwuit user: ```bash sudo adduser --system conduwuit --group --disabled-login --no-create-home @@ -53,13 +53,11 @@ ## Creating the conduwuit configuration file ## Setting the correct file permissions -If you are using a dedicated user for conduwuit, you will need to allow it to read the config. To do that you can run this command on - -Debian or RHEL: +If you are using a dedicated user for conduwuit, you will need to allow it to read the config. To do that you can run this: ```bash sudo chown -R root:root /etc/conduwuit -sudo chmod 755 /etc/conduwuit +sudo chmod -R 755 /etc/conduwuit ``` If you use the default database path you also need to run this: diff --git a/engage.toml b/engage.toml index d28ecff1cd2e3338384601e20179bfc1cee75946..8bba0eafeaa261b174c055e38875f32eb78c1fe2 100644 --- a/engage.toml +++ b/engage.toml @@ -184,6 +184,10 @@ cargo test \ name = "nix-default" group = "tests" script = """ -bin/nix-build-and-cache just .#default -nix run -L .#default -- --help +env DIRENV_DEVSHELL=dynamic \ + direnv exec . \ + bin/nix-build-and-cache just .#default +env DIRENV_DEVSHELL=dynamic \ + direnv exec . \ + nix run -L .#default -- --help """ diff --git a/flake.lock b/flake.lock index 4e6721b258d2b644acead2381838d24af017a6b8..9d7a162efcfbbd60a57c3b8adf55147d7b0753d0 100644 --- a/flake.lock +++ b/flake.lock @@ -9,11 +9,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1717279440, - "narHash": "sha256-kH04ReTjxOpQumgWnqy40vvQLSnLGxWP6RF3nq5Esrk=", + "lastModified": 1720542474, + "narHash": "sha256-aKjJ/4l2I9+wNGTaOGRsuS3M1+IoTibqgEMPDikXm04=", "owner": "zhaofengli", "repo": "attic", - "rev": "717cc95983cdc357bc347d70be20ced21f935843", + "rev": "6139576a3ce6bb992e0f6c3022528ec233e45f00", "type": "github" }, "original": { @@ -81,11 +81,11 @@ "complement": { "flake": false, "locked": { - "lastModified": 1719903368, - "narHash": "sha256-PPzgxM4Bir+Zh9FUV/v+RBxEYeJxYVmi/BYo3uqt268=", + "lastModified": 1720637557, + "narHash": "sha256-oZz6nCmFmdJZpC+K1iOG2KkzTI6rlAmndxANPDVU7X0=", "owner": "matrix-org", "repo": "complement", - "rev": "bc97f1ddc1cd7485faf80c8935ee2641f3e1b57c", + "rev": "0d14432e010482ea9e13a6f7c47c1533c0c9d62f", "type": "github" }, "original": { @@ -123,11 +123,11 @@ ] }, "locked": { - "lastModified": 1720226507, - "narHash": "sha256-yHVvNsgrpyNTXZBEokL8uyB2J6gB1wEx0KOJzoeZi1A=", + "lastModified": 1720546058, + "narHash": "sha256-iU2yVaPIZm5vMGdlT0+57vdB/aPq/V5oZFBRwYw+HBM=", "owner": "ipetkov", "repo": "crane", - "rev": "0aed560c5c0a61c9385bddff471a13036203e11c", + "rev": "2d83156f23c43598cf44e152c33a59d3892f8b29", "type": "github" }, "original": { @@ -209,11 +209,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1720420198, - "narHash": "sha256-OIuDb6pHDyGpo7YMFyuRzMLcHm7mRvlYOz0Ht7ps2sU=", + "lastModified": 1720852044, + "narHash": "sha256-3NBYz8VuXuKU+8ONd9NFafCNjPEGHIZQ2Mdoam1a4mY=", "owner": "nix-community", "repo": "fenix", - "rev": "abc0549e3560189462a7d394cc9d50af4608d103", + "rev": "5087b12a595ee73131a944d922f24d81dae05725", "type": "github" }, "original": { @@ -381,11 +381,11 @@ "liburing": { "flake": false, "locked": { - "lastModified": 1719025212, - "narHash": "sha256-kD0yhjNStqC6uFqC1AxBwUpc/HlSFtiKrV+gwDyroDc=", + "lastModified": 1720798442, + "narHash": "sha256-gtPppAoksMLW4GuruQ36nf4EAqIA1Bs6V9Xcx8dBxrQ=", "owner": "axboe", "repo": "liburing", - "rev": "7b3245583069bd481190c9da18f22e9fc8c3a805", + "rev": "1d674f83b7d0f07553ac44d99a401b05853d9dbe", "type": "github" }, "original": { @@ -606,11 +606,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1720418205, - "narHash": "sha256-cPJoFPXU44GlhWg4pUk9oUPqurPlCFZ11ZQPk21GTPU=", + "lastModified": 1720768451, + "narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "655a58a72a6601292512670343087c2d75d859c1", + "rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9", "type": "github" }, "original": { @@ -673,16 +673,16 @@ "rocksdb": { "flake": false, "locked": { - "lastModified": 1719949653, - "narHash": "sha256-DYx7XHH2GEh17GukKhXs6laM6l+eugCmRkF0adpi9wk=", + "lastModified": 1720900786, + "narHash": "sha256-Vta9Um/RRuWwZ46BjXftV06iWLm/j/9MX39emXUvSAY=", "owner": "girlbossceo", "repo": "rocksdb", - "rev": "a935c0273e1ba44eacf88ce3685a9b9831486155", + "rev": "911f4243e69c2e320a7a209bf1f5f3ff5f825495", "type": "github" }, "original": { "owner": "girlbossceo", - "ref": "v9.3.1", + "ref": "v9.4.0", "repo": "rocksdb", "type": "github" } @@ -705,11 +705,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1720344064, - "narHash": "sha256-STmaV9Zu74QtkGGrbr9uMhskwagfCjJqOAYapXabiuk=", + "lastModified": 1720717809, + "narHash": "sha256-6I+fm+nTLF/iaj7ffiFGlSY7POmubwUaPA/Wq0Bm53M=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "a5b21ea0aa644dffd7cf958b43f11f221d53404e", + "rev": "ffbc5ad993d5cd2f3b8bcf9a511165470944ab91", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e20da52ba8eab6ca13f0ce9522b09d0ef5cfdbe5..a56d1bc0ad3773d9db3d63bd36abb59fb1d09dd5 100644 --- a/flake.nix +++ b/flake.nix @@ -9,8 +9,7 @@ flake-utils.url = "github:numtide/flake-utils?ref=main"; nix-filter.url = "github:numtide/nix-filter?ref=main"; nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; - # https://github.com/girlbossceo/rocksdb/commit/db6df0b185774778457dabfcbd822cb81760cade - rocksdb = { url = "github:girlbossceo/rocksdb?ref=v9.3.1"; flake = false; }; + rocksdb = { url = "github:girlbossceo/rocksdb?ref=v9.4.0"; flake = false; }; liburing = { url = "github:axboe/liburing?ref=master"; flake = false; }; }; @@ -45,10 +44,34 @@ # we have this already at https://github.com/girlbossceo/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155 # unsetting this so i don't have to revert it and make this nix exclusive patches = []; - # no real reason to have snappy, no one uses this cmakeFlags = pkgs.lib.subtractLists - [ "-DWITH_SNAPPY=1" ] - old.cmakeFlags; + [ + # no real reason to have snappy, no one uses this + "-DWITH_SNAPPY=1" + # we dont need to use ldb or sst_dump (core_tools) + "-DWITH_CORE_TOOLS=1" + # we dont need to build rocksdb tests + "-DWITH_TESTS=1" + # we use rust-rocksdb via C interface and dont need C++ RTTI + "-DUSE_RTTI=1" + ] + old.cmakeFlags + ++ [ + # we dont need to use ldb or sst_dump (core_tools) + "-DWITH_CORE_TOOLS=0" + # we dont need trace tools + "-DWITH_TRACE_TOOLS=0" + # we dont need to build rocksdb tests + "-DWITH_TESTS=0" + # we use rust-rocksdb via C interface and dont need C++ RTTI + "-DUSE_RTTI=0" + ]; + + # outputs has "tools" which we dont need or use + outputs = [ "out" ]; + + # preInstall hooks has stuff for messing with ldb/sst_dump which we dont need or use + preInstall = ""; }); # TODO: remove once https://github.com/NixOS/nixpkgs/pull/314945 is available liburing = pkgs.liburing.overrideAttrs (old: { @@ -123,8 +146,12 @@ default = scopeHost.main; all-features = scopeHost.main.override { all_features = true; - # this is non-functional on nix for some reason - disable_features = ["hardened_malloc"]; + disable_features = [ + # this is non-functional on nix for some reason + "hardened_malloc" + # dont include experimental features + "experimental" + ]; }; hmalloc = scopeHost.main.override { features = ["hardened_malloc"]; }; @@ -132,8 +159,12 @@ oci-image-all-features = scopeHost.oci-image.override { main = scopeHost.main.override { all_features = true; - # this is non-functional on nix for some reason - disable_features = ["hardened_malloc"]; + disable_features = [ + # this is non-functional on nix for some reason + "hardened_malloc" + # dont include experimental features + "experimental" + ]; }; }; oci-image-hmalloc = scopeHost.oci-image.override { @@ -175,8 +206,12 @@ name = "${binaryName}-all-features"; value = scopeCrossStatic.main.override { all_features = true; - # this is non-functional on nix for some reason - disable_features = ["hardened_malloc"]; + disable_features = [ + # this is non-functional on nix for some reason + "hardened_malloc" + # dont include experimental features + "experimental" + ]; }; } @@ -200,8 +235,12 @@ value = scopeCrossStatic.oci-image.override { main = scopeCrossStatic.main.override { all_features = true; - # this is non-functional on nix for some reason - disable_features = ["hardened_malloc"]; + disable_features = [ + # this is non-functional on nix for some reason + "hardened_malloc" + # dont include experimental features + "experimental" + ]; }; }; } @@ -229,8 +268,12 @@ (scopeHostStatic.overrideScope (final: prev: { main = prev.main.override { all_features = true; - # this is non-functional on nix for some reason - disable_features = ["hardened_malloc"]; + disable_features = [ + # this is non-functional on nix for some reason + "hardened_malloc" + # dont include experimental features + "experimental" + ]; }; })); devShells.no-features = mkDevShell diff --git a/nix/pkgs/main/cross-compilation-env.nix b/nix/pkgs/main/cross-compilation-env.nix index 83fe6ed60221817af8223d54a71ba10faa6b7120..75b5862fcfc9d5e059554f5442b828d786243c29 100644 --- a/nix/pkgs/main/cross-compilation-env.nix +++ b/nix/pkgs/main/cross-compilation-env.nix @@ -13,6 +13,12 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic { lib.concatStringsSep " " ([] + ++ lib.optionals + stdenv.targetPlatform.isx86_64 + [ "-C" "target-cpu=x86-64-v2" ] + ++ lib.optionals + stdenv.targetPlatform.isAarch64 + [ "-C" "target-cpu=cortex-a55" ] # cortex-a55 == ARMv8.2-a # This disables PIE for static builds, which isn't great in terms # of security. Unfortunately, my hand is forced because nixpkgs' # `libstdc++.a` is built without `-fPIE`, which precludes us from diff --git a/nix/pkgs/main/default.nix b/nix/pkgs/main/default.nix index e3d23a437765d9d40cb9fbcac1b87a4dead76764..629957c82b6277d518463abe02c6761fa05cb883 100644 --- a/nix/pkgs/main/default.nix +++ b/nix/pkgs/main/default.nix @@ -71,10 +71,29 @@ buildDepsOnlyEnv = # which breaks Darwin entirely enableLiburing = enableLiburing; }).overrideAttrs (old: { - # TODO: static rocksdb fails to build on darwin + # TODO: static rocksdb fails to build on darwin, also see <https://github.com/NixOS/nixpkgs/issues/320448> # build log at <https://girlboss.ceo/~strawberry/pb/JjGH> meta.broken = stdenv.hostPlatform.isStatic && stdenv.isDarwin; + enableLiburing = enableLiburing; + + sse42Support = stdenv.targetPlatform.isx86_64; + + cmakeFlags = if stdenv.targetPlatform.isx86_64 + then lib.subtractLists [ "-DPORTABLE=1" ] old.cmakeFlags + ++ lib.optionals stdenv.targetPlatform.isx86_64 [ + "-DPORTABLE=x86-64-v2" + "-DUSE_SSE=1" + "-DHAVE_SSE=1" + "-DHAVE_SSE42=1" + ] + else if stdenv.targetPlatform.isAarch64 + then lib.subtractLists [ "-DPORTABLE=1" ] old.cmakeFlags + ++ lib.optionals stdenv.targetPlatform.isAarch64 [ + # cortex-a55 == ARMv8.2-a + "-DPORTABLE=armv8.2-a" + ] + else old.cmakeFlags; }); in { @@ -101,7 +120,11 @@ buildPackageEnv = { # Only needed in static stdenv because these are transitive dependencies of rocksdb CARGO_BUILD_RUSTFLAGS = buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS + lib.optionalString (enableLiburing && stdenv.hostPlatform.isStatic) - " -L${lib.getLib liburing}/lib -luring"; + " -L${lib.getLib liburing}/lib -luring" + + lib.optionalString stdenv.targetPlatform.isx86_64 + " -Ctarget-cpu=x86-64-v2" + + lib.optionalString stdenv.targetPlatform.isAarch64 + " -Ctarget-cpu=cortex-a55"; # cortex-a55 == ARMv8.2-a }; @@ -126,6 +149,8 @@ commonAttrs = { ]; }; + dontStrip = profile == "dev"; + buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys'; nativeBuildInputs = [ diff --git a/src/api/client/directory.rs b/src/api/client/directory.rs index 68bd0dffcec46ce94e7b8cbfe4b4003da39b12aa..8e12c03432a4aee65e248c2156f92d637623f692 100644 --- a/src/api/client/directory.rs +++ b/src/api/client/directory.rs @@ -117,7 +117,12 @@ pub(crate) async fn set_room_visibility_route( return Err(Error::BadRequest(ErrorKind::NotFound, "Room not found")); } - user_can_publish_room(sender_user, &body.room_id)?; + if !user_can_publish_room(sender_user, &body.room_id)? { + return Err(Error::BadRequest( + ErrorKind::forbidden(), + "User is not allowed to publish this room", + )); + } match &body.visibility { room::Visibility::Public => { @@ -377,8 +382,8 @@ fn user_can_publish_room(user_id: &UserId, room_id: &RoomId) -> Result<bool> { Ok(event.sender == user_id) } else { return Err(Error::BadRequest( - ErrorKind::Unauthorized, - "You are not allowed to publish this room to the room directory", + ErrorKind::forbidden(), + "User is not allowed to publish this room", )); } } diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 336144db52ec2b8d948f1adfd05cde9b56ef45a3..b40ebb65febe218b9082aacc5b49e00cd3ebee01 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -58,8 +58,8 @@ pub struct Config { #[serde(default = "default_pdu_cache_capacity")] pub pdu_cache_capacity: u32, - #[serde(default = "default_conduit_cache_capacity_modifier")] - pub conduit_cache_capacity_modifier: f64, + #[serde(default = "default_cache_capacity_modifier", alias = "conduit_cache_capacity_modifier")] + pub cache_capacity_modifier: f64, #[serde(default = "default_auth_chain_cache_capacity")] pub auth_chain_cache_capacity: u32, #[serde(default = "default_shorteventid_cache_capacity")] @@ -391,8 +391,9 @@ struct ListeningAddr { addrs: Either<IpAddr, Vec<IpAddr>>, } -const DEPRECATED_KEYS: &[&str] = &[ +const DEPRECATED_KEYS: &[&str; 9] = &[ "cache_capacity", + "conduit_cache_capacity_modifier", "max_concurrent_requests", "well_known_client", "well_known_server", @@ -484,7 +485,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ); line("Database backups to keep", &self.database_backups_to_keep.to_string()); line("Database cache capacity (MB)", &self.db_cache_capacity_mb.to_string()); - line("Cache capacity modifier", &self.conduit_cache_capacity_modifier.to_string()); + line("Cache capacity modifier", &self.cache_capacity_modifier.to_string()); line("PDU cache capacity", &self.pdu_cache_capacity.to_string()); line("Auth chain cache capacity", &self.auth_chain_cache_capacity.to_string()); line("Short eventid cache capacity", &self.shorteventid_cache_capacity.to_string()); @@ -847,7 +848,7 @@ fn default_db_cache_capacity_mb() -> f64 { 256.0 } fn default_pdu_cache_capacity() -> u32 { 150_000 } -fn default_conduit_cache_capacity_modifier() -> f64 { 1.0 } +fn default_cache_capacity_modifier() -> f64 { 1.0 } fn default_auth_chain_cache_capacity() -> u32 { 100_000 } diff --git a/src/database/opts.rs b/src/database/opts.rs index 1b9c163fb74949d197643ec4239dd8e7031e59a3..d223645489a7a2825462ba38735da28a8ab5ab93 100644 --- a/src/database/opts.rs +++ b/src/database/opts.rs @@ -310,7 +310,7 @@ fn set_table_with_shared_cache( } fn cache_size(config: &Config, base_size: u32, entity_size: usize) -> usize { - let ents = f64::from(base_size) * config.conduit_cache_capacity_modifier; + let ents = f64::from(base_size) * config.cache_capacity_modifier; #[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)] (ents as usize) diff --git a/src/service/rooms/auth_chain/data.rs b/src/service/rooms/auth_chain/data.rs index 5efb36c2a3ecb70b5382f077b8bb4c53fed4f406..4e46823439a7c5eaa44e38394820d935265c0849 100644 --- a/src/service/rooms/auth_chain/data.rs +++ b/src/service/rooms/auth_chain/data.rs @@ -16,7 +16,7 @@ impl Data { pub(super) fn new(server: &Arc<Server>, db: &Arc<Database>) -> Self { let config = &server.config; let cache_size = f64::from(config.auth_chain_cache_capacity); - let cache_size = usize_from_f64(cache_size * config.conduit_cache_capacity_modifier).expect("valid cache size"); + let cache_size = usize_from_f64(cache_size * config.cache_capacity_modifier).expect("valid cache size"); Self { shorteventid_authchain: db["shorteventid_authchain"].clone(), auth_chain_cache: Mutex::new(LruCache::new(cache_size)), diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs index 18133fc1f9565583f490f9b64d181ed81e75a48c..02db7fab1a8632f89f5a0f44606832c25adce56f 100644 --- a/src/service/rooms/spaces/mod.rs +++ b/src/service/rooms/spaces/mod.rs @@ -161,7 +161,7 @@ impl crate::Service for Service { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { let config = &args.server.config; let cache_size = f64::from(config.roomid_spacehierarchy_cache_capacity); - let cache_size = cache_size * config.conduit_cache_capacity_modifier; + let cache_size = cache_size * config.cache_capacity_modifier; Ok(Arc::new(Self { roomid_spacehierarchy_cache: Mutex::new(LruCache::new(usize_from_f64(cache_size)?)), })) diff --git a/src/service/rooms/state_accessor/mod.rs b/src/service/rooms/state_accessor/mod.rs index 7abe5e0fc5ff5ecedc3b5a4bb6ef9e988c85f83c..bd3eb0a1557b8ce1b18a12fafdd40a7ddb5ce29e 100644 --- a/src/service/rooms/state_accessor/mod.rs +++ b/src/service/rooms/state_accessor/mod.rs @@ -45,9 +45,9 @@ impl crate::Service for Service { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { let config = &args.server.config; let server_visibility_cache_capacity = - f64::from(config.server_visibility_cache_capacity) * config.conduit_cache_capacity_modifier; + f64::from(config.server_visibility_cache_capacity) * config.cache_capacity_modifier; let user_visibility_cache_capacity = - f64::from(config.user_visibility_cache_capacity) * config.conduit_cache_capacity_modifier; + f64::from(config.user_visibility_cache_capacity) * config.cache_capacity_modifier; Ok(Arc::new(Self { db: Data::new(args.db), diff --git a/src/service/rooms/state_compressor/mod.rs b/src/service/rooms/state_compressor/mod.rs index 4b4ea7d4e9f01d5f67a3830a23ddb7a3e9d924eb..422c562b8141977ec85e144770b81cfb0a53a74f 100644 --- a/src/service/rooms/state_compressor/mod.rs +++ b/src/service/rooms/state_compressor/mod.rs @@ -55,7 +55,7 @@ pub struct Service { impl crate::Service for Service { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { let config = &args.server.config; - let cache_capacity = f64::from(config.stateinfo_cache_capacity) * config.conduit_cache_capacity_modifier; + let cache_capacity = f64::from(config.stateinfo_cache_capacity) * config.cache_capacity_modifier; Ok(Arc::new(Self { db: Data::new(args.db), stateinfo_cache: StdMutex::new(LruCache::new(usize_from_f64(cache_capacity)?)),