Files
kenji cb4c48742b
buildbot/nix-eval evaluation succeeded
Nix Flake Check / check (pull_request) Successful in 2m23s
Nix Flake Check / check (push) Successful in 2m42s
buildbot/nix-build 27 attributes built
gitea-mq Already up to date with target branch
import-flake/tests: materialize Fixture in the store
Materialize the fixture in the store, otherwise we get an error:
`ENOENT`.
2026-08-11 10:36:56 +02:00
..

clan-community lib

import-flake.nix

Import a remote flake without builtins.getFlake. Only fetches the source tree and reuses local inputs where possible, avoiding redundant downloads.

Problem

Using builtins.getFlake on a remote flake fetches all of its inputs (including its own nixpkgs), even when you already have the same inputs locally.

Solution

import-flake.nix uses builtins.fetchTree to get just the source, reads the remote flake.lock, and:

  • Auto-passes matching local flake inputs (e.g., your nixpkgs, flake-parts)
  • Fetches from the remote lock only inputs you don't provide
  • Resolves follows correctly, so transitive dependencies use your local inputs too

Usage in services

Services declare their external flake dependency via the clan-community.inputs flake-parts option:

# services/myservice/flake-module.nix
{ config, ... }:
{
  config = {
    clan-community.inputs.myservice.src = {
      type = "github";
      owner = "someone";
      repo = "myservice";
      rev = "abc123...";
    };

    clan.modules.myservice = import ./default.nix {
      inherit (config.clan-community) inputs;
    };
  };
}

Then in the service module, access the resolved flake:

# services/myservice/default.nix
{ inputs }:
{
  _class = "clan.service";
  # ...
  roles.default.perInstance = { ... }: {
    nixosModule = { ... }: {
      imports = [ inputs.myservice.outputs.nixosModules.default ];
    };
  };
}

Overriding from a consumer flake

Users importing clan-community can override the source or specific inputs:

# Override the revision
clan-community.inputs.myservice.src = {
  type = "github";
  owner = "someone";
  repo = "myservice";
  rev = "def456...";
};

# Override a specific input of the remote flake
clan-community.inputs.myservice.inputs.some-dep = my-some-dep;

Option reference

clan-community.inputs.<name>.src

Type: attrset (passed to builtins.fetchTree)

The flake source to fetch. Typically { type = "github"; owner; repo; rev; }.

clan-community.inputs.<name>.inputs

Type: attrset of raw values
Default: {}

Override specific inputs of the remote flake. These take precedence over auto-matched local inputs.

clan-community.inputs.<name>.outputs

Type: raw (read-only)

The resolved flake outputs. Equivalent to what builtins.getFlake would return, but using your local inputs where names match.