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