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
Conversation
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
There was a problem hiding this comment.
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. :)
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.
Thanks a lot for this! ❤️ |
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 toThis 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
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)