API reference¶
default.nix¶
Evaluate a flake without the flake evaluator. flake-compatish reads
flake.nix and flake.lock and calls outputs itself.
Inputs¶
argsA path, or an attrset. A path
pis short for{ source = p; overrides.self = p; }, which evaluatespin place with no store copy.sourceThe flake to evaluate: a path, or a flake reference string.
overrides(default{ })Input name to a path, used in place, or a flake reference string, fetched.
selfnames the root. A name that is notselfor a root input is ignored and not evaluated. A path that does not exist falls back to the lockfile.overridesFile(defaultsource + "/overrides.nix")An optional machine-local file of the same shape. It is read only in impure evaluation, and it wins over
overrides.systemOverrides(defaulttrue)The machine's overrides, matched by flake reference and not by name, at every depth.
truereads the file the NIX_PATH entryflake-compatish-overridesnames,falsereads nothing, and a path, attrset or function is used instead. Impure evaluation only. It wins overoverridesand loses to the local file.warnOverrides(defaulttrue)Print a warning for each override that applies.
reroot(default{ })Input name to an evaluated flake, or to a function from the flake that would have been used to its replacement. It applies at every depth.
nixpkgsArgs(defaultnull)A function from a system to the arguments for the root
nixpkgsinput. The result replacesself.legacyPackagesin compatible flakes.
Set FLAKE_COMPATISH_DISABLE_OVERRIDES=1 to ignore overrides, the local
file, the system-wide overrides and reroot, and evaluate from the
lockfile alone.
Output¶
outputsThe root flake, as another flake would see it.
inputsThe root's resolved inputs, and
self.impureoutputs, withbuiltins.currentSystemselected in each attribute that has it.compatishThe
lib.nixresult for the same evaluation:override,argsandsources, with strict name checks. Evaluated only when read.
Examples¶
default.nix usage example¶
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
flake-compatish = builtins.fetchTree lock.nodes.flake-compatish.locked;
in
import flake-compatish {
source = ./.;
overrides = {
self = ./.;
# Not `~/Code/nixpkgs`: pure evaluation rejects `~` while parsing.
nixpkgs = /. + builtins.getEnv "HOME" + "/Code/nixpkgs";
};
}
lib.nix¶
The overridable entrypoint. default.nix stays a plain flake-compat shim;
this one returns a result you can override again after import, after
sprinkles.
flake-compatish.lib.new¶
Evaluate a flake, and return a result that can be overridden again.
The result has the attributes default.nix returns, and also:
argsThe arguments this result was evaluated with.
sourcesThe root's inputs as fetched: after
overrides, beforereroot.overrideRe-evaluate with changed arguments. An attrset merges into
args, and itsoverridesandrerootmerge key by key. A function gets the previousargsand returns the attrset to merge with//, so it can also remove a key.
Inputs¶
argsA path, or an attrset with the arguments
default.nixtakes. Also:strict(defaulttrue)Abort on an
overridesname that is notselfor a root input, and on arerootname that no flake in the graph declares.default.nixignores such names; here they are typos until proved otherwise. A localoverrides.nixis never checked, because it is the machine's and not the project's.
A reroot value can be a function. It gets the flake that would have
been used, and returns the one to use instead.
Examples¶
new usage example¶
let
fc = import "${flake-compatish}/lib.nix";
flake = fc.new ./.;
in
(flake.override { overrides.nixpkgs = /. + builtins.getEnv "HOME" + "/Code/nixpkgs"; })
.impure.packages.default
nix/core.nix¶
The evaluator behind both entrypoints. Internal: the public interface is
default.nix and lib.nix.
default.nix returns compat. nix/overridable.nix also reads the
attributes beside it.
Inputs¶
argsA path, or the attrset
default.nixdocuments.
flake-compatish.core.compat¶
What default.nix returns, without compatish: inputs, outputs and
impure.
flake-compatish.core.args¶
The arguments as an attrset. A path argument becomes
{ source = path; overrides.self = path; }.
flake-compatish.core.overrideNames¶
The names overrides accepts: self and the root's inputs.
flake-compatish.core.rerootNames¶
The names reroot accepts: every input name declared anywhere in the
graph.
flake-compatish.core.sources¶
The root's inputs as fetched, after overrides and before reroot.
nix/overridable.nix¶
Wraps one core evaluation into the overridable result that lib.nix
documents. Internal.
It takes the core's output, not its arguments, so default.nix can share
a single evaluation between its own attributes and compatish.
Type¶
overridable :: CoreResult -> AttrSet