radrootsd

JSON-RPC bridge for Radroots event publishing
git clone https://radroots.dev/git/radrootsd.git
Log | Files | Refs | README | LICENSE

flake.nix (3451B)


      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/e55c1749902811732167a2ce5c099e22e964624f";
     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               postInstall = ''
     75                 install -Dm444 ${lib.outPath}/crates/domain/NOTICE "$out/share/doc/radrootsd/NOTICE"
     76               '';
     77             }
     78           );
     79           check = craneLib.mkCargoDerivation (
     80             commonArgs
     81             // {
     82               inherit cargoArtifacts;
     83               pname = "radrootsd-check";
     84               version = "1";
     85               buildPhaseCargoCommand = "cargo check --locked --package radrootsd --all-targets";
     86               installPhaseCommand = "mkdir -p $out";
     87             }
     88           );
     89           app = {
     90             type = "app";
     91             program = "${package}/bin/radrootsd";
     92             meta.description = "Run the built radrootsd daemon";
     93           };
     94         in
     95         {
     96           inherit app check package;
     97         };
     98     in
     99     {
    100       packages = forAllSystems (system: {
    101         default = (daemonOutputs system).package;
    102       });
    103       checks = forAllSystems (system: {
    104         default = (daemonOutputs system).check;
    105       });
    106       apps = forAllSystems (system: {
    107         default = (daemonOutputs system).app;
    108       });
    109     };
    110 }