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

sanoid: fix sanoid.conf generation #83904

Merged
merged 1 commit into from Jun 30, 2021
Merged

Conversation

ju1m
Copy link
Contributor

@ju1m ju1m commented Mar 31, 2020

Motivation for this change

sanoid currently generates a bogus sanoid.conf: defaults of NixOS' options are put into templates and into datasets (making the use of templates useless).

Things done

Simplify the generation of sanoid.conf.
As in other modules like services.postfix.config I'm also renaming options to use original names because they are 1:1 mapping to sanoid's config.

A relevant discussion, on #nixos-dev:

julm : while I'm at writing a fix to nixos/modules/services/backup/sanoid.nix (which generates a bogus configfile) I'm wondering if there is a rationale for using CamelCase for options which are direct mapping to sanoid options which use snake_case? eg. use_template becomes useTemplate in NixOS. I'd personnaly prefer to stick to the original, but what's the policy?
rnhmjoj : julm: if it's not too late.. i know at least of the matrix-synapse module, which keeps the original snake_case names. there are also the module.settings options from RFC 0042. personally i don't like having different options styles but keeping the original also has value.
julm : rnhmjoj: thanks!
julm : I'll try to justify to keep the original names because it makes the code simpler (no mapping to be done before supplying the attrset to toINI)
rnhmjoj : julm: if you are doing a 1:1 map of options, yes, i would keep the original names

<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->

- [ ] Tested using sandboxing ([nix.useSandbox](http://nixos.org/nixos/manual/options.html#opt-nix.useSandbox) on NixOS, or option `sandbox` in [`nix.conf`](http://nixos.org/nix/manual/#sec-conf-file) on non-NixOS linux)
- Built on platform(s)
   - [X] NixOS
   - [ ] macOS
   - [ ] other Linux distributions
- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review wip"`
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
- [ ] Determined the impact on package closure size (by running `nix path-info -S` before and after)
- [ ] Ensured that relevant documentation is up to date
- [X] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).

nixos/modules/services/backup/sanoid.nix Show resolved Hide resolved
type = types.ints.unsigned;
default = 48;
type = with types; nullOr ints.unsigned;
default = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch here. This was changed from using null defaults late in the review cycle for the original PR (#72060 (comment)) and I didn't consider the side effects.

cc @infinisil

Copy link
Member

Choose a reason for hiding this comment

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

Agree, when reading the nixos docmentation, null can be confusing. I'd rather like having an explicit default.

nixos/modules/services/backup/sanoid.nix Show resolved Hide resolved
Copy link
Contributor

@lopsided98 lopsided98 left a comment

Choose a reason for hiding this comment

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

This looks good and I have tested it on my systems.

The only thing I noticed is that the comment on line 13 should probably be removed because this module doesn't have defaults anymore.

We really should backport this PR to 20.03 because without it sanoid is pretty broken. We can't backport it as is because it is a breaking change, but I think backporting just the null defaults should work.

@ju1m ju1m force-pushed the sanoid branch 2 times, most recently from 42111d9 to 23a5833 Compare April 27, 2020 15:24
@ju1m
Copy link
Contributor Author

ju1m commented Apr 27, 2020

I've separated the changes in two commits so that the fix could be cherry-picked in 20.03.

Copy link
Contributor

@lopsided98 lopsided98 left a comment

Choose a reason for hiding this comment

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

Thanks for making the backport easier. I think this is ready to merge.

@infinisil perhaps you can take a look at this since you reviewed the initial sanoid PR?

Copy link
Member

@picnoir picnoir left a comment

Choose a reason for hiding this comment

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

Could you adress the release note typo and rebase this PR?

Not a big fan of the implicit default values, but why not. @lopsided98, you're the maintainer, it's your call.

If you're ok with that, I think this PR is ready to be merged.

<listitem>
<para>
<literal>services.sanoid.datasets.*.useTemplate</literal> has been renamed to
<literal>services.sanoid.datasets.*.useTemplate</literal> to match upstream name.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<literal>services.sanoid.datasets.*.useTemplate</literal> to match upstream name.
<literal>services.sanoid.datasets.*.use_template</literal> to match upstream name.

type = types.ints.unsigned;
default = 48;
type = with types; nullOr ints.unsigned;
default = null;
Copy link
Member

Choose a reason for hiding this comment

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

Agree, when reading the nixos docmentation, null can be confusing. I'd rather like having an explicit default.

@lopsided98
Copy link
Contributor

Not a big fan of the implicit default values, but why not. @lopsided98, you're the maintainer, it's your call.

Is there an alternative that allows templates to work correctly?

@numinit
Copy link
Contributor

numinit commented Sep 8, 2020

Didn't realize this was a problem, but fix makes sense to me. +1

@lopsided98
Copy link
Contributor

I'm trying to find someone with merge privileges who can take a look at this PR. Could you move the release notes to 21.03 so hopefully it will be ready to merge?

@ju1m ju1m force-pushed the sanoid branch 2 times, most recently from f57f200 to 9edd200 Compare November 16, 2020 02:18
@ju1m
Copy link
Contributor Author

ju1m commented Nov 16, 2020

@lopsided98 I've rebased against current master.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/372

Copy link
Contributor

@lopsided98 lopsided98 left a comment

Choose a reason for hiding this comment

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

I just realized this needs to update the NixOS test with the new option names.

@ju1m
Copy link
Contributor Author

ju1m commented Nov 25, 2020

@lopsided98 thanks, I've fixed nixos/tests/sanoid.nix.

@ju1m
Copy link
Contributor Author

ju1m commented Feb 17, 2021

Rebase and fix merge conflict due to the rename nixos/doc/manual/release-notes/rl-21{03 => 05}.xml in cfed3b8

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

It would be nice if we could map the old options to the new ones.

@ju1m
Copy link
Contributor Author

ju1m commented Jun 27, 2021

@SuperSandro2000 old options are now supported as you requested.

default = [];
};
useTemplate = use_template;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SuperSandro2000 AFAICS mkRenamedOptionModule does not work for options in submodules, that's why I've used mkAliasDefinitions instead.

@SuperSandro2000 SuperSandro2000 merged commit 30e2735 into NixOS:master Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants