Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Nix Improvements
Merged fintohaps opened 2 years ago

nix: use rust-overlay for toolchain pinning

To ensure the Nix derivations are using the correct toolchain, defined in the rust-toolchain file, use the rust-overlay library.

Also remove the fenix input, since this was actually never used and was an artefact of some copy-paste shenanigans.


nix: add rad-web app

To allow for Nix users to install rad-web easily, add the package to the set of packages and apps.

3 files changed +58 -30 501b6ba9 64fd4196
modified flake.lock
@@ -36,27 +36,6 @@
        "type": "github"
      }
    },
-
    "fenix": {
-
      "inputs": {
-
        "nixpkgs": [
-
          "nixpkgs"
-
        ],
-
        "rust-analyzer-src": []
-
      },
-
      "locked": {
-
        "lastModified": 1701930186,
-
        "narHash": "sha256-t9uIiU1fE7VXi3t460iOuAUW8Ece9mowRKva1aw48zI=",
-
        "owner": "nix-community",
-
        "repo": "fenix",
-
        "rev": "aeb764a8e4c16da3f36b200a302552d8e457b9f4",
-
        "type": "github"
-
      },
-
      "original": {
-
        "owner": "nix-community",
-
        "repo": "fenix",
-
        "type": "github"
-
      }
-
    },
    "flake-utils": {
      "inputs": {
        "systems": "systems"
@@ -95,9 +74,32 @@
      "inputs": {
        "advisory-db": "advisory-db",
        "crane": "crane",
-
        "fenix": "fenix",
        "flake-utils": "flake-utils",
-
        "nixpkgs": "nixpkgs"
+
        "nixpkgs": "nixpkgs",
+
        "rust-overlay": "rust-overlay"
+
      }
+
    },
+
    "rust-overlay": {
+
      "inputs": {
+
        "flake-utils": [
+
          "flake-utils"
+
        ],
+
        "nixpkgs": [
+
          "nixpkgs"
+
        ]
+
      },
+
      "locked": {
+
        "lastModified": 1708308739,
+
        "narHash": "sha256-FtKWP6d51kz8282jfziNNcCBpAvEzv2TtKH6dYIXCuA=",
+
        "owner": "oxalica",
+
        "repo": "rust-overlay",
+
        "rev": "d45281ce1027a401255db01ea44972afbc569b7e",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "oxalica",
+
        "repo": "rust-overlay",
+
        "type": "github"
      }
    },
    "systems": {
modified flake.nix
@@ -9,10 +9,12 @@
      inputs.nixpkgs.follows = "nixpkgs";
    };

-
    fenix = {
-
      url = "github:nix-community/fenix";
-
      inputs.nixpkgs.follows = "nixpkgs";
-
      inputs.rust-analyzer-src.follows = "";
+
    rust-overlay = {
+
      url = "github:oxalica/rust-overlay";
+
      inputs = {
+
        nixpkgs.follows = "nixpkgs";
+
        flake-utils.follows = "flake-utils";
+
      };
    };

    flake-utils.url = "github:numtide/flake-utils";
@@ -31,18 +33,22 @@
    self,
    nixpkgs,
    crane,
-
    fenix,
    flake-utils,
    advisory-db,
+
    rust-overlay,
    ...
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pname = "Heartwood";
-
      pkgs = nixpkgs.legacyPackages.${system};
+
      pkgs = import nixpkgs {
+
        inherit system;
+
        overlays = [(import rust-overlay)];
+
      };

      inherit (pkgs) lib;

-
      craneLib = crane.lib.${system};
+
      rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
+
      craneLib = (crane.mkLib pkgs).overrideToolchain rustToolChain;

      srcFilters = path: type:
      # Allow sql schemas
@@ -186,6 +192,13 @@
            cargoBuildCommand = "cargo build --release -p radicle-httpd";
            doCheck = false;
          });
+
        rad-web = craneLib.buildPackage (commonArgs
+
          // {
+
            inherit (craneLib.crateNameFromCargoToml {cargoToml = ./radicle-httpd/Cargo.toml;});
+
            inherit cargoArtifacts;
+
            cargoBuildCommand = "cargo build --release --bin rad-web --manifest-path ./radicle-httpd/Cargo.toml";
+
            doCheck = false;
+
          });
      };

      apps.default = flake-utils.lib.mkApp {
@@ -212,6 +225,11 @@
        drv = self.packages.${system}.radicle-httpd;
      };

+
      apps.rad-web = flake-utils.lib.mkApp {
+
        name = "rad-web";
+
        drv = self.packages.${system}.rad-web;
+
      };
+

      devShells.default = craneLib.devShell {
        # Extra inputs can be added here; cargo and rustc are provided by default.
        packages = [
modified radicle-httpd/Cargo.toml
@@ -14,6 +14,14 @@ logfmt = [
  "tracing-subscriber/env-filter"
]

+
[[bin]]
+
name = "radicle-httpd"
+
path = "src/main.rs"
+

+
[[bin]]
+
name = "rad-web"
+
path = "src/bin/rad-web.rs"
+

[dependencies]
anyhow = { version = "1" }
axum = { version = "0.7.2", default-features = false, features = ["json", "query", "tokio", "http1"] }