Skip to content

nix flake check fails when nix-unit is used in a flake-parts partitioned module without network #270

@folliehiyuki

Description

@folliehiyuki

I'm using nix-unit in a partitioned flake, following https://flake.parts/options/flake-parts-partitions. When executing nix flake check, nix-unit still tries to fetch unknown inputs even when perSystem.nix-input.inputs is defined. The check command refers to the top-level flake, where no partitioned inputs exist.

--flake ${self}#tests.systems.${system} \

The flake module works when flake-parts' partition module is not used.

Reproduced setup

flake.nix

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    # Use https://github.com/hercules-ci/flake-parts/pull/273 to eliminate any other networking factors.
    flake-parts = {
      url = "github:MattSturgeon/flake-parts/override-flake-compat";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };

  outputs =
    inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        flake-parts.flakeModules.partitions
      ];

      systems = [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ];

      flakeCompatSrc = inputs.flake-compat;

      partitionedAttrs.checks = "dev";
      partitionedAttrs.tests = "dev";
      partitions.dev.extraInputsFlake = ./dev;
      partitions.dev.module =
        { inputs, ... }:
        {
          imports = [
            inputs.nix-unit.modules.flake.default
          ];

          perSystem = _: {
            nix-unit.inputs = {
              inherit (inputs) nixpkgs flake-parts nix-unit flake-compat;
            };

            nix-unit.allowNetwork = false;
          };

          flake.tests."test example" = {
            expr = {
              x = 1;
            };
            expected = {
              y = 1;
            };
          };
        };
    };
}

dev/flake.nix

{
  outputs = _: { };

  inputs = {
    treefmt-nix.url = "github:numtide/treefmt-nix";

    nix-unit = {
      url = "github:nix-community/nix-unit";
      inputs.treefmt-nix.follows = "treefmt-nix";
    };
  };
}

Error output

The command doesn't know about nix-unit input, which is only defined in the partitioned flake, so the override doesn't work.

out=/nix/store/4jmf3610h9cwniw29bjhd23inpbq5h1r-nix-unit-check
Running tests for  x86_64-linux
warning: `--gc-roots-dir' not specified
warning: input '' has an override for a non-existent input 'nix-unit'
warning: the flag '--override-input nix-unit path:/nix/store/b6mpyyfj2lkxhz92nb1yyc0zkay6d6ff-source' does not match any input
warning: not writing modified lock file of flake 'path:/nix/store/rsp82k7fcp2aybicikh44kwlsp3xkayl-source':Updated input 'flake-compat':
    'github:edolstra/flake-compat/9100a0f413b0c601e0533d1d94ffd501ce2e7885?narHash=sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX%2BfjA8Xf8PUmqCY%3D' (2025-05-12)
  → 'path:/nix/store/b0my5vy8pzfzjqrr3g58j0w6md9jf3ch-source?lastModified=1&narHash=sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX%2BfjA8Xf8PUmqCY%3D' (1970-01-01)Updated input 'flake-parts':
    'github:MattSturgeon/flake-parts/ebfbd32548b4bd19a5315ec08e489c01ef0978e2?narHash=sha256-xg5ssb8T8t28umxjtpLmSJusKUdAb0r%2BZ2DJRHh0cD0%3D' (2025-02-24)
  → 'path:/nix/store/ym4gk90zcjrsq9anrvybjvsghcis5j5w-source?lastModified=1&narHash=sha256-xg5ssb8T8t28umxjtpLmSJusKUdAb0r%2BZ2DJRHh0cD0%3D' (1970-01-01)Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5?narHash=sha256-XexyKZpf46cMiO5Vbj%2BdWSAXOnr285GHsMch8FBoHbc%3D' (2025-08-25)
  → 'path:/nix/store/r33xw4w5nmpmfac4g47h1lmrcl4qlz7k-source?lastModified=0&narHash=sha256-XexyKZpf46cMiO5Vbj%2BdWSAXOnr285GHsMch8FBoHbc%3D' (1970-01-01)
unpacking 'github:nix-community/nix-unit/388045c7bee5a2617cca8e94444bea1862df19ac?narHash=sha256-OLaoMtlNL5AvYuaQ5P4p7riy7M9J8XpFdWKpD5RzQfU%3D' into the Git cache...
warning: error: unable to download 'https://github.com/nix-community/nix-unit/archive/388045c7bee5a2617cca8e94444bea1862df19ac.tar.gz': Could not resolve hostname (6) Could not resolve host: github.com; retrying in 325 ms

Maintainers ping

cc @roberth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions