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/imaginary: init #215222

Merged
merged 2 commits into from
Feb 12, 2023
Merged

nixos/imaginary: init #215222

merged 2 commits into from
Feb 12, 2023

Conversation

dotlambda
Copy link
Member

@dotlambda dotlambda commented Feb 8, 2023

Tested using

services.nextcloud.config = {
  enabledPreviewProviders = [
    ''OC\Preview\Imaginary''
  ];
  preview_imaginary_url = "http://localhost:8088/";
};
services.imaginary = {
  enable = true;
  settings = {
    a = "localhost";
    p = 8088;
    return-size = true;
  };
};
Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 8, 2023
@dotlambda dotlambda force-pushed the nixos-imaginary-init branch 2 times, most recently from 7588230 to 468d34f Compare February 8, 2023 01:27
Copy link
Contributor

@urandom2 urandom2 left a comment

Choose a reason for hiding this comment

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

I am pleased with the derivation changes; still new to nixos modules, but nothing stands out as egregious

pkgs/servers/imaginary/default.nix Show resolved Hide resolved
pkgs/servers/imaginary/default.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot requested a review from urandom2 February 8, 2023 01:53
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 labels Feb 8, 2023
]);

options = {
a = mkOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

are these option names that good? we'd much prefer giving the descriptive names and amending the description with something like Corresponds to the `-a` parameter.. this wouldn't stop anyone using the original names, but it'd make module instances more readable.

(note: we're only taking issue with a and p, but return-size is totally good as is)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also not super happy with it but I think this would be against the spirit of NixOS/rfcs#42.
However we could file a PR upstream that introduces e.g. -address as an alias for -a.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could just add these options outside of settings.

Copy link
Contributor

Choose a reason for hiding this comment

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

both sound reasonable, but adding them outside of settings is probably better. that more clearly communicates that there could be special handling going on.

nixos/modules/services/networking/imaginary.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/imaginary.nix Outdated Show resolved Hide resolved
@dotlambda dotlambda force-pushed the nixos-imaginary-init branch from 468d34f to bd062c7 Compare February 8, 2023 04:46
@dotlambda
Copy link
Member Author

I can't get ports < 1024 to work:

listen: listen tcp 10.0.0.23:99: bind: permission denied

Does someone have an idea?

@pennae
Copy link
Contributor

pennae commented Feb 8, 2023

I can't get ports < 1024 to work:

listen: listen tcp 10.0.0.23:99: bind: permission denied

Does someone have an idea?

PrivateUsers= causes the unit to be executed with no capabilities in the hosting namespace, so your capability sets do nothing. should work if you drop it.

@dotlambda dotlambda force-pushed the nixos-imaginary-init branch from bd062c7 to a8b4e7d Compare February 8, 2023 06:10
@dotlambda dotlambda marked this pull request as ready for review February 8, 2023 06:10
@dotlambda
Copy link
Member Author

I added TemporaryFileSystem and BindReadOnlyPaths.

@urandom2 urandom2 added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package label Feb 8, 2023
Copy link
Contributor

@pennae pennae left a comment

Choose a reason for hiding this comment

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

haven't tested the module, but it looks good.

@dotlambda dotlambda force-pushed the nixos-imaginary-init branch 2 times, most recently from 9e2235d to fbd5bec Compare February 10, 2023 02:47
@github-actions github-actions bot added 8.has: changelog 8.has: documentation This PR adds or changes documentation labels Feb 10, 2023
@dotlambda dotlambda force-pushed the nixos-imaginary-init branch from fbd5bec to efee1b5 Compare February 11, 2023 17:18
@dotlambda dotlambda merged commit 7b60fce into NixOS:master Feb 12, 2023
@dotlambda dotlambda deleted the nixos-imaginary-init branch February 12, 2023 16:42

address = mkOption {
type = types.str;
default = "";
Copy link
Member

Choose a reason for hiding this comment

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

Does emptry string equal to localhost? If I understand the nextcloud doc correct it sounds like you want to run imaginary always bound on localhost.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it does mean that according to https://pkg.go.dev/net#Dial. I went with upstream's default: https://github.com/h2non/imaginary/blob/master/imaginary.go#L20

Copy link
Member Author

Choose a reason for hiding this comment

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

Never mind, it means any address. That's also what it says in https://github.com/h2non/imaginary#command-line-usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it should be changed to localhost by default. See #100192. But the problem is that localhost means 127.0.0.1 and doesn't include ::1.

Copy link
Member

Choose a reason for hiding this comment

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

Can we use [::1]?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, gotta love it. golang/go#9334

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we set address = "localhost" by default anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

if it's primarily not meant to be accessed from other hosts, probably? don't know enough about the service to be sure. but then again, if it makes for such interesting complications it might just be better to rely on the firewall existing and a note that by default all addresses are bound? 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

For the nextcloud use case it is only accessed through localhost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants