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

Update: easyjson, hydron, meguca, nodePackages: meguca; Improve: quicktemplate #43792

Merged
merged 7 commits into from Aug 3, 2018

Conversation

Chiiruno
Copy link
Contributor

@Chiiruno Chiiruno commented Jul 19, 2018

Motivation for this change

Update 4 packages, make 1 better conform to standards.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@Chiiruno
Copy link
Contributor Author

cc @Mic92 @matthewbauer

@matthewbauer
Copy link
Member

@GrahamcOfBorg build easyjson hydron meguca quicktemplate

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: easyjson, hydron, meguca, quicktemplate

Partial log (click to expand)

shrinking /nix/store/jyi941xb9cpkyil61fddairlg53zvfh8-meguca-unstable-2018-07-25-bin/bin/meguca
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/jyi941xb9cpkyil61fddairlg53zvfh8-meguca-unstable-2018-07-25-bin/bin
patching script interpreter paths in /nix/store/jyi941xb9cpkyil61fddairlg53zvfh8-meguca-unstable-2018-07-25-bin
checking for references to /build in /nix/store/jyi941xb9cpkyil61fddairlg53zvfh8-meguca-unstable-2018-07-25-bin...
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip
/nix/store/03djwdrdcydqvh6rqjh2iymv0p5dpiri-easyjson-unstable-2018-07-24-bin
/nix/store/lzjfcm3zs6yqj3p6hrlrbbl6ddkalnwz-hydron-unstable-2018-07-25-bin
/nix/store/jyi941xb9cpkyil61fddairlg53zvfh8-meguca-unstable-2018-07-25-bin
/nix/store/z4srjg7rhxz9wrh5bhqjq75dv7wkj9wl-quicktemplate-unstable-2018-04-30-bin

@GrahamcOfBorg
Copy link

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)

shrinking RPATHs of ELF executables and libraries in /nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin
shrinking /nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin/bin/hydron
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin/bin
patching script interpreter paths in /nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin
checking for references to /build in /nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin...
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
/nix/store/mirjvcikrwm3d9f06yrwk75vyhs97ma4-easyjson-unstable-2018-07-24-bin
/nix/store/gilf9ghi57mqpsfr5vb3km4fs8583876-hydron-unstable-2018-07-25-bin
/nix/store/5f08bdwf2bnzw6w38hzsk45p9fllam11-quicktemplate-unstable-2018-04-30-bin

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: easyjson, hydron, meguca, quicktemplate

Partial log (click to expand)

find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
find: '/nix/store/a5cg07vadhhha113rwcxdfr4wm7mih3n-meguca-unstable-2018-07-25': No such file or directory
/nix/store/0n93mhik0irzvr6alw2jbi5f70zvimxi-easyjson-unstable-2018-07-24-bin
/nix/store/kja6zg9yh8hvywd90ggmcl3k8313fpaf-hydron-unstable-2018-07-25-bin
/nix/store/k4qfr7i255cj8qwgbg3jnbr94cfm2c2a-meguca-unstable-2018-07-25-bin
/nix/store/1nrdgv06hii9a7k534df1qq326arqpyn-quicktemplate-unstable-2018-04-30-bin

@Chiiruno
Copy link
Contributor Author

Chiiruno commented Aug 1, 2018

Don't merge yet, please.

@Chiiruno
Copy link
Contributor Author

Chiiruno commented Aug 2, 2018

Okay, we're good now. The last meguca commit had a bug in upstream, and I didn't realize until after the push.
CC @matthewbauer

options.services.meguca = {
enable = mkEnableOption "meguca";

baseDir = mkOption {
dataDir = mkOption {
Copy link
Member

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.

Copy link
Contributor Author

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" ])
  ];

Copy link
Member

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";
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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";
Copy link
Member

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 {
Copy link
Member

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;
Copy link
Member

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
Copy link
Member

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

@Chiiruno
Copy link
Contributor Author

Chiiruno commented Aug 3, 2018

@infinisil How does this look?

{
"driver": "postgres",
"connection": "user=hydron password='' + cfg.password + " " + ''dbname=hydron sslmode=disable"
'' + "}";
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@Chiiruno Chiiruno Aug 3, 2018

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.

Copy link
Contributor Author

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";
Copy link
Member

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.

@infinisil
Copy link
Member

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");
Copy link
Member

@infinisil infinisil Aug 3, 2018

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"
}
'');
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary parens

@Chiiruno
Copy link
Contributor Author

Chiiruno commented Aug 3, 2018

@infinisil hai dozo

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

LGTM, arigatou gozaimasu!

@infinisil infinisil merged commit a35a488 into NixOS:master Aug 3, 2018
@Chiiruno Chiiruno deleted the dev/hydron branch August 3, 2018 16:10
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

5 participants