1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-22 19:19:45 +01:00
home-manager/nixos
Michael Hoang 192f123e4b
nixos: add key to shared module to allow disabling it (#6017)
By adding `key`, this allows users to disable this shared module or they can choose to not disable this shared module (by filtering by key before disabling)

This means users can disable all shared modules if all modules are paths or attrsets with a key:

`configuration.nix`:

```nix
{ config, ... }:

{
  home-manager.users.enzime = { ... }: {
    disabledModules = config.home-manager.sharedModules;
  };
}
```

Or disabling just this module specifically:

```nix
{ ... }:

{
  home-manager.users.enzime = { ... }: {
    disabledModules = [ { key = "home-manager#nixos-shared-module"; } ];
  };
}
```

Or disabling all modules when you have modules you can't disable (like lambdas):

```nix
{ ... }:

{
  home-manager.users.enzime = { ... }: {
    disabledModules = lib.filter (v: lib.isString v || lib.isPath v || (lib.isAttrs v && v ? key)) config.home-manager.sharedModules;
  };
}
```


https://nixos.org/manual/nixos/unstable/#sec-replace-modules
2024-11-16 18:31:16 +01:00
..
common.nix home-manager: set module class to "homeManager" 2024-04-27 09:28:21 +02:00
default.nix nixos: add key to shared module to allow disabling it (#6017) 2024-11-16 18:31:16 +01:00