Trying to install helix editor but error: the option 'enable' is already declared

I’m trying to install helix editor via home-manager on macOS using the helix flake from:

https://github.com/nix-community/home-manager/blob/c59f0eac51da91c6989fd13a68e156f63c0e60b6/modules/programs/helix.nix

and this as my home-manager flake (that works - at least until I added the path to the helix.nix file in modules:

{
  description = "Home Manager configuration of me";

  inputs = {
{
  description = "Home Manager configuration of me";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, home-manager, ... }:
    let
      username = "me";
      system = "x86_64-darwin";
    in {
      homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
        pkgs = nixpkgs.legacyPackages.${system};
        modules = [
          {
            home = {
              inherit username;
              homeDirectory = "/Users/${username}";
              stateVersion = "22.11";
            };
            programs.home-manager.enable = true;
          }
            ./home-manager/modules/gui/editors/helix.nix
        ];
        # Optionally use extraSpecialArgs
        # to pass through arguments to home.nix
      };
    };
}

but I am getting the following error:

The option programs.helix.enable’ in /nix/store/6zxkqbrcw5r5yi6hmk3xf17y6wqiqs0h-source/modules/programs/helix.nix' is already declared in /nix/store/7jpmwypn48hx9abv2fys0zs0mm693mk2-source/home-manager/modules/gui/editors/helix.nix’.`

Am I misunderstanding how to install programs via home-manager?

I ask, because when I look at the docs…


https://nix-community.github.io/home-manager/index.html#sec-install-standalone

I get the impression that some programs can just be enabled via a boolean (that home-manager then installs silently in the background??), whereas other programs may require enabling and their own config file (for example as a flake).

Home-manager already has its own helix module:

https://nix-community.github.io/home-manager/options.html#opt-programs.helix.enable

So you either need to disable that, or can’t use the module provided by the helix flake.

You should still be able to use programs.helix.package to use the version from the helix repo though.

1 Like

Thanks @NobbZ!

I went with the built-in home-manager way you mentioned via programs.helix.enable and it ‘just worked’!

My main focus to-date has been getting nix and home-manager installed and working while having a basic understanding of the benefits of nix and less of home-manager. Your answer has clarified more of the benefits of home-manager.

If you get a moment, could you please have a look at my newb question in:

https://discourse.nixos.org/t/when-to-use-git-for-nix/24930/2

Many thanks!