Skip to content

Can flake-parts help with sharing code with nixosModules/darwinModules exports? #265

Answered by roberth
z0al asked this question in Q&A
Discussion options

You must be logged in to vote

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:

{ self, customThing }:
{ config, withSystem, ... }:
{
  # module attrs
}

I would recommend to use a name that's not lib for anything other than the Nixpkgs lib, but some will disagree with that :)

import ./module.nix

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 to imports, options of type deferredModule, and …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@z0al
Comment options

@z0al
Comment options

@roberth
Comment options

Answer selected by z0al
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants