nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.64k stars 1.74k forks source link

Implement `backupFileExtension` as an option with `lib.homeManagerConfiguration` use-cases. #5649

Open shymega opened 1 month ago

shymega commented 1 month ago

Description

I'm on NixOS 24.05 (plus HM 24.05), and I was wondering if it would be possible to allow the usage of backupFileExtension for Home Manager configurations using lib.homeManagerConfiguration. Currently, I can see the option is implemented when HM is used as a NixOS module, or a nix-darwin module.

However, my config is based around the lib.homeManagerConfiguration module. I could embed it in the NixOS config, but on some systems, I can't install NixOS.

I've done basic searches in the issue tracker, and AFAICT, but this hasn't been implemented yet.

Thoughts?

Liassica commented 1 month ago

You could make home-manager an alias for home-manager -b "<backup extension>"; for example, I use -b "hm.bak".

shymega commented 1 month ago

Hello,

On 23.07.2024 14:59, Liassica wrote:

You could make home-manager an alias for home-manager -b "<backup extension>"; for example, I use -b "hm.bak".

-- Reply to this email directly or view it on GitHub: https://github.com/nix-community/home-manager/issues/5649#issuecomment-2246385397 You are receiving this because you authored the thread.

Message ID: @.***>

Yes, I could. But that wouldn't be declarative. I would rather it be checked in with my Nix Flake.

I've had a look at the sources, but I am not sure where would be the best way to integrate this argument.

Best wishes,

Dom Rodriguez GPG Fingerprint: EB0D 45E6 D0DC 1BA1 A2B5 FC24 72DC F123 1E54 BD43

Liassica commented 1 month ago

If you use Home Manager to manage your shell, you can set aliases declaratively:

home.shellAliases.home-manager = "home-manager -b hm.bak";
shymega commented 1 month ago

This is true. However, I believe this should be implemented in the Nix hmModule itself.

When I get around to moving my shell config to Home Manager, I'll keep your suggestion in mind.

shymega commented 2 weeks ago

Looking through the exposed homeManagerConfiguration function via lib, I think it would be possible to use backupFileExtension, as an additional parameter.

I would like homeManagerConfiguration to have this argument and do not think using shell aliases solves the issue.

Would the maintainers be open to a PR adding this functionality?

Thank you.