-
Given the following flake: {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
{ self
, nixpkgs
, flake-parts
, ...
}@inputs:
let
# Q: How to ensure this is passed to nixosModules/darwinModules?
lib = nixpkgs.lib.extend
(final: prev: (import ./lib final));
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
...
];
flake = {
nixosModules.default = import ./module.nix;
darwinModules.default = import ./darwin-module.nix;
};
};
} How do I pass my custom lib to I tried Alternatively: what's the easiest way to share code (read custom helpers) between these exports in my case? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think you're looking for You can use it to pass anything to a module file. { self, customThing }:
{ config, withSystem, ... }:
{
# module attrs
} I would recommend to use a name that's not
|
Beta Was this translation helpful? Give feedback.
I think you're looking for
importApply
You can use it to pass anything to a module file.
Basically your module file will be a function to a module, arity 2:
I would recommend to use a name that's not
lib
for anything other than the Nixpkgslib
, but some will disagree with that :)import
will throw away the file name, and the module system won't know where it came from, leading to worse error messages.importApply
solves that problem.If you did't need to pass anything custom, it's better to do
nixosModules.default = ./module.nix;
etc. Also applies toimports
, options of typedeferredModule
, and …