Open endgame opened 3 months ago
- Emit per-system functions by setting them in
perSystem
, or
Can be done by defining flake.lib.something
using the withSystem
module argument.
Example:
{ lib, withSystem, ... }: {
perSystem = mkPerSystemOption {
options.lib = mkOption { type = raw; internal = true; };
config.lib.freeze = <...>;
};
flake.lib.freeze = drv:
withSystem drv.system ({ config, ... }:
config.lib.freeze drv
);
}
- Call an equivalent to
eachSystem
without having to go throughflake-utils
?
You could define lib
using perSystem
, similar to how flake-parts
does it for other attributes. The formatter.nix
is a reasonable template for this, if you omit perInput
, because the format of lib
isn't standardized for arbitrary flakes.
I'm not a big fan of doing it this way, because system
attributes are bothersome.
(3?)
You could expose a flake-parts module that adds your library as a module argument. That way it can use the user pkgs
, which can be something fancy, like a cross compiled package set.
I ported
nix-freeze-tree
toflake-parts
. It exports a function for freezing a derivation as a tree of fixed-output derivations and uses a native program to do this. Because I can't assign tolib
inperSystem
, I am forced to declare these functions inflake
and useflake-utils
'eachSystem
to generate this function. Is there a better way to either:perSystem
, oreachSystem
without having to go throughflake-utils
?https://git.sr.ht/~jack/nix-freeze-tree/tree/343fd80a67db6f55cacc1961f60bbac91d96bbb6/item/flake.nix#L27-52 is what I am currently doing.