# Override submodule options

**URL:** https://discourse.nixos.org/t/override-submodule-options/12165
**Category:** Help
**Created:** [March 26, 2021, 12:19pm UTC](https://discourse.nixos.org/t/override-submodule-options/12165 "2021-03-26T12:19:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![iSma](https://discourse.nixos.org/user_avatar/discourse.nixos.org/isma/32/3988_2.png) [@iSma](https://discourse.nixos.org/u/iSma)
#### Post date: [March 26, 2021, 12:19pm UTC](https://discourse.nixos.org/t/override-submodule-options/12165/1 "2021-03-26T12:19:08Z")

</div>

Hi there. Is there a way to override options nested inside an option of `type = attrsOf (submodule ...)`? I want to add an extra attribute to `networking.interfaces.<name>`. Is there a way to do this without editing the original source file?

---

<div class="post-metadata">

### Author: ![zzantares](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zzantares/32/3994_2.png) [@zzantares](https://discourse.nixos.org/u/zzantares)
#### Post date: [March 28, 2021, 5:34am UTC](https://discourse.nixos.org/t/override-submodule-options/12165/2 "2021-03-28T05:34:55Z")

</div>

I’m interested in this too, I needed to do something similar in editing options of `ohMyZsh` module, in the end I did as the [Replace Modules](https://nixos.org/manual/nixos/stable/index.html#sec-replace-modules) manual section suggests. I hid the “original” module, imported my custom one in my `configuration.nix` file and used it, however I couldn’t figure out how to change just bits of the code, I shamelessly copied the original, did my modifications on it and imported that.  
Although not ideal, until I find something better this gets the work done.

---

<div class="post-metadata">

### Author: ![nrdxp](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nrdxp/32/8501_2.png) [@nrdxp](https://discourse.nixos.org/u/nrdxp)
#### Post date: [March 28, 2021, 5:58am UTC](https://discourse.nixos.org/t/override-submodule-options/12165/3 "2021-03-28T05:58:42Z")

</div>

There was an [issue](https://github.com/NixOS/nixpkgs/issues/16884) opened on nixpkgs a while ago on this very topic, but adding this functionality seems to have been overly complex and it was closed. The current workaround, as @zzantares described, is disabling the old module completely in `disabledModules` and then making a copy of it with your extensions added in.

---

<div class="post-metadata">

### Author: ![iSma](https://discourse.nixos.org/user_avatar/discourse.nixos.org/isma/32/3988_2.png) [@iSma](https://discourse.nixos.org/u/iSma)
#### Post date: [April 8, 2021, 6:22am UTC](https://discourse.nixos.org/t/override-submodule-options/12165/4 "2021-04-08T06:22:41Z")

</div>

Turns out it was easier than expected, you just need to redefine the `attrsOf` option, and it looks like the module system will take care of merging the sub-options:

```auto
{ config, lib, ... }:
with lib;
let
  interfaceModule = { name, config, ... }:
    {
      options = {
        myNewOption = mkOption {
          type = types.str;
        };
      };
    };
in
{
    options = {
      networking.interfaces = mkOption {
        type = types.attrsOf (types.submodule interfaceModule);
      };
    };
}

```
