Skip to content
vic

jakehamilton/idc

Import Nix projects regardless of how they are exposed.

jakehamilton/idc.json
{
"createdAt": "2025-11-05T08:13:53Z",
"defaultBranch": "main",
"description": "Import Nix projects regardless of how they are exposed.",
"fullName": "jakehamilton/idc",
"homepage": null,
"language": "Nix",
"name": "idc",
"pushedAt": "2025-11-09T23:35:47Z",
"stargazersCount": 30,
"topics": [],
"updatedAt": "2025-11-22T20:45:08Z",
"url": "https://github.com/jakehamilton/idc"
}

Import Nix projects regardless of how they are exposed.

idc supports all of the following frameworks/libraries:

  • Nilla
  • Sprinkles
  • Flakes (with input overriding)
  • Nixpkgs (special cased to not import as a flake)
  • Plain default.nix files

Using idc is easy. Fetch it from this repository or even copy [./default.nix]!(./default.nix) to your project as idc.nix, then import idc.

let
idc = builtins.fetchTarball "https://github.com/jakehamilton/idc/archive/main.tar.gz";
# Or use a local copy
# idc = ./idc.nix;
in
# ...

To use idc, call the function with an attribute set containing:

Attribute NameTypeDescription
srcPath | DerivationThe source that you will be importing from.
loaderOptional StringManually set the loader to use (see [#loaders]). If left unset or set to null, idc will automatically select a loader.
settingsOptional AttributeSetSettings to pass to the loader (see [#loaders]).
# Import Nixpkgs
idc { src = my-nixpkgs; }
# Import a `default.nix` file, but call the function with arguments
idc {
src = my-legacy;
settings = {
args = {
system = "x86_64-linux";
};
};
}
# Import a flake, but override its nixpkgs input
idc {
src = my-flake;
settings = {
inputs = {
nixpkgs = my-nixpkgs;
};
};
}
# Import a Nilla project, but modify its configuration
idc {
src = my-nilla;
settings = {
extend = {
my-value.enable = true;
};
};
}
# Import a Sprinkle, but override it
idc {
src = my-sprinkle;
settings = {
override = {
my-value.enable = true;
};
};
}

A loader is a function which takes a source path and produces a useful value from it. Typically this means that a loader will do builtins.import src, but additional logic is common to support configuration of how an input is loaded. To use a loader, set loader when calling idc. Optionally, you may also set settings to customize how source is loaded.

Name: legacy

This loader is useful for loading default.nix files or any other *.nix file directly.

The following settings attributes can be set on the settings attribute set to customize functionality.

Attribute NameTypeDescription
targetOptional StringThe file to import in the source. This defaults to default.nix
argsOptional AnyIt is common for default.nix files to export a function which takes an attribute set as its argument. When setting args, idc will automatically call this function with the value provided.
idc {
src = my-source;
loader = "legacy";
settings = {
# Choose a different file to import in the source.
target = "subdir/other.nix";
# When the imported value is a function, call it with this argument.
args = {
x = 1;
y = 2;
z = 3;
};
};
}

Name: nixpkgs

This loader is useful for loading Nixpkgs via its default.nix file rather than its Flake (which idc typically prefers).

The value of settings is used when importing Nixpkgs.

idc {
src = my-source;
loader = "nixpkgs";
settings = {
# Any configuration for Nixpkgs can be used here.
system = "x86_64-linux";
overlays = [
# ...
];
config = {
# ...
};
};
}

Name: flake

This loader is useful for loading flake.nix files. Notably, you can choose to replace a Flake’s inputs if desired.

The following settings attributes can be set on the settings attribute set to customize functionality.

Attribute NameTypeDescription
targetOptional StringThe file to import in the source. This defaults to flake.nix and MUST end in flake.nix.
inputsOptional AttributeSetA set of inputs to use instead of the ones that are provided by the Flake.
idc {
src = my-source;
loader = "flake";
settings = {
# Choose a different flake location to import in the source.
target = "subdir/flake.nix";
inputs = {
# Replace only the my-helper input. Typically you will get the
# value to use (`my-helper-flake`) by calling `idc` to import
# that flake for use.
my-helper = my-helper-flake;
};
};
}

Name: nilla

This loader is useful for loading nilla.nix files.

The following settings attributes can be set on the settings attribute set to customize functionality.

Attribute NameTypeDescription
targetOptional StringThe file to import in the source. This defaults to nilla.nix.
extendOptional AttributeSetExtend the Nilla project’s configuration with the provided module.
idc {
src = my-source;
loader = "nilla";
settings = {
# Choose a different file to import in the source.
target = "subdir/nilla.nix";
# Call `project.extend` on the imported Nilla project using the
# value provided.
extend = {
# Any config option can be set for the Nilla project here.
my-value.enable = true;
};
# Note that `extend` can also be a function module.
# extend = { config }: { /* ... */ }
};
}

Name: sprinkles

This loader is useful for loading default.nix files that use Sprinkles.

The following settings attributes can be set on the settings attribute set to customize functionality.

Attribute NameTypeDescription
targetOptional StringThe file to import in the source. This defaults to default.nix.
overrideOptional AttributeSetOverride a Sprinkle using the provided value.
idc {
src = my-source;
loader = "sprinkles";
settings = {
# Choose a different file to import in the source.
target = "subdir/default.nix";
# Call `sprinkle.override` on the imported Sprinkle using the
# value provided.
override = {
# Any config option can be set for the Nilla project here.
my-value.enable = true;
};
};
}

Name: raw

This loader is a fallback which returns the source directly without importing it. Typically this will not be used, but exists for niche use cases or for debugging purposes.

No settings are available for this loader.

idc {
src = my-source;
loader = "raw";
}

I Don’t Care, as in “I don’t care what Nix library or framework this project is using, just import it.”