Question about using custom config files instead of home-manager config files

I currently have some config files from my previous distro that I’d like to use, and I’m not yet ready to convert them all to .nix files. For example, I have a ~/.config/rofi/config.rasi file that I want to reuse. However, when I try running sudo nixos-rebuild switch, I get an exit code from home-manager saying it would overwrite my files. I’ve seen the -b flag, which forces the home-manager config files, but is there a way to nicely source my own instead?

I’ve seen stuff like home.file.".config/rofi/config.rasi".source = ~/.config/rofi/config.rasi;
but that doesn’t seem to be working (rebuilding still fails)

This is the output of journalctl -xe --unit home-manager-abhamra.service

A start job for unit home-manager-abhamra.service has begun execution.
░░
░░ The job identifier is 5831.
Jan 11 19:19:57 abhamra hm-activate-abhamra[14964]: Starting Home Manager activation
Jan 11 19:19:57 abhamra hm-activate-abhamra[14964]: Activating checkFilesChanged
Jan 11 19:19:57 abhamra hm-activate-abhamra[14964]: Activating checkLinkTargets
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: Existing file '/home/abhamra/.config/polybar/config.ini' is in the way of '/nix/store/xval5bjp887msr54i6yyb70bylidvc59-home-manager-files/.config/polybar/config.ini', will be skipped since they are the same
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: Existing file '/home/abhamra/.config/zathura/zathurarc' is in the way of '/nix/store/xval5bjp887msr54i6yyb70bylidvc59-home-manager-files/.config/zathura/zathurarc'
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: Existing file '/home/abhamra/.config/nvim/init.lua' is in the way of '/nix/store/xval5bjp887msr54i6yyb70bylidvc59-home-manager-files/.config/nvim/init.lua'
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: Existing file '/home/abhamra/.config/rofi/config.rasi' is in the way of '/nix/store/xval5bjp887msr54i6yyb70bylidvc59-home-manager-files/.config/rofi/config.rasi'
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: Please do one of the following:
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: - Move or remove the above files and try again.
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: - In standalone mode, use 'home-manager switch -b backup' to back up
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]:   files automatically.
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]: - When used as a NixOS or nix-darwin module, set
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]:     'home-manager.backupFileExtension'
Jan 11 19:19:57 abhamra hm-activate-abhamra[14985]:   to, for example, 'backup' and rebuild.
Jan 11 19:19:57 abhamra systemd[1]: home-manager-abhamra.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit home-manager-abhamra.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 11 19:19:57 abhamra systemd[1]: home-manager-abhamra.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit home-manager-abhamra.service has entered the 'failed' state with result 'exit-code'.
Jan 11 19:19:57 abhamra systemd[1]: Failed to start Home Manager environment for abhamra.
░░ Subject: A start job for unit home-manager-abhamra.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit home-manager-abhamra.service has finished with a failure.
░░
░░ The job identifier is 5831 and the job result is failed.

Thanks

1 Like

If you don’t activate any programs.rofi config options, you should be able to keep all your rofi config where it is without doing anything.

If you do want some rofi config to come from Home Manager but other bits to come from your own files (and you aren’t happy with moving the extra bits into programs.rofi.extraConfig), then move the files you want to keep to some new location (~/.config/legacy/rofi, maybe), and point the home.file."...".source entries to there.

(Same advice if you replace ‘rofi’ with any other program that Home Manager manages.)

By any programs.rofi config options, do you include the enable = true? Because as far as I recall, my rofi section just contains enable. Also, the home.file."...".source stuff should be outside something like

programs.rofi = {
    enable = true;
    // other things
}

right?

Yes, enable is what matters. enable = true; tells Home Manager to manage that particular program’s config for you; if you don’t want that, don’t enable it.

And yes, home.file should exist ‘outside’ of anything else, though you could write it as

home = {
  file = {
    "whatever/path/here" = {
      source = ~/.config/legacy/whatever.cfg;
    };
  };
};

if you want to merge it with other home settings; it means exactly the same thing as

home.file."whatever/path/here".source = ~/.config/legacy/whatever.cfg;

.