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

borgmatic: Allow top-level extra options #3793

Closed

Conversation

DamienCassou
Copy link
Contributor

@DamienCassou DamienCassou commented Mar 20, 2023

Description

Fix #3760

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • 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.

    • Added myself and the module files to .github/CODEOWNERS.

@DamienCassou DamienCassou marked this pull request as draft March 20, 2023 19:23
@DamienCassou DamienCassou marked this pull request as ready for review March 20, 2023 19:44
@DamienCassou DamienCassou mentioned this pull request Mar 20, 2023
@@ -168,7 +170,7 @@ let
} // config.retention.extraConfig;
consistency = removeNullValues { checks = config.consistency.checks; }
// config.consistency.extraConfig;
};
} // config.extraConfig);
Copy link
Member

Choose a reason for hiding this comment

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

It may be a bit unfortunate that this doesn't do a recursive update so consistency.extraConfig = … would give a different result compared to extraConfig.consistency = ….

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is a very good point. Would you mind giving me a clue on how to implement that please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after discussing on Matrix, we decided to:

  1. get rid of all the extraConfig options and only keep the top-level one
  2. use mkRenamedOptionModule to warn the user about the deprecated API

Unfortunately, I've been unable to make it work. I pushed a WIP commit to show my latest try. Can someone please help?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latest issue I have is

error: You're trying to declare a value of type `list'
       rather than an attribute-set for the option
       `programs.borgmatic.backups.<name>.imports'!

       This usually happens if `programs.borgmatic.backups.<name>.imports' has option
       definitions inside that are not matched. Please check how to properly define
       this option by e.g. referring to `man 5 configuration.nix'!
(use '--show-trace' to show detailed location information)

Copy link
Member

Choose a reason for hiding this comment

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

The immediate problem is that you're defining imports inside options, but it should be at the same level as config and options.

The real problem is that these mkRemovedOptionModules will not work because of NixOS/nixpkgs#96006. The most promising attempt to fix that is currently NixOS/nixpkgs#207187.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand what @ncfavier just said, it seems impossible to deprecate the non-top-level extraConfig options for now. Having both a top-level extraConfig option and having non-top-level ones is messy.

The only solution I see is to have no top-level extraConfig option. As a result, I suggest we introduce a top-level option for each of borgmatic's setting sections and add one extraConfig for each. If I'm not mistaken after reading the example configuration file, this just means adding output and hooks top-level options.

What do you think @ncfavier and @rycee?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented this approach in #4108.

@DamienCassou
Copy link
Contributor Author

Can someone please answer my question?

@DamienCassou
Copy link
Contributor Author

@ncfavier and @rycee: I would really like to get an answer on this.

@DamienCassou
Copy link
Contributor Author

Closing this PR in favor of #4108.

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.

Borgmatic Hooks?
3 participants