-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
piwik & piwik service: init at 3.0.4 #26073
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
Conversation
@florianjacob, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @joachifm and @offlinehacker to be potential reviewers. |
8f86def
to
d309b61
Compare
nixos/modules/misc/ids.nix
Outdated
@@ -295,6 +295,7 @@ | |||
aria2 = 277; | |||
clickhouse = 278; | |||
rslsync = 279; | |||
piwik = 280; |
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.
Why is a static uid required?
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.
My initial thought was so that the whole dataDir
folder /var/lib/piwik
can be easily restored from a backup, e.g. after a failure that needed a reinstall or on another machine.
In the meantime I learned that actually only a single file, /var/lib/piwik/config/config.ini.php
needs to be backed up. It's probably easy enough to fix uid+gid for a single file manually on restores, so I guess it's not that required anymore. Nothing in the code depends on it, I could simply remove the static assignment again.
This is my first nixpkg package, could you tell me more about in which cases and for what purposes it's considered good pratice to use static ids, and in which it isn't?
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.
The most clear-cut use for static uids is if you need to refer to a user before the user/uid mapping is established. Otherwise, you need to make a judgement about the kind of data the daemon generates, whether you'd transfer the data between hosts, whether ownership can be easily fixed up, what the privacy or security implications would be if the data ended up being owned (however transiently) by another user etc.
Relying on static uids to maintain ownership invariants is fragile imo (it won't help if you transfer data to a non-NixOS host, for example). Better to have code that enforces invariants you care about directly.
Now, I don't mean to say you should overthink this but there should be a reason for doing it :)
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.
Thanks alot for that explanation, that was very helpful. :)
I decided to remove the static ids and added a small chown+chmod script in the systemd unit that is executed as root and enforces the right ownership and permissions on startup instead. I figured that's much more beneficial to what I wanted to achieve, keeping things private while allowing an occasional but easy restore/move.
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.
Sounds good to me. If it turns out that a static uid makes more sense, it can always be added later (the other way 'round is a little harder).
@joachifm thanks for taking a look! 😄 |
258b4c1
to
3dd9633
Compare
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 some nitpicks for you to consider. None of them blockers.
home = dataDir; | ||
group = "${user}"; | ||
}; | ||
users.extraGroups = [ { name = "${user}"; } ]; |
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.
I think users.extraGroups.${user} = {}
would work as well.
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.
Much more elegant. 😃
requiredBy = [ "${phpExecutionUnit}.service" ]; | ||
before = [ "${phpExecutionUnit}.service" ]; | ||
# the update part of the script can only work if the database is already up and running | ||
requires = [ "${databaseService}" ]; |
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.
Note that "${foo}"
could be simplified to foo
.
serviceConfig = { | ||
Type = "oneshot"; | ||
User = user; | ||
Group = user; |
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.
Group
is strictly redundant, it defaults to the primary group of User
.
sha512 = "2i0vydr073ynv7wcn078zxhvywdv85c648hympkzicdd746g995878py9006m96iwkmk4q664wn3f8jnfqsl1jd9f26alz1nssizbn9"; | ||
}; | ||
|
||
phases = [ "unpackPhase" "patchPhase" "installPhase" ]; |
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.
Please consider disabling problematic phases instead of listing phases; this is a known source of bugs.
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 just throw this out completely, did learn that all default phases don't do anything like the buildPhase doesn't do anything if there is no Makefile.
|
||
phases = [ "unpackPhase" "patchPhase" "installPhase" ]; | ||
|
||
buildInputs = [ makeWrapper ]; |
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.
Can go innativeBuildInputs
.
|
||
# regarding substitutes: looks like this is just a bug / confusion of the directories, and nobod yhas tested this. | ||
# PR at https://github.com/piwik/piwik/pull/11661 | ||
patchPhase = '' |
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.
Consider postPatch
; at least in general its nice to allow applying arbitrary patches via override. Specifying a custom patch phase prevents that.
enable = mkOption { | ||
type = types.bool; | ||
default = false; | ||
example = true; |
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.
Nit: examples for booleans are usually skipped, it's self-evident.
type = types.bool; | ||
default = false; | ||
example = true; | ||
description = '' |
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.
Note that long-form descriptions may not render very well. You can generate the nixos manual to check whether it'll look okay. You can farm out longer documentation fragments to the manual.
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.
You are right, it renders quite bad.
So it would be ok to include a new manual section like II.Configuration > 22. piwik for that longer part? I was struggeling to find a good place for this, but now I see this long description isn't one.
# TODO: Move more unnecessary files from share/, especially using PIWIK_INCLUDE_PATH. | ||
# See https://forum.piwik.org/t/bootstrap-php/5926/10 and | ||
# https://github.com/piwik/piwik/issues/11654#issuecomment-297730843 | ||
installPhase = '' |
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.
Note that this will cause install hooks to be skipped (you can run e..g, the post phase hook manually with runHook postInstall
).
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.
I understand. I added runHook call for preInstall / postInstall as first / last commands of my installPhase, mirroring the default implementation I found in pkgs/stdenv/generic/setup.sh
. From that file I assume there's no better way to overwrite / have a custom installPhase without having to call the hooks by hand, right?
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.
Pretty much. At some point I think it's possible hooks may become implicit, making this a bit more natural.
description = "A real-time web analytics application"; | ||
license = licenses.gpl3Plus; | ||
homepage = https://piwik.org/; | ||
platforms = platforms.all; |
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.
If you wish, you could add yourself to the list of maintainers.
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.
I thought you had to be part of the NixOS github organization to be a maintainer. 😅
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.
Not at all. It basically means you care about the package, lets other's know to ping you if there are questions or whatever.
I can feel the packaging quality is increasing…✨ 😄 |
I don't have much more to add, so let me know when you're ready to integrate. |
@@ -6,7 +6,7 @@ | |||
|
|||
<title>Piwik</title> | |||
<para> | |||
Piwik is a real-time web analytics application. | |||
Piwik is a real-time web analytics web application. |
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.
Might want to revert this line :D
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.
It was actually intentional, as it is a web application for web analytics, but I admit it sounds really weird in english, adds nothing much and probably irritates the reader more than clarifies stuff. 😆 Thanks!
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.
Yeah, I could see that.
6b5fd6d
to
711507a
Compare
@joachifm / @Alphor I've aded a NixOS manual chapter for piwik now, and I think it's good not to try to cram it all into the description. 😄 If you don't have any other suggestions for the manual, I'd be ready to integrate now. The manual also contains a paragraph on this sendmail issue, I'd remove it later if the issue is resolved, but it seems to be nothing trivial: #26611 @Alphor can I get back on your offer to test other stuff? In case you have some kind of |
@florianjacob |
@Alphor yes, an MTA would be enough, it just needs to provide the |
711507a
to
55844c8
Compare
Thank you |
Motivation for this change
Piwik is an open analytics application. Resolves #25266.
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)