-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Wordpress improvements #96910
Closed
Closed
Wordpress improvements #96910
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8ce3255
wordpress: Add update script
mohe2015 5ef625b
wordpress-core: init at 5.7.2
mohe2015 97ed2d3
nixos/mysql: Fix for databases with special characters
mohe2015 28afe07
nixos/wordpress: Use separate database for each wordpress instance
mohe2015 512f643
nixos/wordpress: Add option to allow mutable wp-content directory
mohe2015 0e3ae1c
nixos/wordpress: Mention a theme and plugin packaging tool in the docs.
mohe2015 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,8 +26,16 @@ let | |||||
|
||||||
# symlink the wordpress config | ||||||
ln -s ${wpConfig hostName cfg} $out/share/wordpress/wp-config.php | ||||||
|
||||||
${optionalString (!cfg.mutableWpContent) '' | ||||||
# symlink uploads directory | ||||||
ln -s ${cfg.uploadsDir} $out/share/wordpress/wp-content/uploads | ||||||
''} | ||||||
|
||||||
${optionalString cfg.mutableWpContent '' | ||||||
rm -Rf $out/share/wordpress/wp-content | ||||||
ln -s ${stateDir hostName} $out/share/wordpress/wp-content | ||||||
''} | ||||||
|
||||||
# https://github.com/NixOS/nixpkgs/pull/53399 | ||||||
# | ||||||
|
@@ -36,9 +44,11 @@ let | |||||
# requests that look like: https://example.com/wp-content//nix/store/...plugin/path/some-file.js | ||||||
# Since hard linking directories is not allowed, copying is the next best thing. | ||||||
|
||||||
${optionalString (!cfg.mutableWpContent) '' | ||||||
# copy additional plugin(s) and theme(s) | ||||||
${concatMapStringsSep "\n" (theme: "cp -r ${theme} $out/share/wordpress/wp-content/themes/${theme.name}") cfg.themes} | ||||||
${concatMapStringsSep "\n" (plugin: "cp -r ${plugin} $out/share/wordpress/wp-content/plugins/${plugin.name}") cfg.plugins} | ||||||
''} | ||||||
''; | ||||||
}; | ||||||
|
||||||
|
@@ -53,9 +63,15 @@ let | |||||
|
||||||
require_once('${stateDir hostName}/secret-keys.php'); | ||||||
|
||||||
${optionalString (!cfg.mutableWpContent) '' | ||||||
# wordpress is installed onto a read-only file system | ||||||
define('DISALLOW_FILE_EDIT', true); | ||||||
define('AUTOMATIC_UPDATER_DISABLED', true); | ||||||
''} | ||||||
|
||||||
${optionalString cfg.mutableWpContent '' | ||||||
define('FS_METHOD','direct'); | ||||||
''} | ||||||
|
||||||
${cfg.extraConfig} | ||||||
|
||||||
|
@@ -87,7 +103,8 @@ let | |||||
package = mkOption { | ||||||
type = types.package; | ||||||
default = pkgs.wordpress; | ||||||
description = "Which WordPress package to use."; | ||||||
example = literalExample "pkgs.wordpress-core"; | ||||||
description = "Which WordPress package to use. Use pkgs.wordpress-core for a version without the default plugins and theme."; | ||||||
}; | ||||||
|
||||||
uploadsDir = mkOption { | ||||||
|
@@ -99,12 +116,18 @@ let | |||||
''; | ||||||
}; | ||||||
|
||||||
mutableWpContent = mkOption { | ||||||
type = types.bool; | ||||||
default = false; | ||||||
description = "Allow any modification in the wp-content directory. This usually means adding, removing and updating plugins and themes in the web interface. This is helpful for testing which themes and plugins to use. It should only be used on a test server as migrating between mutable and readonly is not easily possible."; | ||||||
}; | ||||||
|
||||||
plugins = mkOption { | ||||||
type = types.listOf types.path; | ||||||
default = []; | ||||||
description = '' | ||||||
List of path(s) to respective plugin(s) which are copied from the 'plugins' directory. | ||||||
<note><para>These plugins need to be packaged before use, see example.</para></note> | ||||||
<note><para>These plugins need to be packaged before use, see example. Using something like https://git.helsinki.tools/helsinki-systems/wp4nix may be a better option.</para></note> | ||||||
''; | ||||||
example = '' | ||||||
# Wordpress plugin 'embed-pdf-viewer' installation example | ||||||
|
@@ -131,7 +154,7 @@ let | |||||
default = []; | ||||||
description = '' | ||||||
List of path(s) to respective theme(s) which are copied from the 'theme' directory. | ||||||
<note><para>These themes need to be packaged before use, see example.</para></note> | ||||||
<note><para>These themes need to be packaged before use, see example. Using something like https://git.helsinki.tools/helsinki-systems/wp4nix may be a better option.</para></note> | ||||||
''; | ||||||
example = '' | ||||||
# Let's package the responsive theme | ||||||
|
@@ -168,7 +191,7 @@ let | |||||
|
||||||
name = mkOption { | ||||||
type = types.str; | ||||||
default = "wordpress"; | ||||||
default = if lib.versionAtLeast config.system.stateVersion "21.11" then "wordpress-${name}" else "wordpress"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I should change this to
Suggested change
|
||||||
description = "Database name."; | ||||||
}; | ||||||
|
||||||
|
@@ -314,7 +337,7 @@ in | |||||
ensureDatabases = mapAttrsToList (hostName: cfg: cfg.database.name) eachSite; | ||||||
ensureUsers = mapAttrsToList (hostName: cfg: | ||||||
{ name = cfg.database.user; | ||||||
ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; }; | ||||||
ensurePermissions = { "`${cfg.database.name}`.*" = "ALL PRIVILEGES"; }; | ||||||
} | ||||||
) eachSite; | ||||||
}; | ||||||
|
@@ -375,7 +398,15 @@ in | |||||
"d '${stateDir hostName}' 0750 ${user} ${webserver.group} - -" | ||||||
"d '${cfg.uploadsDir}' 0750 ${user} ${webserver.group} - -" | ||||||
"Z '${cfg.uploadsDir}' 0750 ${user} ${webserver.group} - -" | ||||||
]) eachSite); | ||||||
] | ||||||
++ | ||||||
(if cfg.mutableWpContent then [ | ||||||
"d '${stateDir hostName}/themes' 0750 ${user} ${webserver.group} - -" | ||||||
"Z '${stateDir hostName}/themes' 0750 ${user} ${webserver.group} - -" | ||||||
"d '${stateDir hostName}/plugins' 0750 ${user} ${webserver.group} - -" | ||||||
"Z '${stateDir hostName}/plugins' 0750 ${user} ${webserver.group} - -" | ||||||
] else []) | ||||||
) eachSite); | ||||||
|
||||||
systemd.services = mkMerge [ | ||||||
(mapAttrs' (hostName: cfg: ( | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env nix-shell | ||
#!nix-shell -i bash -p common-updater-scripts jq | ||
|
||
set -eu -o pipefail | ||
|
||
version=$(curl --globoff "https://api.wordpress.org/core/version-check/1.7/" | jq -r '.offers[0].version') | ||
update-source-version wordpress $version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ wordpress }: | ||
|
||
wordpress.overrideAttrs (oldAttrs: { | ||
pname = "wordpress-core"; | ||
|
||
installPhase = oldAttrs.installPhase + '' | ||
rm -r $out/share/wordpress/wp-content/plugins/* | ||
rm -r $out/share/wordpress/wp-content/themes/* | ||
''; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I checked (code-wise) that this shouldn't break anything but somebody else should probably also check that. Also I would run some other modules that use this before merging.