[Nix#8881] Run a single flake check #122

Open
opened 2024-03-16 06:45:01 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#8881

There's currently (Nix 2.17.0) no way to run a single flake check.

For example, with the given flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
  }:
    flake-utils.lib.eachDefaultSystem (
      system: let
        pkgs = import nixpkgs {
          inherit system;
        };
      in {
        checks = {
          my-check = pkgs.runCommand "my-check" {} "echo hello > $out";
        };
      }
    );
}

The only way to build the check my-check is with nix flake check, which builds every check (and packages, and other stuff).

Unlike nix build, nix shell, and nix develop, nix flake check doesn't allow specifying a check:

$ nix flake check .#my-check
error: unexpected fragment 'my-check' in flake reference '.#my-check'

As a workaround, nix build can be used, but it requires specifying the full attribute path, including the current architecture: nix build .#checks.aarch64-darwin.my-check.

Describe the solution you'd like
nix flake check could gain a mode to run individual checks with fragments, like nix flake check .#my-check. Alternatively, to match nix build, nix shell, and nix develop, we could introduce a nix check command.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/8881 There's currently (Nix 2.17.0) no way to run a single flake check. For example, with the given `flake.nix`: ```nix { inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils, }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; }; in { checks = { my-check = pkgs.runCommand "my-check" {} "echo hello > $out"; }; } ); } ``` The only way to build the check `my-check` is with `nix flake check`, which builds _every_ check (and packages, and other stuff). Unlike `nix build`, `nix shell`, and `nix develop`, `nix flake check` doesn't allow specifying a check: ```ShellSession $ nix flake check .#my-check error: unexpected fragment 'my-check' in flake reference '.#my-check' ``` As a workaround, `nix build` can be used, but it requires specifying the full attribute path, including the current architecture: `nix build .#checks.aarch64-darwin.my-check`. **Describe the solution you'd like** `nix flake check` could gain a mode to run individual checks with fragments, like `nix flake check .#my-check`. Alternatively, to match `nix build`, `nix shell`, and `nix develop`, we could introduce a `nix check` command.
lix-bot added the
imported
label 2024-03-16 06:45:01 +00:00
qyriad added the
ux
label 2024-03-27 23:56:21 +00:00
jade added the
Area/flakes
label 2024-03-30 00:04:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#122
No description provided.