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

Set module class to "homeManager" #5339

Closed
wants to merge 1 commit into from

Commits on Apr 26, 2024

  1. home-manager: Set module class to "homeManager"

    This enables a module system feature documented here:
    https://nixos.org/manual/nixpkgs/stable/index.html#module-system-lib-evalModules-param-class
    
    For example, it allows a mistake to be caught, which is loading
    a NixOS module into home-manager.
    This only works when the offending module declares what it's for
    with a `_class` attribute.
    
    It is not expected that users declare the `_type`, because the payoff
    is small. It is only expected to be set by generic code, such as
    functions or libraries that help with the "publishing" of modules
    (e.g. flake-parts, flake-utils).
    
    The class feature has been available in the module system since
    NixOS/nixpkgs#197547, merged May 6, 2023.
    It has been part of all releases since 23.05-beta.
    The last NixOS release that did _not_ support it has been end-of-life
    for close to a year now.
    
    Example:
    
        (lib.homeManagerConfiguration {
          pkgs = nixpkgs.legacyPackages.x86_64-linux;
          modules = [{ _class = "nixos"; imports = [ ./foo.nix ]; }];
        }).activation-script
    
    Corresponding error:
    
        error: The module <unknown-file> was imported into homeManager instead of nixos.
    
    (`<unknown-file>` can be improved by also setting `_file`, if known;
     a much older feature)
    roberth committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    56691ae View commit details
    Browse the repository at this point in the history