cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

flake.nix (3152B)


      1 {
      2   description = "Radroots command-line interface";
      3 
      4   inputs = {
      5     crane.url = "github:ipetkov/crane/01bc1d404a51a0a07e9d8759cd50a7903e218c82";
      6     lib = {
      7       url = "github:radrootslabs/lib/e55c1749902811732167a2ce5c099e22e964624f";
      8       inputs.crane.follows = "crane";
      9     };
     10     nixpkgs.follows = "lib/nixpkgs";
     11     rust-overlay.follows = "lib/rust-overlay";
     12   };
     13 
     14   outputs =
     15     {
     16       crane,
     17       lib,
     18       nixpkgs,
     19       rust-overlay,
     20       ...
     21     }:
     22     let
     23       systems = [
     24         "aarch64-darwin"
     25         "x86_64-linux"
     26       ];
     27       forAllSystems =
     28         function:
     29         builtins.listToAttrs (
     30           map (system: {
     31             name = system;
     32             value = function system;
     33           }) systems
     34         );
     35       cliOutputs =
     36         system:
     37         let
     38           pkgs = import nixpkgs {
     39             inherit system;
     40             overlays = [ rust-overlay.overlays.default ];
     41           };
     42           toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
     43           craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
     44           source = pkgs.lib.cleanSourceWith {
     45             src = ./.;
     46             filter =
     47               path: type:
     48               craneLib.filterCargoSources path type
     49               || pkgs.lib.hasSuffix ".json" (baseNameOf path)
     50               || pkgs.lib.hasSuffix ".txt" (baseNameOf path)
     51               || baseNameOf path == "flake.nix"
     52               || baseNameOf path == "README";
     53             name = "radroots-cli-source";
     54           };
     55           commonArgs = {
     56             src = source;
     57             cargoLock = ./Cargo.lock;
     58             strictDeps = true;
     59             doCheck = false;
     60           };
     61           cargoArtifacts = craneLib.buildDepsOnly commonArgs;
     62           package = craneLib.buildPackage (
     63             commonArgs
     64             // {
     65               inherit cargoArtifacts;
     66               pname = "radroots_cli";
     67               version = "0.1.0";
     68               CARGO_PROFILE = "release";
     69               cargoExtraArgs = "--locked --package radroots_cli --bin radroots";
     70               postInstall = ''
     71                 install -Dm444 ${lib.outPath}/crates/domain/NOTICE "$out/share/doc/radroots/NOTICE"
     72               '';
     73             }
     74           );
     75           check = craneLib.mkCargoDerivation (
     76             commonArgs
     77             // {
     78               inherit cargoArtifacts;
     79               pname = "radroots-cli-check";
     80               version = "1";
     81               buildPhaseCargoCommand = "cargo check --locked --package radroots_cli --all-targets";
     82               installPhaseCommand = "mkdir -p $out";
     83             }
     84           );
     85           app = {
     86             type = "app";
     87             program = "${package}/bin/radroots";
     88             meta.description = "Run the built radroots CLI";
     89           };
     90         in
     91         {
     92           inherit app check package;
     93         };
     94     in
     95     {
     96       packages = forAllSystems (system: {
     97         default = (cliOutputs system).package;
     98       });
     99       checks = forAllSystems (system: {
    100         default = (cliOutputs system).check;
    101       });
    102       apps = forAllSystems (system: {
    103         default = (cliOutputs system).app;
    104       });
    105     };
    106 }