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/moinmoin: init module #68327

Merged
merged 1 commit into from Nov 3, 2019
Merged

nixos/moinmoin: init module #68327

merged 1 commit into from Nov 3, 2019

Conversation

mmilata
Copy link
Member

@mmilata mmilata commented Sep 8, 2019

Motivation for this change

Migrating my wiki instance from CentOS->NixOS.

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 nix-review --run "nix-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @abbradar @danieldk

Copy link
Contributor

@danieldk danieldk left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this! I do not use MoinMoin in farm mode (I have a separate vassal for each site), so I can only provide limited feedback.

nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/tests/all-tests.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
@mmilata
Copy link
Member Author

mmilata commented Sep 9, 2019

Thanks for the quick feedback guys!

Regarding the farmconfig, I currently only run single wiki instance so I don't need it, though easy way of running multiple instances seemed like a nice thing to have. I see several possibilities here:

  • switching to vassal-per-instance if @danieldk wants to use or even help maintain this module
  • switching to private uWSGI instance, or some other application server, to take advantage of systemd sandboxing
  • forcing single instance, as that's what most users want and it's still quite easy to run multiple instances using NixOS containers

What do you think?

Changes:

  • fix all-tests.nix
  • wrapped services.uwsgi.plugins in mkDefault, removed setting services.uwsgi.moin.instance.vassals.moin.pythonpath as it had no effect

@mmilata
Copy link
Member Author

mmilata commented Sep 24, 2019

I've updated the module to use gunicorn instead of uWSGI as an application server. Personally, gunicorn seems easier to use than uWSGI, and it is possible to use systemd sandboxing options. Haven't enabled DynamicUser because I don't know how to make it work with the command line moin utility.

Changes:

  • farmconfig setup is no longer used, multiple wikis are implemented through multiple gunicorn systemd units
  • default forceSSL=true and enableACME=true for nginx vhosts
  • generated wrapper script no longer shadows the shipped moin script

@danieldk @aanderse PTAL

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/62

@mmahut
Copy link
Member

mmahut commented Oct 17, 2019

@GrahamcOfBorg test moin

nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
"d /run/moin 0750 ${user} ${group} - -"
"d ${dataDir} 0550 ${user} ${group} - -"
]
++ (concatLists (flip mapAttrsToList cfg.wikis (wikiIdent: wiki: [
Copy link
Member

Choose a reason for hiding this comment

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

Is there any concept of 'migrations' in moinmoin which might have some problems introduced during version upgrades here (particularly the C entries in your tmpfiles)? While I do like the declarative nature of tmpfiles I have concerns that tmpfiles may not be flexible enough if upgrading between versions of moinmoin requires special handling.

I'm not familiar with moinmoin as a sysadmin, so if my question is of no concern please disregard.

Copy link
Member Author

Choose a reason for hiding this comment

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

The data dir is supposed to be migrated to newer version using
moin --config-dir=/path/to/config_dir --wiki-url=wiki.example.org/ migration data.
Not sure whether we should do this automatically, however the C should be fine here for manual migrations.

Regarding the underlay dir the docs suggest to replace it with the one from the newer version. We can make preStart always replace it at the cost of slower startup. Symlinking doesn't work unfortunately.

References:

indentLines = n: str: concatMapStrings (line: "${fixedWidthString n " " " "}${line}\n") (splitString "\n" str);

moinCliWrapper = wikiIdent: pkgs.writeShellScriptBin "moin-${wikiIdent}" ''
${pkgs.su}/bin/su -s ${pkgs.runtimeShell} -c "${pkg}/bin/moin --config-dir=/var/lib/moin/${wikiIdent}/config $*" ${user}
Copy link
Member

Choose a reason for hiding this comment

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

If you didn't use su but instead just ran the command then nixos sysadmins could have better control over the access to this script with sudo rules. The sysadmin can always type sudo -u moin-ExampleWiki to be explicit.

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 wanted to make setting up simple instance as easy as possible, not sure whether a script that just adds single argument to the moin cli helps with that. For maximum flexibility the moin cli is added to systemPackages as well.

Or did you mean to use sudo with some default rules instead?

Copy link
Member

Choose a reason for hiding this comment

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

Personally I don't like the approach taken here (a script using su) and my preference would certainly be to document setting up access via sudo rules. I want to be clear on this point what I state is only my opinion, and not a hard requirement preventing this PR from being merged. You may take either approach.

nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/moin.nix Outdated Show resolved Hide resolved
Copy link
Member Author

@mmilata mmilata left a comment

Choose a reason for hiding this comment

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

Changes:

  • removed redundant default attributes
  • flip map -> forEach
  • renamed module to moinmoin
  • moved underlay initialization from tmpfiles to preStart
  • added note about creating user accounts

PTAL @aanderse

@mmilata mmilata changed the title nixos/moin: init module nixos/moinmoin: init module Oct 25, 2019
@mmahut
Copy link
Member

mmahut commented Oct 26, 2019

@GrahamcOfBorg test moin

@mmilata
Copy link
Member Author

mmilata commented Oct 26, 2019

@GrahamcOfBorg test moinmoin

Renamed the test as well:)

@mmahut
Copy link
Member

mmahut commented Oct 26, 2019

@GrahamcOfBorg test moinmoin

@mmahut
Copy link
Member

mmahut commented Nov 1, 2019

This looks good to me, @aanderse a final word?

@aanderse
Copy link
Member

aanderse commented Nov 1, 2019

This looks good to me, @aanderse a final word?

@mmahut looks like a few things need to be fixed up maybe (bot is failing) but I have no major show stoppers on the quality of the code, only opinions that @mmilata is free to follow or disregard. Overall looks good 👍

@mmahut
Copy link
Member

mmahut commented Nov 1, 2019

tests.moin failed as I run the wrong test name, kicking the test on aarch64 where we run out of space.

@GrahamcOfBorg test moinmoin

@mmahut mmahut merged commit 794c919 into NixOS:master Nov 3, 2019
@mmilata
Copy link
Member Author

mmilata commented Nov 5, 2019

Thx for the review everyone!

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

6 participants