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

Allow multiple backups files #6243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

colonelpanic8
Copy link
Contributor

…he backup file path

Description

Allow multiple backup files -- avoid failing the "switch home manager configuration".

Checklist

  • [x ] Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@teto
Copy link
Collaborator

teto commented Jan 1, 2025

if you need multiple backup files, I am tempted to think something is wrong with setup so I would lean against the feature. Do you have a specific scenario in mind ?

@colonelpanic8
Copy link
Contributor Author

if you need multiple backup files, I am tempted to think something is wrong with setup so I would lean against the feature. Do you have a specific scenario in mind ?

It's not that I need multiple backup files -- its just that I find it very annoying that this fails if there was a preexisting backup file.

In my case, my gtkrc files sometimes get overwritten by certain programs and my home manager activation is constantly failing because of this. I don't really care about the files that are getting overwritten and I think trying to aim for the default of almost never failing is a good idea.

@teto
Copy link
Collaborator

teto commented Jan 1, 2025

you can set force = true to forcefully update the file (check the code to find examples), which solves your issue in a better way IMO.

Comment on lines +38 to +42
counter=1
while [[ -e "$backup" ]]; do
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT.$counter"
counter=$((counter + 1))
done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stat tends to be slow in some systems (especially in macOS), and considering that this is affecting you at every new generation it means you will eventually end up having multiple files and your switch taking longer and longer.

I concur with @teto here, it is better to use force in your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants