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

nixos/grafana: Remove duplicate plugins and add service script error handling #125703

Merged
merged 2 commits into from Jun 7, 2021

Conversation

talyz
Copy link
Contributor

@talyz talyz commented Jun 4, 2021

Motivation for this change

Fixes two issues I had when trying to use the module:

  • Remove duplicate plugins

    If the same plugin appears multiple times in declarativePlugins, for example due to being added both by a module and in user config, the build fails with an error message similar to

    ln: failed to create symbolic link 'grafana-worldmap-panel/glmqcj88zk2bz3mvdr3r7920wxg02qnq-grafana-worldmap-panel-0.3.2': Permission denied
    

    This is solved by removing all duplicates.

  • Add service script error handling

    The services starts even if files are missing or prerequisite commands fail, which can lead to incorrect initial state.

    Solved by adding some boilerplate bash error handling and exporting variables in a separate step (subshell errors aren't propagated otherwise).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside 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/)
  • 21.11 Release Notes
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

declarativePlugins = mkOption {
type = with types; nullOr (listOf path);
default = null;
description = "If non-null, then a list of packages containing Grafana plugins to install. If set, plugins cannot be manually installed.";
example = literalExample "with pkgs.grafanaPlugins; [ grafana-piechart-panel ]";
apply = x: if isList x then lib.unique x else x;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just add a comment here for why we are adding this.
Just so we can remember later in case it ever needs to be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment. I hope it's readable enough. :)

talyz added 2 commits June 7, 2021 09:21
If the same plugin appears multiple times in `declarativePlugins`, for
example due to being added both by a module and in user config, the
build fails with an error message similar to

ln: failed to create symbolic link 'grafana-worldmap-panel/glmqcj88zk2bz3mvdr3r7920wxg02qnq-grafana-worldmap-panel-0.3.2': Permission denied

This is solved by removing all duplicates.
Without this, the services starts even if files are missing or
prerequisite commands fail, which can lead to incorrect initial
state.
@happysalada
Copy link
Contributor

Thanks a lot for this! ❤️

@happysalada happysalada merged commit 4138713 into NixOS:master Jun 7, 2021
@talyz talyz deleted the grafana-fixes branch June 7, 2021 12:34
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

3 participants