cli

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

flake.nix (3003B)


      1 {
      2   description = "Radroots command-line interface";
      3 
      4   inputs = {
      5     crane.url = "github:ipetkov/crane/01bc1d404a51a0a07e9d8759cd50a7903e218c82";
      6     lib = {
      7       url = "github:radrootslabs/lib/3563f3b5a4331eb2cb3f925cafc9de524d844228";
      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             }
     71           );
     72           check = craneLib.mkCargoDerivation (
     73             commonArgs
     74             // {
     75               inherit cargoArtifacts;
     76               pname = "radroots-cli-check";
     77               version = "1";
     78               buildPhaseCargoCommand = "cargo check --locked --package radroots_cli --all-targets";
     79               installPhaseCommand = "mkdir -p $out";
     80             }
     81           );
     82           app = {
     83             type = "app";
     84             program = "${package}/bin/radroots";
     85             meta.description = "Run the built radroots CLI";
     86           };
     87         in
     88         {
     89           inherit app check package;
     90         };
     91     in
     92     {
     93       packages = forAllSystems (system: {
     94         default = (cliOutputs system).package;
     95       });
     96       checks = forAllSystems (system: {
     97         default = (cliOutputs system).check;
     98       });
     99       apps = forAllSystems (system: {
    100         default = (cliOutputs system).app;
    101       });
    102     };
    103 }