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; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 90 | disallowedReferences = [ |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 91 | (webNodeModules pkgs) |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 92 | pkgs.nodejs_22 |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 93 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 94 | nativeBuildInputs = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 95 | pkgs.nodejs_22 |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 96 | pkgs.importNpmLock.hooks.linkNodeModulesHook |
54e1929170a7 | atagen | 2026-10-26 03:48 UTC | 97 | pkgs.brotli |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 98 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 99 | buildPhase = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 100 | runHook preBuild |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 101 | export HOME=$TMPDIR |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 102 | npm run ${task} |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 103 | runHook postBuild |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 104 | ''; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 105 | installPhase = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 106 | runHook preInstall |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 107 | mkdir -p $out/share/malice |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 108 | cp -R ${outDir}/. $out/share/malice/ |
54e1929170a7 | atagen | 2026-10-26 03:48 UTC | 109 | find $out/share/malice -type f \( -name '*.wasm' -o -name '*.js' -o -name '*.css' -o -name '*.html' -o -name '*.svg' -o -name '*.json' -o -name '*.webmanifest' \) -size +1k \ |
54e1929170a7 | atagen | 2026-10-26 03:48 UTC | 110 | -exec brotli --best --keep {} \; -exec gzip -9 --keep {} \; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 111 | runHook postInstall |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 112 | ''; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 113 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 114 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 115 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 116 | packages = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 117 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 118 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 119 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 120 | wasmPlatform = pkgs.makeRustPlatform { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 121 | cargo = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 122 | rustc = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 123 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 124 | web = buildWeb pkgs { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 125 | pname = "malice-web"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 126 | task = "build"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 127 | outDir = "dist"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 128 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 129 | backend = pkgs.rustPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 130 | pname = "malice-server"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 131 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 132 | src = cleanSrc ./.; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 133 | cargoLock = { |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 134 | lockFile = ./Cargo.lock; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 135 | allowBuiltinFetchGit = true; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 136 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 137 | nativeBuildInputs = [ pkgs.pkg-config ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 138 | buildInputs = [ pkgs.sqlite ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 139 | cargoBuildFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 140 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 141 | "malice" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 142 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 143 | cargoTestFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 144 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 145 | "malice" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 146 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 147 | # preBuild = "export NIX_BUILD_CORES=2"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 148 | preCheck = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 149 | cargo build --release --bin malice --target ${pkgs.stdenv.hostPlatform.rust.rustcTarget} --offline --locked |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 150 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 151 | SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 152 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 153 | staticServer = pkgs.rustPlatform.buildRustPackage { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 154 | pname = "malice-static"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 155 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 156 | src = cleanSrc ./.; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 157 | cargoLock = { |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 158 | lockFile = ./Cargo.lock; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 159 | allowBuiltinFetchGit = true; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 160 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 161 | cargoBuildFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 162 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 163 | "malice-static" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 164 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 165 | cargoTestFlags = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 166 | "-p" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 167 | "malice-static" |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 168 | ]; |
aa3dce5114d0 | atagen | 2026-10-26 06:09 UTC | 169 | SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 170 | meta.mainProgram = "malice-static"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 171 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 172 | server = pkgs.symlinkJoin { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 173 | name = "malice"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 174 | paths = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 175 | backend |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 176 | web |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 177 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 178 | nativeBuildInputs = [ pkgs.makeWrapper ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 179 | postBuild = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 180 | wrapProgram $out/bin/malice --set MALICE_WEB_DIR ${web}/share/malice |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 181 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 182 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 183 | # the wasm-bindgen `--target web` glue for malice-worker's `Host`, consumed by |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 184 | # web/src/worker/pkg (gitignored, worker-web's TS imports it as ./pkg/malice_worker.js) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 185 | workerWasm = wasmPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 186 | pname = "malice-worker-wasm"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 187 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 188 | src = cleanSrc ./.; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 189 | cargoRoot = "crates/malice-worker"; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 190 | cargoLock = { |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 191 | lockFile = ./crates/malice-worker/Cargo.lock; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 192 | allowBuiltinFetchGit = true; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 193 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 194 | nativeBuildInputs = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 195 | (wasmBindgenCli pkgs) |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 196 | pkgs.removeReferencesTo |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 197 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 198 | buildPhase = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 199 | runHook preBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 200 | cd crates/malice-worker |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 201 | cargo build --offline --frozen --release --lib --target wasm32-unknown-unknown |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 202 | mkdir -p $out |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 203 | wasm-bindgen --target web --out-dir $out --out-name malice_worker \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 204 | target/wasm32-unknown-unknown/release/malice_worker.wasm |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 205 | remove-references-to -t ${wasmToolchain system} $out/*.wasm |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 206 | runHook postBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 207 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 208 | doCheck = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 209 | installPhase = "true"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 210 | disallowedReferences = [ (wasmToolchain system) ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 211 | }; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 212 | web-device = buildWeb pkgs { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 213 | pname = "malice-web-device"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 214 | task = "build:device"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 215 | outDir = "dist-device"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 216 | postPatch = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 217 | mkdir -p src/worker/pkg |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 218 | cp -R ${workerWasm}/. src/worker/pkg/ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 219 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 220 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 221 | local = pkgs.symlinkJoin { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 222 | name = "malice-local"; |
6d7dff75a67d | atagen | 2026-10-26 09:10 UTC | 223 | meta.mainProgram = "malice-static"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 224 | paths = [ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 225 | staticServer |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 226 | web-device |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 227 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 228 | nativeBuildInputs = [ pkgs.makeWrapper ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 229 | postBuild = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 230 | wrapProgram $out/bin/malice-static \ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 231 | --set MALICE_WEB_DIR ${web-device}/share/malice |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 232 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 233 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 234 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 235 | { |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 236 | inherit |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 237 | web |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 238 | server |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 239 | web-device |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 240 | local |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 241 | ; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 242 | default = server; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 243 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 244 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 245 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 246 | devShells = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 247 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 248 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 249 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 250 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 251 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 252 | default = pkgs.mkShell { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 253 | packages = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 254 | (wasmToolchain system) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 255 | (wasmBindgenCli pkgs) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 256 | pkgs.rust-analyzer |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 257 | pkgs.nodejs_22 |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 258 | pkgs.importNpmLock.hooks.linkNodeModulesHook |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 259 | pkgs.pkg-config |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 260 | pkgs.sqlite |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 261 | pkgs.firefox |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 262 | pkgs.geckodriver |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 263 | pkgs.chromium |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 264 | pkgs.matrix-continuwuity |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 265 | pkgs.nushell |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 266 | ]; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 267 | CHROMIUM_PATH = nixpkgs.lib.getExe pkgs.chromium; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 268 | npmDeps = webNodeModules pkgs; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 269 | # 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 | 270 | shellHook = '' |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 271 | npmRoot="$(git rev-parse --show-toplevel 2>/dev/null || pwd)/web" linkNodeModulesHook |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 272 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 273 | # 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 | 274 | # the store rpaths, leaving the native server unable to find libsqlite3 at run time |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 275 | "CARGO_TARGET_${ |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 276 | nixpkgs.lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] pkgs.stdenv.hostPlatform.config) |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 277 | }_RUSTFLAGS" = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 278 | "-C linker-features=-lld"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 279 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 280 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 281 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 282 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 283 | nixosModules.malice = import ./nix/module.nix { inherit self; }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 284 | nixosModules.default = self.nixosModules.malice; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 285 | checks = forAllSystems ( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 286 | system: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 287 | let |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 288 | pkgs = nixpkgs.legacyPackages.${system}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 289 | wasmPlatform = pkgs.makeRustPlatform { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 290 | cargo = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 291 | rustc = wasmToolchain system; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 292 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 293 | # continuwuity refuses to start without /etc/resolv.conf, which the build sandbox lacks, or with |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 294 | # 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 | 295 | # 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 | 296 | sandboxedHomeserver = pkgs.writeShellScriptBin "conduwuit" '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 297 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 298 | ${pkgs.lib.getExe pkgs.bubblewrap} --die-with-parent --dev-bind / / --tmpfs /etc \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 299 | --ro-bind ${pkgs.writeText "resolv.conf" "nameserver 127.0.0.1\n"} /etc/resolv.conf \ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 300 | ${pkgs.lib.getExe' pkgs.matrix-continuwuity "conduwuit"} "$@" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 301 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 302 | in |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 303 | { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 304 | default = self.packages.${system}.default; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 305 | worker-wasm = self.packages.${system}.web-device; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 306 | web = pkgs.stdenvNoCC.mkDerivation { |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 307 | pname = "malice-web-check"; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 308 | version = "0.1.0"; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 309 | src = cleanSrc ./web; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 310 | npmDeps = webNodeModules pkgs; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 311 | nativeBuildInputs = [ |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 312 | pkgs.nodejs_22 |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 313 | pkgs.importNpmLock.hooks.linkNodeModulesHook |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 314 | ]; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 315 | buildPhase = '' |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 316 | runHook preBuild |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 317 | export HOME=$TMPDIR |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 318 | npm run check |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 319 | npm test |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 320 | runHook postBuild |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 321 | ''; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 322 | installPhase = "touch $out"; |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 323 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 324 | worker-browser = wasmPlatform.buildRustPackage { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 325 | pname = "malice-worker-browser-check"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 326 | version = "0.1.0"; |
dffd63b58af4 | atagen | 2026-09-28 09:10 UTC | 327 | src = cleanSrc ./.; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 328 | cargoRoot = "crates/malice-worker"; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 329 | cargoLock = { |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 330 | lockFile = ./crates/malice-worker/Cargo.lock; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 331 | allowBuiltinFetchGit = true; |
29f8ccacfdc7 | atagen | 2026-10-22 13:07 UTC | 332 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 333 | nativeBuildInputs = [ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 334 | (wasmBindgenCli pkgs) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 335 | pkgs.firefox |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 336 | pkgs.geckodriver |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 337 | sandboxedHomeserver |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 338 | pkgs.nushell |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 339 | ]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 340 | buildPhase = '' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 341 | runHook preBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 342 | export HOME=$TMPDIR |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 343 | nu --no-config-file crates/malice-worker/run.nu |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 344 | runHook postBuild |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 345 | ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 346 | doCheck = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 347 | installPhase = "touch $out"; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 348 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 349 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 350 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 351 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 352 | } |