nixos/drupal: synchronize config sync yamls from src into drupal state dir (#508427)
This commit is contained in:
@@ -330,4 +330,4 @@ gnuradioMinimal.override {
|
||||
|
||||
- The builder `php.buildComposerProject2` for PHP applications has been improved for better reliability and stability.
|
||||
|
||||
- The `services.drupal` module has a few improvements aimed at making it better for installing custom Drupal instances, namely a `webRoot` option and a some new settings for managing variable content and filepaths.
|
||||
- The `services.drupal` module has a few improvements aimed at making it better for installing custom Drupal instances, namely a new `webRoot` option for identifying custom webroots in source code, a new `configRoot` option for identifying and synchronizing config yamls onto NixOS, and a some new settings for managing variable content and filepaths.
|
||||
|
||||
@@ -23,10 +23,12 @@ let
|
||||
mkPackageOption
|
||||
nameValuePair
|
||||
optionalAttrs
|
||||
optionalString
|
||||
types
|
||||
;
|
||||
inherit (lib.strings)
|
||||
removePrefix
|
||||
removeSuffix
|
||||
;
|
||||
inherit (pkgs)
|
||||
mariadb
|
||||
@@ -51,7 +53,13 @@ let
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
rsync -aq * $out/ --exclude=${removePrefix "/" cfg.webRoot}/sites --exclude=sites
|
||||
EXCLUDES="--exclude=${removePrefix "/" cfg.webRoot}/sites --exclude=sites"
|
||||
|
||||
if [ ! -z "${cfg.configRoot}" ]; then
|
||||
EXCLUDES="$EXCLUDES --exclude=${removePrefix "/" cfg.configRoot}"
|
||||
fi
|
||||
|
||||
rsync -aq * $out/ $EXCLUDES
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
@@ -81,6 +89,26 @@ let
|
||||
'';
|
||||
});
|
||||
|
||||
configSync =
|
||||
hostName: cfg:
|
||||
optionalString (cfg.configRoot != "") (
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "drupal-config-${hostName}";
|
||||
name = "drupal-config-${hostName}";
|
||||
src = cfg.package;
|
||||
buildInputs = with pkgs; [ rsync ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/config
|
||||
rsync -a ./share/php/${cfg.package.pname}${cfg.configRoot}/* $out/config/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
);
|
||||
|
||||
drupalSettings =
|
||||
hostName: cfg:
|
||||
pkgs.writeTextFile {
|
||||
@@ -136,7 +164,10 @@ let
|
||||
hostName: cfg:
|
||||
pkgs.writeShellApplication {
|
||||
name = "drupal-state-init-${hostName}";
|
||||
excludeShellChecks = [ "SC2194" ];
|
||||
excludeShellChecks = [
|
||||
"SC2194"
|
||||
"SC2157"
|
||||
];
|
||||
runtimeInputs = with pkgs; [ rsync ];
|
||||
text = ''
|
||||
echo "Updating the sites directory for ${hostName}..."
|
||||
@@ -144,6 +175,12 @@ let
|
||||
--exclude "*/files" \
|
||||
--delete-before
|
||||
|
||||
if [ ! -z "${cfg.configRoot}" ]; then
|
||||
echo "Updating config sync directory for ${hostName}..."
|
||||
rsync -auq "${configSync hostName cfg}/config/" "${removeSuffix "/sync" cfg.configSyncDir}" \
|
||||
--delete-before
|
||||
fi
|
||||
|
||||
if [ ! -d "${cfg.filesDir}" ]; then
|
||||
echo "Preparing files directory..."
|
||||
mkdir -p "${cfg.filesDir}"
|
||||
@@ -221,6 +258,10 @@ let
|
||||
The location of the user-managed Drupal config sync directory.
|
||||
Drupal will both read from and write to this directory when executing
|
||||
configuration management operations.
|
||||
|
||||
This option differs from the `configRoot` option,
|
||||
which this service uses to discover
|
||||
the location of the config sync directory in the package's source code.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -229,12 +270,32 @@ let
|
||||
default = "";
|
||||
description = ''
|
||||
An optional path string with a leading slash
|
||||
indicating the location of the Drupal webroot relative to the
|
||||
project root directory, if one exists.
|
||||
indicating the location of the Drupal webroot
|
||||
in your package's source code.
|
||||
|
||||
The path relative to the project root directory.
|
||||
'';
|
||||
example = "/web";
|
||||
};
|
||||
|
||||
configRoot = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
An optional path string with a leading slash
|
||||
indicating the location of the config sync directory on
|
||||
the Drupal package. Your package will probably have a config sync
|
||||
directory if it has been significantly customized.
|
||||
|
||||
The path must be relative to the project root directory.
|
||||
|
||||
This option differs from the `configSyncDir` option, which
|
||||
tells this service where to create a user-writeable config directory
|
||||
on NixOS.
|
||||
'';
|
||||
example = "/config";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
||||
Reference in New Issue
Block a user