Difference between revisions of "Drupal"

From NixOS Wiki
Jump to: navigation, search
m (Removed bad link)
m (Fix typo)
Line 51: Line 51:
 
users.users.<user>.extraGroups = ["caddy"];  
 
users.users.<user>.extraGroups = ["caddy"];  
 
</syntaxHighlight>
 
</syntaxHighlight>
 +
 +
Alternatively, you can log in as root and edit any file in the state directory you like.
  
 
=== Installing Modules & Themes Using The State Directory ===
 
=== Installing Modules & Themes Using The State Directory ===
Line 57: Line 59:
  
 
Modules can be copied into <code>/var/lib/drupal/<hostname>/modules</code> and themes can be copied into <code>/var/lib/drupal/<hostname>/themes</code>.
 
Modules can be copied into <code>/var/lib/drupal/<hostname>/modules</code> and themes can be copied into <code>/var/lib/drupal/<hostname>/themes</code>.
 
Alternatively, you can log in as root and edit any file in the state directory you like.
 
  
 
== Using Caddy ==
 
== Using Caddy ==

Revision as of 15:02, 23 June 2025

Drupal is a self-hosted content management system web application. Its focus is on scalability, customization, and accessibility. Many large-scale institutions including those in government, higher-ed, and the non-profit sector use Drupal for running their website, but Drupal can also be used for running a humble blog, homepage, or turnkey web app.

Installation

A simple local set of Drupal can be enabled with the following configuration:

services.drupal.enable = true;

This will spin up a Drupal installation at http://localhost using nginx and MYSQL.

This configuration is functionally identical to writing:

services.drupal = {
  enable = true;
  sites = {
    "localhost" = {
      enable = true;
    };
  };
};

Configuration

It is possible to configure a number of different site settings using the settings.php file that comes installed with every Drupal instance.

The settings.php file is located at /var/lib/drupal/<hostname>/sites/default/settings.php for each website you install. So if your website is installed at http://localhost, the path to the settings would be /var/lib/drupal/localhost/sites/default/settings.php

See the official documentation for more information on how to use settings.php.

State Directory

Every website you run in NixOS will install a state directory at /var/lib/drupal/<hostname>. This directory contains a simple file tree with some Drupal files you can edit.

Note: at the time of writing this, not every file in this directory will be symlinked to the Drupal package in /nix/store.

In order to edit anything in the state directory, your user must be a part of the webserver group.

If you want to use nginx, you would add:

users.users.<user>.extraGroups = ["nginx"];

If you want to use caddy, you would add:

users.users.<user>.extraGroups = ["caddy"];

Alternatively, you can log in as root and edit any file in the state directory you like.

Installing Modules & Themes Using The State Directory

You can copy/paste modules and themes directly from drupal.org into the state directory and Drupal will detect them.

Modules can be copied into /var/lib/drupal/<hostname>/modules and themes can be copied into /var/lib/drupal/<hostname>/themes.

Using Caddy

The Drupal service uses the nginx webserver by default, but you can switch to the Caddy webserver by writing:

services.drupal.webserver = "caddy";

Note: there is currently no API for changing the webserver on individual projects. The webserver you pick will be used for every instance of Drupal you run on NixOS.