How to split home manager config to different files

Hi,

Background info

I am running NixOS 22.11 and install home manager as module.

home.nix file is imported as below on configuration.nix

  home-manager = {
    useGlobalPkgs = true;
    useUserPackages = true;
    users.<username> = import ./home.nix;
  };

Problame statement

I am trying to split home manager configs to different files under apps folder then import them back to home.nix.

For example, I have below config on apps/zsh.nix.

{
  programs.zsh = {
    enable = true;
  }
}

Then I import it back to home.nix file

  imports = [
    ./apps/zsh.nix
  ];

When I rebuild, I am getting below error

$ sudo nixos-rebuild switch                                                                                        
building Nix...
building the system configuration...
error: syntax error, unexpected '['

       at /etc/nixos/apps/zsh.nix:1:107:

            1| {                                                                                                         
             |                                                                                                           ^
            2|   programs.zsh = {
(use '--show-trace' to show detailed location information)

Question

Does anyone know how to fix this? Or if I’ve done something wrong, can you please suggest another approach to do this?

Thank you

1 Like

Line 1, column 107? do you have a really long bunch of whitespace in that file followed by a [?

:sweat_smile:

Thanks… it turns out I copied terminal time accidentally to the file… removing that solved the issue.