Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place
at main 3.9 kB view raw
1{ 2 inputs = { 3 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 4 rust-overlay.url = "github:oxalica/rust-overlay"; 5 flake-utils.url = "github:numtide/flake-utils"; 6 }; 7 8 outputs = { self, nixpkgs, rust-overlay, flake-utils }: 9 flake-utils.lib.eachDefaultSystem (system: 10 let 11 overlays = [ (import rust-overlay) ]; 12 pkgs = import nixpkgs { inherit system overlays; }; 13 14 rustToolchain = pkgs.rust-bin.stable.latest.default.override { 15 targets = [ 16 "x86_64-unknown-linux-musl" 17 "aarch64-unknown-linux-musl" 18 "x86_64-apple-darwin" 19 "aarch64-apple-darwin" 20 ]; 21 }; 22 23 cargoLockConfig = { 24 lockFile = ./Cargo.lock; 25 outputHashes = { 26 "jacquard-0.9.5" = "sha256-75bas4VAYFcZAcBspSqS4vlJe8nmFn9ncTgeoT/OvnA="; 27 }; 28 }; 29 30 # Native build for current system 31 native = pkgs.rustPlatform.buildRustPackage { 32 pname = "wisp-cli"; 33 version = "0.4.2"; 34 src = ./.; 35 cargoLock = cargoLockConfig; 36 nativeBuildInputs = [ rustToolchain ]; 37 }; 38 39 # Cross-compilation targets (Linux from macOS needs zigbuild) 40 linuxTargets = let 41 zigbuildPkgs = pkgs; 42 in { 43 x86_64-linux = pkgs.stdenv.mkDerivation { 44 pname = "wisp-cli-x86_64-linux"; 45 version = "0.4.2"; 46 src = ./.; 47 48 nativeBuildInputs = [ 49 rustToolchain 50 pkgs.cargo-zigbuild 51 pkgs.zig 52 ]; 53 54 buildPhase = '' 55 export HOME=$(mktemp -d) 56 cargo zigbuild --release --target x86_64-unknown-linux-musl 57 ''; 58 59 installPhase = '' 60 mkdir -p $out/bin 61 cp target/x86_64-unknown-linux-musl/release/wisp-cli $out/bin/ 62 ''; 63 64 # Skip Nix's cargo vendor - we use network 65 dontConfigure = true; 66 dontFixup = true; 67 }; 68 69 aarch64-linux = pkgs.stdenv.mkDerivation { 70 pname = "wisp-cli-aarch64-linux"; 71 version = "0.4.2"; 72 src = ./.; 73 74 nativeBuildInputs = [ 75 rustToolchain 76 pkgs.cargo-zigbuild 77 pkgs.zig 78 ]; 79 80 buildPhase = '' 81 export HOME=$(mktemp -d) 82 cargo zigbuild --release --target aarch64-unknown-linux-musl 83 ''; 84 85 installPhase = '' 86 mkdir -p $out/bin 87 cp target/aarch64-unknown-linux-musl/release/wisp-cli $out/bin/ 88 ''; 89 90 dontConfigure = true; 91 dontFixup = true; 92 }; 93 }; 94 95 in { 96 packages = { 97 default = native; 98 inherit native; 99 100 # macOS universal binary 101 macos-universal = pkgs.stdenv.mkDerivation { 102 pname = "wisp-cli-macos-universal"; 103 version = "0.4.2"; 104 src = ./.; 105 106 nativeBuildInputs = [ rustToolchain pkgs.darwin.lipo ]; 107 108 buildPhase = '' 109 export HOME=$(mktemp -d) 110 cargo build --release --target aarch64-apple-darwin 111 cargo build --release --target x86_64-apple-darwin 112 ''; 113 114 installPhase = '' 115 mkdir -p $out/bin 116 lipo -create \ 117 target/aarch64-apple-darwin/release/wisp-cli \ 118 target/x86_64-apple-darwin/release/wisp-cli \ 119 -output $out/bin/wisp-cli 120 ''; 121 122 dontConfigure = true; 123 dontFixup = true; 124 }; 125 } // (if pkgs.stdenv.isDarwin then linuxTargets else {}); 126 127 devShells.default = pkgs.mkShell { 128 buildInputs = [ 129 rustToolchain 130 pkgs.cargo-zigbuild 131 pkgs.zig 132 ]; 133 }; 134 } 135 ); 136}