An easy-to-host PDS on the ATProtocol, MacOS. Grandma-approved.
at main 86 lines 3.3 kB view raw
1{ 2 description = "ezpds development shell"; 3 4 nixConfig = { 5 extra-substituters = "https://devenv.cachix.org https://nix-community.cachix.org"; 6 extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCUSOut="; 7 allow-import-from-derivation = true; 8 }; 9 10 inputs = { 11 nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; 12 devenv.url = "github:cachix/devenv"; 13 systems.url = "github:nix-systems/default"; 14 rust-overlay.url = "github:oxalica/rust-overlay"; 15 rust-overlay.inputs = { nixpkgs.follows = "nixpkgs"; }; 16 crane.url = "github:ipetkov/crane"; 17 }; 18 19 outputs = { self, nixpkgs, devenv, systems, rust-overlay, crane, ... } @ inputs: 20 let 21 forEachSystem = f: nixpkgs.lib.genAttrs (import systems) f; 22 in { 23 packages = forEachSystem (system: 24 let 25 pkgs = import nixpkgs { 26 inherit system; 27 overlays = [ (import rust-overlay) ]; 28 }; 29 rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; 30 craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; 31 32 commonArgs = { 33 src = craneLib.cleanCargoSource ./.; 34 pname = "relay"; 35 strictDeps = true; 36 nativeBuildInputs = [ pkgs.pkg-config ]; 37 buildInputs = [ pkgs.sqlite ]; 38 LIBSQLITE3_SYS_USE_PKG_CONFIG = "1"; 39 }; 40 41 # Build deps separately so they're cached when only source changes. 42 # Scope buildDepsOnly to relay-related crates only. 43 # apps/identity-wallet/src-tauri uses Tauri (webkit2gtk on Linux, Apple frameworks 44 # on macOS) which are not in commonArgs.buildInputs. Without this scope, 45 # buildDepsOnly would attempt to compile Tauri's native deps and fail in Nix. 46 cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { 47 cargoExtraArgs = "--package relay --package repo-engine --package crypto --package common"; 48 }); 49 50 relay = craneLib.buildPackage (commonArgs // { 51 inherit cargoArtifacts; 52 cargoExtraArgs = "--package relay"; 53 }); 54 in { 55 inherit relay; 56 default = relay; 57 } // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { 58 docker-image = import ./nix/docker.nix { inherit pkgs relay; }; 59 } 60 ); 61 62 devShells = forEachSystem (system: 63 let 64 pkgs = nixpkgs.legacyPackages.${system}; 65 in { 66 default = devenv.lib.mkShell { 67 inherit inputs pkgs; 68 modules = [ ./devenv.nix ]; 69 }; 70 } 71 ); 72 73 # nixosModules is not per-system — placed outside forEachSystem. 74 # self is captured from the outputs function closure. 75 nixosModules.default = { lib, pkgs, ... }: { 76 imports = [ ./nix/module.nix ]; 77 # Guard the package default: on unsupported architectures self.packages 78 # won't have an entry, and the raw attrset access would produce an 79 # opaque "attribute missing" error. When the guard fails, NixOS surfaces 80 # its own "option services.ezpds.package is not set" message instead. 81 config.services.ezpds.package = lib.mkIf 82 (self.packages ? ${pkgs.system}) 83 (lib.mkDefault self.packages.${pkgs.system}.relay); 84 }; 85 }; 86}