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

flarum, nixos/flarum: init at 0.1.0-beta.13 #96869

Closed
wants to merge 1 commit into from
Closed

Conversation

astro
Copy link
Contributor

@astro astro commented Aug 31, 2020

Motivation for this change

Adds Flarum discussion platform web application. Includes NixOS module.

The dependencies subpackage is output from composer2nix.

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

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

A couple discussion points on the module. I haven't reviewed the package.

nixos/modules/services/web-apps/flarum.nix Outdated Show resolved Hide resolved
description = "Domain to serve on.";
};

installPath = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

What is this needed for? It looks like the software is packaged so you don't need to install (already in /nix/store).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the software needs to reside in a writable file system location.

Copy link
Member

Choose a reason for hiding this comment

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

All of the software, or just the storage/ folder and config.php?

Copy link
Member

Choose a reason for hiding this comment

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

After reviewing upstream documentation and code I think you can patch this to work with the nix store. Comments in source code even mention this. See here and here.

nixos/modules/services/web-apps/flarum.nix Show resolved Hide resolved
nixos/modules/services/web-apps/flarum.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/flarum.nix Show resolved Hide resolved
serviceConfig = {
Type = "oneshot";
};
script = with cfg; ''
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth replacing this with systemd.tmpfiles.rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The installPath will contain state: config.php, storage/. The software checks for writeability of these paths.

Copy link
Contributor

Choose a reason for hiding this comment

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

@astro can this be resolved after doing #96869 (comment) ?

@astro
Copy link
Contributor Author

astro commented Nov 29, 2020

This PR has been improved to run the installer fully automatic. Rebased.

@aanderse
Copy link
Member

@astro if you're still interested in working in this and need and help just ping.

@sbourdeauducq
Copy link
Contributor

@astro what is the status of this?

@astro
Copy link
Contributor Author

astro commented Mar 16, 2021

@aanderse Ping. I could definitively use a hand with leaving more files in the nix store.

@aanderse
Copy link
Member

@astro - see https://github.com/aanderse/nixpkgs/blob/48c8f0302af71c4db7f271bfe51bb157ed4b2831/nixos/modules/services/web-apps/flarum.nix for my take on the module.

A few notes:

  • unfortunately a few immutable files need to remain in mutable paths1, via symlink: ${cfg.stateDir}/public/index.php, ${cfg.stateDir}/public/.htaccess (though not really, this is a httpd specific file), ${cfg.stateDir}/flarum, and ${cfg.stateDir}/site.php
  • i removed "misleading" options - options which have no impact after the initial install of the application - replacing them with a single installConfig option (which could use a more descriptive name possibly) because if a sysadmin ever changed the value of database, forumTitle, or baseUrl they might get confused why there was no change (and in the case of database why their web application suddenly doesn't work)
  • i used systemd.tmpfiles.rules to provision directories and symlink required files into place which has a few benefits over the way it was
  • i don't do nginx and the config you had didn't immediately work with the changes i had so i switched to httpd to make it easier on me (you should switch back to nginx asap)
  • i added a flarum command to the systemPackages which wraps the flarum commend so a sysadmin can type flarum migrate or flarum cache:clear after packages updates
  • maybe some more...?

There is definitely some room for improvement:

  • maybe we want to consider running migrations automatically, maybe we don't... if we do then a separate flarum-update.service would be a good idea
  • it would be nice if we could add more options to database that actually did something if the sysadmin ever changed them - i have some ideas on how to achieve this, but maybe that is for a future PR
  • the installConfig option should probably be renamed and it requires a better description
    • it is "nice" in that it the default value will get you an instance of flarum up and running quickly, but it also hardcodes the default admin password to a known value in the nix store so a big warning of "change the password immediately" is important (maybe even important enough to add to the .enable description... "Whether to enable the Flarum discussion platform and configure a default admin account with username 'admin' and password 'blah' which you should immediately change", etc...)

Questions? Comments? Love it? Hate it? Let me know. I hope this has helped.

  1. well not really "need to"... but it wouldn't be worth the hassle, they're small files anyways 🤷‍♂️

@aanderse
Copy link
Member

ping @astro

@astro
Copy link
Contributor Author

astro commented May 19, 2021

Awesome! Finally someone who is savvy with all that PHP stuff. :-)

Do you mind proposing your own PR, take all the credits, and we close this one?

Cc: @sbourdeauducq

@aanderse
Copy link
Member

Well... I'm not familiar with this software, I don't have any interest in running this software, and I don't want to maintain this module in NixOS... I was just trying to help out 🤷‍♂️

@stale
Copy link

stale bot commented Nov 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 16, 2021
@astro astro closed this Jul 11, 2022
albertchae added a commit to ngi-nix/ngipkgs that referenced this pull request Jul 25, 2023
copy installPhase build script from closed PR NixOS/nixpkgs#96869

fix typo
@albertchae albertchae mentioned this pull request Jul 25, 2023
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

4 participants