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

Module overriding inside home.nix (e.g. through imports and disableModules) #2740

Closed
ShamrockLee opened this issue Feb 20, 2022 · 7 comments
Closed
Assignees

Comments

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Feb 20, 2022

Description

I haven't found a way to override the Home Manager modules for standalone without dilect patching to the home-manager source tree.

If is a modular way to override the modules, just as what imports = [ "path/to/foo", ... ]; and disableModules = [ bar/baz, ... ] do on NixOS, is available in Home Manager, users will be able to get modules from multiple sources, and module testing will be a piece of cake.

Without such mechanism, changse such as #2718 will be untestable without switching the source branch.

@berbiche
Copy link
Member

Hi,

Home Manager supports the disabledModules feature of NixOS.

For instance, to disable the swayidle service, you can set disabledModules = [ "services/swayidle.nix" ].

The modulesPath functionality that allows using disabledModules was added in October and is only available in the "master" branch currently.

See:

@ShamrockLee
Copy link
Contributor Author

@berbiche I mean supporting imports, disableModules or similar functionality to override modules inside the Home Manager Configuratio (home.nix).

Stand-alone installation cannot make use of the NixOS and nix-darwin feature so far.

@ShamrockLee ShamrockLee changed the title Module overriding (e.g. through imports and disableModules) Module overriding inside home.nix (e.g. through imports and disableModules) Feb 20, 2022
@berbiche berbiche reopened this Feb 20, 2022
@berbiche
Copy link
Member

Hi again @ShamrockLee,

I've looked at our module code once more and the disabledModules feature should work.
The attribute modulesPath (used by the modules system to support disabledModules) is correctly exported in a standalone Home Manager configuration.

@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Apr 21, 2022

But I get this:

error: The option `disableModules' does not exist. Definition values:
       - In `<unknown-file>': [ ]
(use '--show-trace' to show detailed location information)

after having

{ config, lib, pkgs, ... }:
{
  disableModules = [
  ];

  # Something else ...
}

in my home.nix.

BTW, the Home Manager is set up as a flake (the way I have documented it in the manual). Not sure if it causes any difference:
https://nix-community.github.io/home-manager/index.html#sec-flakes-standalone

@berbiche
Copy link
Member

@ShamrockLee You used disableModules instead of disabledModules, you are missing a "d".

@ShamrockLee
Copy link
Contributor Author

Oops! Sorry for the typo, and thanks a lot for your patience!

The problem is now solved.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/can-home-manager-install-unstable-and-stable-programs-modules-not-just-pkgs/42919/13

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

No branches or pull requests

5 participants