-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Update: easyjson, hydron, meguca, nodePackages: meguca; Improve: quicktemplate #43792
Conversation
@GrahamcOfBorg build easyjson hydron meguca quicktemplate |
Success on x86_64-linux (full log) Attempted: easyjson, hydron, meguca, quicktemplate Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: easyjson, hydron, quicktemplate The following builds were skipped because they don't evaluate on aarch64-linux: meguca Partial log (click to expand)
|
Success on x86_64-darwin (full log) Attempted: easyjson, hydron, meguca, quicktemplate Partial log (click to expand)
|
Don't merge yet, please. |
Okay, we're good now. The last meguca commit had a bug in upstream, and I didn't realize until after the push. |
options.services.meguca = { | ||
enable = mkEnableOption "meguca"; | ||
|
||
baseDir = mkOption { | ||
dataDir = mkOption { |
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.
This will break configs of people using the baseDir
option. You'd need to use mkRenamedOptionModule
to hint at a rename.
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.
Like this, right?
imports = [
(mkRenamedOptionModule [ "baseDir" ] [ "dataDir" ])
];
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.
Yup, but you need to use the full paths to the options
type = types.path; | ||
default = "/run/meguca"; | ||
default = "/var/lib/meguca"; |
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.
Changing the default will break everybody's setup that hasn't set the option explicitly.
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 already broken since /run deletes the data each time.
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.
Oh haha, I see, never mind then
|
||
postgresArgs = mkOption { | ||
type = types.str; | ||
default = "user=hydron password=" + cfg.password + " dbname=hydron sslmode=disable"; |
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.
This would rebuild the manual every time one changes the password. Assign a default in the config section with mkDefault
or use defaultText =
to avoid that.
security.sudo.enable = cfg.enable == true; | ||
services.postgresql.enable = cfg.enable == true; | ||
|
||
services.hydron.passwordFile = mkDefault (toString (pkgs.writeTextFile { |
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 can use the shorter pkgs.writeText "hydron-password-file" cfg.password
. Also toString
shouldn't be needed.
@@ -47,16 +77,40 @@ in with lib; { | |||
}; | |||
|
|||
config = mkIf cfg.enable { | |||
security.sudo.enable = cfg.enable == true; | |||
services.postgresql.enable = cfg.enable == 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.
Use just services.postgresql.enable = cfg.enable
mkdir -p ${escapeShellArg cfg.dataDir}/{.hydron,images} | ||
cp ${pkgs.hydron}/share/hydron/db_conf.json ${escapeShellArg cfg.dataDir}/.hydron | ||
sed -i "s/user=hydron password=hydron dbname=hydron sslmode=disable/$(cat ${escapeShellArg cfg.postgresArgsFile})/g" \ | ||
${escapeShellArg cfg.dataDir}/.hydron/db_conf.json |
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.
Since this db_conf.json
file gets copied every time, I think it's better to build the file with Nix instead and have it be a symlink to the Nix-built version. Then the user won't think of modifying it. Something like
ln -s ${pkgs.runCommand "db_conf.json" {} "cp && sed"} ${cfg.dataDir}/.hydron/db_conf.json
@infinisil How does this look? |
{ | ||
"driver": "postgres", | ||
"connection": "user=hydron password='' + cfg.password + " " + ''dbname=hydron sslmode=disable" | ||
'' + "}"; |
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 manual will prefer defaultText
over default
, so using the same for both doesn't do anything. You'll want to use something like password=\${cfg.password}
to not have Nix actually insert the password. Or use password=${options.services.hydron.password.default}
. But on second thought, it might be better to not set the default here, but instead use mkDefault
in the config section, such that nothing is duplicated, up to you.
And what's up with the weird quotes? I'd prefer to only use one type everywhere, you can use string interpolation foo=${foo}
as well.
Also why is this a json string now?
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.
db_conf.json is a json string, so I'd rather just put the string directly, and we avoid a lot of cruft this way.
The weird quotes are just to make it look pretty on-disk, since for some reason the last }
keeps it's tabbing and doesn't strip white space.
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.
Also, for some reason, the quote after cfg.password does strip whitespace, so you end up getting password=whateverdbname=
, without that extra quote, anyway.
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.
Looks like string interpolation fixed my problem with the last }
being tabbed.
@@ -30,6 +30,7 @@ in with lib; { | |||
password = mkOption { | |||
type = types.str; | |||
default = "hydron"; | |||
defaultText = "hydron"; |
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 needed, will use default
as text by default.
Same thing with meguca |
security.sudo.enable = cfg.enable; | ||
services.postgresql.enable = cfg.enable; | ||
services.hydron.passwordFile = mkDefault (pkgs.writeText "hydron-password-file" cfg.password); | ||
services.hydron.password = mkDefault ("hydron"); |
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.
No need to set the default here, put it into the option directly. The mkDefault thing is only needed when the default depends on another option value.
"driver": "postgres", | ||
"connection": "user=hydron password=${cfg.password} dbname=hydron sslmode=disable" | ||
} | ||
''); |
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.
Unnecessary parens
@infinisil hai dozo |
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.
LGTM, arigatou gozaimasu!
Motivation for this change
Update 4 packages, make 1 better conform to standards.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)