Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use a modified version of a module? #28

Closed
voidzero opened this issue Apr 8, 2023 · 2 comments
Closed

How to use a modified version of a module? #28

voidzero opened this issue Apr 8, 2023 · 2 comments

Comments

@voidzero
Copy link

voidzero commented Apr 8, 2023

Hi! I'd like to make a few changes to this module:

https://github.com/NixOS/nixpkgs/blob/nixos-22.11/nixos/modules/tasks/network-interfaces.nix

But I want to test them for myself before I issue a pull request. How can I do this in the 'standard' flake?

Thanks and have a blessed easter weekend,
Mark

@Misterio77
Copy link
Owner

Misterio77 commented Apr 20, 2023

Hey!

It's actually pretty straightforward.

  • Add that module as you would any other:
    • Move it into your modules/modules/
    • List it at modules/modules/default.nix
    • Import it in your NixOS config. For example:
{ outputs, ... }: {
  imports = [ outputs.nixosModules.foo-bar ];
}
  • You must now disable nixpkgs's version by adding it to a top-level (i.e. next to options, config, imports). disabledModules attribute anywhere in your config
    • I'd recommend you add that at the module itself, right here.
    • It should be a string that is the path to the original nixpkgs module file, relative from nixos/modules. In your case it would be:
{
  disabledModules = [ "tasks/network-interfaces.nix" ];
  # ...
}

Here's some docs about replacing modules. Hope this helps!

@voidzero
Copy link
Author

Thanks for the pointers - here and on the Discord channel. 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants