Radish alpha
r
rad:z2UcCU1LgMshWvXj6hXSDDrwB8q8M
Radicle Job Collaborative Object
Radicle
Git
radicle-job flake.nix
{
  description = "Radicle Job Collaborative Object";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/release-24.11";

    crane.url = "github:ipetkov/crane";

    flake-utils.url = "github:numtide/flake-utils";

    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    nixpkgs,
    crane,
    flake-utils,
    rust-overlay,
    ...
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      lib = nixpkgs.lib;
      pkgs = import nixpkgs {
        inherit system;
        overlays = [(import rust-overlay)];
      };

      # Get the `rust-version` from the Cargo manifest
      manifest = builtins.fromTOML (builtins.readFile ./Cargo.toml);
      rust-version = manifest.package.rust-version;
      rustToolChain = pkgs.rust-bin.stable.${rust-version}.default;
      craneLib = (crane.mkLib pkgs).overrideToolchain rustToolChain;

      src = lib.cleanSourceWith {
        src = ./.;
      };

      basicArgs = {
        inherit src;
        pname = "radicle-job";
        strictDeps = true;
      };

      # Build *just* the cargo dependencies, so we can reuse
      # all of that work (e.g. via cachix) when running in CI
      cargoArtifacts = craneLib.buildDepsOnly basicArgs;

      # Common arguments can be set here to avoid repeating them later
      commonArgs =
        basicArgs
        // {
          inherit cargoArtifacts;

          nativeBuildInputs = with pkgs; [
            # Add additional build inputs here
          ];
          buildInputs = lib.optionals pkgs.stdenv.buildPlatform.isDarwin (with pkgs; [
            darwin.apple_sdk.frameworks.Security
            pkgs.libiconv
          ]);
        };
    in {
      formatter = pkgs.alejandra;

      checks = {
        inherit (self.packages.${system}) radicle-job;

        clippy = craneLib.cargoClippy (commonArgs
          // {
            cargoClippyExtraArgs = "--all-targets -- --deny warnings";
          });

        doc = craneLib.cargoDoc commonArgs;
        fmt = craneLib.cargoFmt basicArgs;
        # Run tests with cargo-nextest
        nextest = craneLib.cargoNextest (commonArgs
          // {
            partitions = 1;
            partitionType = "count";
            # Ensure dev is used since we rely on env variables being
            # set in tests.
            env.CARGO_PROFILE = "dev";
          });
      };

      packages.radicle-job = craneLib.buildPackage (commonArgs
        // {
          src = craneLib.cleanCargoSource ./.;
          strictDeps = true;
          doCheck = false;
        });
      packages.default = self.packages.${system}.radicle-job;

      devShells.default = craneLib.devShell {
        # Inherit inputs from checks.
        checks = self.checks.${system};

        # Extra inputs can be added here; cargo and rustc are provided by default
        # from the toolchain that was specified earlier.
        packages = with pkgs; [
          cargo-msrv
          cargo-nextest
          cargo-release
          cargo-semver-checks
          cargo-watch
          ripgrep
          rust-analyzer
        ];
      };
    });
}