Skip to content

Clippy hook fails when run using nix flake check #452

Closed
@Scrumplex

Description

@Scrumplex

This is the relevant flake.parts code:

# SPDX-FileCopyrightText: 2023 Sefa Eyeoglu <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{
  perSystem = {
    config,
    lib,
    pkgs,
    ...
  }: {
    pre-commit.settings = {
      excludes = [
        "vendor/"
      ];
      hooks = {
        alejandra.enable = true;
        rustfmt.enable = true;
        clippy.enable = true;
        prettier = {
          enable = true;
          excludes = ["flake.lock"];
        };
      };
    };
    devShells.default = pkgs.mkShell {
      shellHook = ''
        ${config.pre-commit.installationScript}
      '';

      inputsFrom = [config.packages.default];
      buildInputs = config.pre-commit.settings.enabledPackages;
      packages = with pkgs; [reuse];
    };
    formatter = pkgs.alejandra;
  };
}

The hook works fine when run in a devShell, but it fails when run as a flake check, as there is no internet access, no access to the cargo cache. Error:

       > - hook id: clippy
       > - exit code: 101
       >
       > error: no matching package named `tokio` found
       > location searched: registry `crates-io`
       > required by package `inhibridge v0.3.0 (/build/src)`
       > As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.
       >

Maybe we should have a way to pass a cargoDeps derivation to allow it to run in a flake check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingflakeRelated to running in pure environments

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions