973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2 | description = "Malice: a hosted Matrix client backed by macltok"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 3 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 4 | inputs = { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 6 | fenix = { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 7 | url = "github:nix-community/fenix"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 8 | inputs.nixpkgs.follows = "nixpkgs"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 9 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 10 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 11 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 12 | outputs = |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 13 | { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 14 | self, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 15 | nixpkgs, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 16 | fenix, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 17 | }: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 18 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 19 | systems = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 20 | "x86_64-linux" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 21 | "aarch64-linux" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 22 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 23 | forAllSystems = nixpkgs.lib.genAttrs systems; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 24 | cleanSrc = |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 25 | root: |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 26 | nixpkgs.lib.cleanSourceWith { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 27 | src = root; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 28 | filter = |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 29 | path: type: |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 30 | nixpkgs.lib.cleanSourceFilter path type |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 31 | && !( |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 32 | type == "directory" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 33 | && builtins.elem (baseNameOf path) [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 34 | "target" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 35 | "node_modules" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 36 | "dist" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 37 | "dist-device" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 38 | ] |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 39 | ); |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 40 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 41 | workerLock = builtins.fromTOML (builtins.readFile ./crates/malice-worker/Cargo.lock); |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 42 | lockedVersion = name: (nixpkgs.lib.findFirst (p: p.name == name) null workerLock.package).version; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 43 | # wasm-bindgen-test-runner refuses a module built by any other wasm-bindgen version |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 44 | wasmBindgenCli = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 45 | pkgs: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 46 | pkgs.buildWasmBindgenCli rec { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 47 | src = pkgs.fetchCrate { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 48 | pname = "wasm-bindgen-cli"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 49 | version = lockedVersion "wasm-bindgen"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 50 | hash = "sha256-a7lcXJnnZkYReja+iUO7NqqrWyv3toxnUgQb8s4IS5s="; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 51 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 52 | cargoDeps = pkgs.rustPlatform.fetchCargoVendor { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 53 | inherit src; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 54 | inherit (src) pname version; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 55 | hash = "sha256-R1Tas33Ursy8kqsxguAkG0ZhNed2n5uFTAhw1l2qlLY="; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 56 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 57 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 58 | wasmToolchain = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 59 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 60 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 61 | toolchains = fenix.packages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 62 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 63 | toolchains.combine [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 64 | toolchains.stable.cargo |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 65 | toolchains.stable.clippy |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 66 | toolchains.stable.rustc |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 67 | toolchains.stable.rustfmt |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 68 | toolchains.stable.rust-src |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 69 | toolchains.targets.wasm32-unknown-unknown.stable.rust-std |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 70 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 71 | webNodeModules = |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 72 | pkgs: |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 73 | pkgs.importNpmLock.buildNodeModules { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 74 | npmRoot = ./web; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 75 | nodejs = pkgs.nodejs_22; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 76 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 77 | buildWeb = |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 78 | pkgs: |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 79 | { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 80 | pname, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 81 | task, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 82 | outDir, |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 83 | postPatch ? "", |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 84 | }: |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 85 | pkgs.stdenvNoCC.mkDerivation { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 86 | inherit pname postPatch; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 87 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 88 | src = cleanSrc ./web; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 89 | npmDeps = webNodeModules pkgs; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 90 | nativeBuildInputs = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 91 | pkgs.nodejs_22 |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 92 | pkgs.importNpmLock.hooks.linkNodeModulesHook |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 93 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 94 | buildPhase = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 95 | runHook preBuild |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 96 | export HOME=$TMPDIR |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 97 | npm run ${task} |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 98 | runHook postBuild |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 99 | ''; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 100 | installPhase = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 101 | runHook preInstall |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 102 | mkdir -p $out/share/malice |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 103 | cp -R ${outDir}/. $out/share/malice/ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 104 | runHook postInstall |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 105 | ''; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 106 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 107 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 108 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 109 | packages = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 110 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 111 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 112 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 113 | wasmPlatform = pkgs.makeRustPlatform { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 114 | cargo = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 115 | rustc = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 116 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 117 | web = buildWeb pkgs { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 118 | pname = "malice-web"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 119 | task = "build"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 120 | outDir = "dist"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 121 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 122 | backend = pkgs.rustPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 123 | pname = "malice-server"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 124 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 125 | src = cleanSrc ./.; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 126 | cargoLock.lockFile = ./Cargo.lock; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 127 | nativeBuildInputs = [ pkgs.pkg-config ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 128 | buildInputs = [ pkgs.sqlite ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 129 | cargoBuildFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 130 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 131 | "malice" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 132 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 133 | cargoTestFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 134 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 135 | "malice" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 136 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 137 | # preBuild = "export NIX_BUILD_CORES=2"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 138 | preCheck = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 139 | cargo build --release --bin malice --target ${pkgs.stdenv.hostPlatform.rust.rustcTarget} --offline --locked |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 140 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 141 | SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 142 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 143 | staticServer = pkgs.rustPlatform.buildRustPackage { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 144 | pname = "malice-static"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 145 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 146 | src = cleanSrc ./.; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 147 | cargoLock.lockFile = ./Cargo.lock; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 148 | cargoBuildFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 149 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 150 | "malice-static" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 151 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 152 | cargoTestFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 153 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 154 | "malice-static" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 155 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 156 | meta.mainProgram = "malice-static"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 157 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 158 | server = pkgs.symlinkJoin { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 159 | name = "malice"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 160 | paths = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 161 | backend |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 162 | web |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 163 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 164 | nativeBuildInputs = [ pkgs.makeWrapper ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 165 | postBuild = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 166 | wrapProgram $out/bin/malice --set MALICE_WEB_DIR ${web}/share/malice |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 167 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 168 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 169 | # the wasm-bindgen `--target web` glue for malice-worker's `Host`, consumed by |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 170 | # web/src/worker/pkg (gitignored, worker-web's TS imports it as ./pkg/malice_worker.js) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 171 | workerWasm = wasmPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 172 | pname = "malice-worker-wasm"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 173 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 174 | src = cleanSrc ./.; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 175 | cargoRoot = "crates/malice-worker"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 176 | cargoLock.lockFile = ./crates/malice-worker/Cargo.lock; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 177 | nativeBuildInputs = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 178 | (wasmBindgenCli pkgs) |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 179 | pkgs.removeReferencesTo |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 180 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 181 | buildPhase = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 182 | runHook preBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 183 | cd crates/malice-worker |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 184 | cargo build --offline --frozen --release --lib --target wasm32-unknown-unknown |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 185 | mkdir -p $out |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 186 | wasm-bindgen --target web --out-dir $out --out-name malice_worker \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 187 | target/wasm32-unknown-unknown/release/malice_worker.wasm |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 188 | remove-references-to -t ${wasmToolchain system} $out/*.wasm |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 189 | runHook postBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 190 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 191 | doCheck = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 192 | installPhase = "true"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 193 | disallowedReferences = [ (wasmToolchain system) ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 194 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 195 | web-device = buildWeb pkgs { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 196 | pname = "malice-web-device"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 197 | task = "build:device"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 198 | outDir = "dist-device"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 199 | postPatch = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 200 | mkdir -p src/worker/pkg |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 201 | cp -R ${workerWasm}/. src/worker/pkg/ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 202 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 203 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 204 | local = pkgs.symlinkJoin { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 205 | name = "malice-local"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 206 | paths = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 207 | staticServer |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 208 | web-device |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 209 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 210 | nativeBuildInputs = [ pkgs.makeWrapper ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 211 | postBuild = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 212 | wrapProgram $out/bin/malice-static \ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 213 | --set MALICE_WEB_DIR ${web-device}/share/malice |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 214 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 215 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 216 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 217 | { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 218 | inherit |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 219 | web |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 220 | server |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 221 | web-device |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 222 | local |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 223 | ; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 224 | default = server; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 225 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 226 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 227 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 228 | devShells = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 229 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 230 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 231 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 232 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 233 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 234 | default = pkgs.mkShell { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 235 | packages = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 236 | (wasmToolchain system) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 237 | (wasmBindgenCli pkgs) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 238 | pkgs.rust-analyzer |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 239 | pkgs.nodejs_22 |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 240 | pkgs.importNpmLock.hooks.linkNodeModulesHook |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 241 | pkgs.pkg-config |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 242 | pkgs.sqlite |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 243 | pkgs.firefox |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 244 | pkgs.geckodriver |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 245 | pkgs.chromium |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 246 | pkgs.matrix-continuwuity |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 247 | pkgs.nushell |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 248 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 249 | CHROMIUM_PATH = nixpkgs.lib.getExe pkgs.chromium; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 250 | npmDeps = webNodeModules pkgs; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 251 | # the hook's own npmRoot would be a store path, so link into the checkout's web/ instead |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 252 | shellHook = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 253 | npmRoot="$(git rev-parse --show-toplevel 2>/dev/null || pwd)/web" linkNodeModulesHook |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 254 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 255 | # fenix's rustc links through its bundled rust-lld, which skips nix's ld-wrapper and so |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 256 | # the store rpaths, leaving the native server unable to find libsqlite3 at run time |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 257 | "CARGO_TARGET_${ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 258 | nixpkgs.lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] pkgs.stdenv.hostPlatform.config) |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 259 | }_RUSTFLAGS" = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 260 | "-C linker-features=-lld"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 261 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 262 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 263 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 264 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 265 | nixosModules.malice = import ./nix/module.nix { inherit self; }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 266 | nixosModules.default = self.nixosModules.malice; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 267 | checks = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 268 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 269 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 270 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 271 | wasmPlatform = pkgs.makeRustPlatform { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 272 | cargo = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 273 | rustc = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 274 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 275 | # continuwuity refuses to start without /etc/resolv.conf, which the build sandbox lacks, or with |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 276 | # stdenv's deliberately bogus SSL_CERT_FILE. no exec, run.nu launches through a shell that exits at |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 277 | # once and would trip --die-with-parent, so this shell stays as the parent run.nu kills |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 278 | sandboxedHomeserver = pkgs.writeShellScriptBin "conduwuit" '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 279 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 280 | ${pkgs.lib.getExe pkgs.bubblewrap} --die-with-parent --dev-bind / / --tmpfs /etc \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 281 | --ro-bind ${pkgs.writeText "resolv.conf" "nameserver 127.0.0.1\n"} /etc/resolv.conf \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 282 | ${pkgs.lib.getExe' pkgs.matrix-continuwuity "conduwuit"} "$@" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 283 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 284 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 285 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 286 | default = self.packages.${system}.default; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 287 | worker-wasm = self.packages.${system}.web-device; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 288 | worker-browser = wasmPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 289 | pname = "malice-worker-browser-check"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 290 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 291 | src = cleanSrc ./.; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 292 | cargoRoot = "crates/malice-worker"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 293 | cargoLock.lockFile = ./crates/malice-worker/Cargo.lock; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 294 | nativeBuildInputs = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 295 | (wasmBindgenCli pkgs) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 296 | pkgs.firefox |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 297 | pkgs.geckodriver |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 298 | sandboxedHomeserver |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 299 | pkgs.nushell |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 300 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 301 | buildPhase = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 302 | runHook preBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 303 | export HOME=$TMPDIR |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 304 | nu --no-config-file crates/malice-worker/run.nu |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 305 | runHook postBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 306 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 307 | doCheck = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 308 | installPhase = "touch $out"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 309 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 310 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 311 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 312 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 313 | } |