grain.social is a photo sharing platform built on atproto. grain.social
atproto photography appview
50
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 215ad95ab1bb96b23dd3fae2ac401d01a1feab63 125 lines 4.4 kB view raw
1{ 2 description = "Grain CLI - A command-line interface for grain.social"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 flake-utils.url = "github:numtide/flake-utils"; 7 crane = { 8 url = "github:ipetkov/crane"; 9 inputs.nixpkgs.follows = "nixpkgs"; 10 }; 11 rust-overlay = { 12 url = "github:oxalica/rust-overlay"; 13 inputs.nixpkgs.follows = "nixpkgs"; 14 }; 15 }; 16 17 outputs = { self, nixpkgs, flake-utils, crane, rust-overlay }: 18 flake-utils.lib.eachDefaultSystem (system: 19 let 20 overlays = [ (import rust-overlay) ]; 21 pkgs = import nixpkgs { inherit system overlays; }; 22 23 rustToolchain = pkgs.rust-bin.stable.latest.default.override { 24 extensions = [ "rust-src" ]; 25 targets = [ 26 "x86_64-unknown-linux-gnu" 27 "x86_64-pc-windows-gnu" 28 "x86_64-apple-darwin" 29 "aarch64-apple-darwin" 30 "aarch64-unknown-linux-gnu" 31 ]; 32 }; 33 34 craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; 35 36 src = craneLib.cleanCargoSource (craneLib.path ./.); 37 38 commonArgs = { 39 inherit src; 40 strictDeps = true; 41 42 buildInputs = with pkgs; [ 43 openssl 44 ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ 45 pkgs.darwin.apple_sdk.frameworks.Security 46 pkgs.darwin.apple_sdk.frameworks.SystemConfiguration 47 ]; 48 49 nativeBuildInputs = with pkgs; [ 50 pkg-config 51 ]; 52 }; 53 54 # Build dependencies first for caching 55 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 56 57 # Build function for different targets 58 buildGrainCLI = target: craneLib.buildPackage (commonArgs // { 59 inherit cargoArtifacts; 60 CARGO_BUILD_TARGET = target; 61 } // pkgs.lib.optionalAttrs (target == "x86_64-pc-windows-gnu") { 62 depsBuildBuild = with pkgs; [ 63 pkgsCross.mingwW64.stdenv.cc 64 ]; 65 CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/x86_64-w64-mingw32-gcc"; 66 }); 67 68 in { 69 packages = { 70 default = buildGrainCLI system; 71 72 # Cross-compilation targets 73 grain-linux-x86_64 = buildGrainCLI "x86_64-unknown-linux-gnu"; 74 grain-linux-aarch64 = buildGrainCLI "aarch64-unknown-linux-gnu"; 75 grain-macos-x86_64 = buildGrainCLI "x86_64-apple-darwin"; 76 grain-macos-aarch64 = buildGrainCLI "aarch64-apple-darwin"; 77 grain-windows-x86_64 = buildGrainCLI "x86_64-pc-windows-gnu"; 78 }; 79 80 devShells.default = pkgs.mkShell { 81 inputsFrom = [ self.packages.${system}.default ]; 82 packages = with pkgs; [ 83 rustToolchain 84 pkg-config 85 openssl 86 cargo-cross 87 ]; 88 }; 89 90 # Helper script to build all targets 91 apps.build-all = flake-utils.lib.mkApp { 92 drv = pkgs.writeShellScriptBin "build-all" '' 93 set -e 94 95 echo "Building Grain CLI for all platforms..." 96 97 mkdir -p releases 98 99 # Build for each platform 100 echo "Building for Linux x86_64..." 101 nix build .#grain-linux-x86_64 -o result-linux-x86_64 102 cp result-linux-x86_64/bin/grain releases/grain-linux-x86_64 103 104 echo "Building for Linux aarch64..." 105 nix build .#grain-linux-aarch64 -o result-linux-aarch64 106 cp result-linux-aarch64/bin/grain releases/grain-linux-aarch64 107 108 echo "Building for macOS x86_64..." 109 nix build .#grain-macos-x86_64 -o result-macos-x86_64 110 cp result-macos-x86_64/bin/grain releases/grain-darwin-x86_64 111 112 echo "Building for macOS aarch64..." 113 nix build .#grain-macos-aarch64 -o result-macos-aarch64 114 cp result-macos-aarch64/bin/grain releases/grain-darwin-aarch64 115 116 echo "Building for Windows x86_64..." 117 nix build .#grain-windows-x86_64 -o result-windows-x86_64 118 cp result-windows-x86_64/bin/grain.exe releases/grain-windows-x86_64.exe 119 120 echo "All builds complete! Binaries are in releases/" 121 ls -la releases/ 122 ''; 123 }; 124 }); 125}