flake.nix (3301B)
1 { 2 description = "Radroots public runtime daemon"; 3 4 inputs = { 5 # Crane 0.23+ currently asks nixpkgs' Cargo vendor helper to fetch 6 # semver-build-metadata crate versions through the crates.io API. That 7 # endpoint rejects the literal `+`; the immutable v0.22.0 input avoids 8 # that upstream fetch defect while preserving the same locked sources. 9 crane.url = "github:ipetkov/crane/01bc1d404a51a0a07e9d8759cd50a7903e218c82"; 10 lib = { 11 url = "github:radrootslabs/lib/3563f3b5a4331eb2cb3f925cafc9de524d844228"; 12 inputs.crane.follows = "crane"; 13 }; 14 nixpkgs.follows = "lib/nixpkgs"; 15 rust-overlay.follows = "lib/rust-overlay"; 16 }; 17 18 outputs = 19 { 20 crane, 21 lib, 22 nixpkgs, 23 rust-overlay, 24 ... 25 }: 26 let 27 systems = [ 28 "aarch64-darwin" 29 "x86_64-linux" 30 ]; 31 forAllSystems = 32 function: 33 builtins.listToAttrs ( 34 map (system: { 35 name = system; 36 value = function system; 37 }) systems 38 ); 39 daemonOutputs = 40 system: 41 let 42 pkgs = import nixpkgs { 43 inherit system; 44 overlays = [ rust-overlay.overlays.default ]; 45 }; 46 toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; 47 craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; 48 source = pkgs.lib.cleanSourceWith { 49 src = ./.; 50 filter = 51 path: type: 52 craneLib.filterCargoSources path type 53 || pkgs.lib.hasSuffix ".json" (baseNameOf path) 54 || pkgs.lib.hasSuffix ".txt" (baseNameOf path) 55 || baseNameOf path == "flake.nix" 56 || baseNameOf path == "README"; 57 name = "radrootsd-source"; 58 }; 59 commonArgs = { 60 src = source; 61 cargoLock = ./Cargo.lock; 62 strictDeps = true; 63 doCheck = false; 64 }; 65 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 66 package = craneLib.buildPackage ( 67 commonArgs 68 // { 69 inherit cargoArtifacts; 70 pname = "radrootsd"; 71 version = "0.1.0"; 72 CARGO_PROFILE = "release"; 73 cargoExtraArgs = "--locked --package radrootsd --bin radrootsd"; 74 } 75 ); 76 check = craneLib.mkCargoDerivation ( 77 commonArgs 78 // { 79 inherit cargoArtifacts; 80 pname = "radrootsd-check"; 81 version = "1"; 82 buildPhaseCargoCommand = "cargo check --locked --package radrootsd --all-targets"; 83 installPhaseCommand = "mkdir -p $out"; 84 } 85 ); 86 app = { 87 type = "app"; 88 program = "${package}/bin/radrootsd"; 89 meta.description = "Run the built radrootsd daemon"; 90 }; 91 in 92 { 93 inherit app check package; 94 }; 95 in 96 { 97 packages = forAllSystems (system: { 98 default = (daemonOutputs system).package; 99 }); 100 checks = forAllSystems (system: { 101 default = (daemonOutputs system).check; 102 }); 103 apps = forAllSystems (system: { 104 default = (daemonOutputs system).app; 105 }); 106 }; 107 }