{ description = "FeDIY: a federated ActivityPub DIY platform built in Rust"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs@{ self, ... }: let supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forEachSupportedSystem = f: inputs.nixpkgs.lib.genAttrs supportedSystems ( system: f { pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.self.overlays.default ]; }; } ); in { templates = { default = { path = ./.; description = "FeDIY Rust development environment and package outputs for Nix and non-Nix contributors"; }; }; overlays.default = _final: prev: { rustToolchain = with inputs.fenix.packages.${prev.stdenv.hostPlatform.system}; combine ( with stable; [ clippy rustc cargo rustfmt rust-src ] ); }; devShells = forEachSupportedSystem ( { pkgs }: { default = pkgs.mkShell { packages = with pkgs; [ # Rust toolchain (managed by fenix overlay) rustToolchain rust-analyzer # Build essentials git gnumake openssl pkg-config # Local database tooling postgresql # Localization tooling gettext # Browser and accessibility testing chromium playwright # Cargo productivity tools cargo-deny cargo-edit cargo-watch # Code quality pre-commit # Packaging flatpak-builder ] ++ lib.optionals pkgs.stdenv.isLinux [ # OCI/container tooling (Linux host only) podman podman-compose buildah ]; env = { # Required by rust-analyzer RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library"; }; shellHook = '' # Initialize git repository if not already present if [ ! -d .git ]; then git init echo "✓ Initialized git repository" fi echo "[FeDIY] Welcome to the dev shell!" echo "If you're new to Nix: this shell gives you the exact tools this repo expects." echo "Start with 'cargo build'. Use 'nix run .#dev-helper' for a quick tool summary." echo "Tools: cargo, rustc, clippy, rustfmt, rust-analyzer, flatpak-builder, psql, gettext, chromium, playwright" echo "Packaging note: the shell is intentionally reviewed and trimmed as the roadmap changes." if command -v podman >/dev/null 2>&1; then echo "OCI tools: podman, podman-compose, buildah" fi echo "Run 'cargo build' to build, 'cargo test' to test, or 'make flatpak-build' for Flatpak." echo "See README.md for usage." ''; }; } ); packages = forEachSupportedSystem ( { pkgs }: { # Build the FeDIY Cargo project default = pkgs.rustPlatform.buildRustPackage { pname = "fediy"; version = "0.1.0"; src = ./.; cargoLock.lockFile = ./Cargo.lock; meta.mainProgram = "fediy"; }; devHelper = pkgs.writeShellScriptBin "dev-helper" '' echo "=== FeDIY dev shell tools ===" echo "Build + Rust" command -v cargo >/dev/null 2>&1 && echo " cargo: $(cargo --version)" || echo " cargo: not found" command -v rustc >/dev/null 2>&1 && echo " rustc: $(rustc --version)" || echo " rustc: not found" command -v rust-analyzer >/dev/null 2>&1 && echo " rust-analyzer: $(rust-analyzer --version)" || echo " rust-analyzer: not found" echo "Testing + quality" command -v pre-commit >/dev/null 2>&1 && echo " pre-commit: $(pre-commit --version)" || echo " pre-commit: not found" command -v flatpak-builder >/dev/null 2>&1 && echo " flatpak-builder: $(flatpak-builder --version)" || echo " flatpak-builder: not found" echo "Data + localization" command -v psql >/dev/null 2>&1 && echo " psql: $(psql --version)" || echo " psql: not found" command -v gettext >/dev/null 2>&1 && echo " gettext: $(gettext --version | head -n 1)" || echo " gettext: not found" echo "Accessibility + browser checks" command -v chromium >/dev/null 2>&1 && echo " chromium: $(chromium --version)" || echo " chromium: not found" command -v playwright >/dev/null 2>&1 && echo " playwright: $(playwright --version)" || echo " playwright: not found" if command -v podman >/dev/null 2>&1; then echo "Container tooling" echo " podman: $(podman --version)" command -v podman-compose >/dev/null 2>&1 && echo " podman-compose: $(podman-compose --version)" || echo " podman-compose: not found" command -v buildah >/dev/null 2>&1 && echo " buildah: $(buildah --version)" || echo " buildah: not found" fi ''; } ); apps = forEachSupportedSystem ( { pkgs }: { default = { type = "app"; program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default; }; dev-helper = { type = "app"; program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.devHelper; }; } ); }; }