use autogenerated theme
This commit is contained in:
parent
4a4762ac11
commit
c4ffe02cf7
9 changed files with 933 additions and 865 deletions
File diff suppressed because it is too large
Load diff
|
@ -98,4 +98,6 @@ desktop: {pkgs, ...}: {
|
|||
};
|
||||
home.stateVersion = "22.05";
|
||||
manual.manpages.enable = false; # broken
|
||||
|
||||
_module.args.bg = "${pkgs.lotte-art}/2022-06-21-sammythetanuki-lotteplushpride.jxl";
|
||||
}
|
||||
|
|
|
@ -121,4 +121,5 @@
|
|||
"https://cache.nixos.org/"
|
||||
];
|
||||
services.tailscale.useRoutingFeatures = "client";
|
||||
home-manager.users.darkkirb._module.args.bg = lib.mkForce "${pkgs.lotte-art}/2022-08-12-deathtoaster-funpit-scat.jxl";
|
||||
}
|
||||
|
|
|
@ -28,27 +28,6 @@
|
|||
${pkgs.sway-contrib.grimshot}/bin/grimshot "$@"
|
||||
${pkgs.sway}/bin/swaymsg mode default
|
||||
'';
|
||||
bg-full-res = "${pkgs.lotte-art}/2022-06-21-sammythetanuki-lotteplushpride.jxl";
|
||||
bg-1440p = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "wayland-background-1440p.png";
|
||||
nativeBuildInputs = [pkgs.imagemagick pkgs.libjxl];
|
||||
src = pkgs.emptyDirectory;
|
||||
buildPhase = ''
|
||||
djxl ${bg-full-res} bg-full-res.png
|
||||
convert bg-full-res.png -resize 2560x1440 $out
|
||||
'';
|
||||
installPhase = "true";
|
||||
};
|
||||
bg-1080p = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "wayland-background-1080p.png";
|
||||
nativeBuildInputs = [pkgs.imagemagick pkgs.libjxl];
|
||||
src = pkgs.emptyDirectory;
|
||||
buildPhase = ''
|
||||
djxl ${bg-full-res} bg-full-res.png
|
||||
convert bg-full-res.png -resize 1920x1080 $out
|
||||
'';
|
||||
installPhase = "true";
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
./wl-clipboard.nix
|
||||
|
@ -68,21 +47,16 @@ in {
|
|||
};
|
||||
};
|
||||
output = {
|
||||
"eDP-1" = {
|
||||
bg = "${bg-1080p} fill";
|
||||
};
|
||||
"DP-1" = {
|
||||
mode = "2560x1440@74.971Hz";
|
||||
position = "0 0";
|
||||
subpixel = "rgb";
|
||||
adaptive_sync = "on";
|
||||
bg = "${bg-1440p} fill";
|
||||
};
|
||||
"HDMI-A-1" = {
|
||||
mode = "1920x1080@60Hz";
|
||||
position = "2560 0";
|
||||
subpixel = "rgb";
|
||||
bg = "${bg-1080p} fill";
|
||||
};
|
||||
};
|
||||
keybindings = let
|
||||
|
|
|
@ -1,12 +1,33 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
colorpickle,
|
||||
bg,
|
||||
...
|
||||
}: let
|
||||
theme = import ../../extra/theme.nix;
|
||||
inherit (config.lib.formats.rasi) mkLiteral;
|
||||
rasiColor = c: mkLiteral (theme.cssColor c);
|
||||
color = n:
|
||||
config.environment.graphical.colors.main."${builtins.toString n}";
|
||||
color' = n: mkLiteral (color n);
|
||||
bgPng = pkgs.stdenv.mkDerivation {
|
||||
name = "bg.png";
|
||||
src = pkgs.emptyDirectory;
|
||||
nativeBuildInputs = [pkgs.imagemagick];
|
||||
buildPhase = ''
|
||||
convert ${bg} $out
|
||||
'';
|
||||
installPhase = "true";
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
colorpickle.nixosModules.default
|
||||
];
|
||||
environment.graphical.colorschemes.main = {
|
||||
image = bgPng;
|
||||
#params = ["--lighten" "0.1"];
|
||||
};
|
||||
wayland.windowManager.sway.config.output."*".bg = "${bgPng} fill";
|
||||
dconf.settings."org/gnome/desktop/interface" = {
|
||||
gtk-theme = "Breeze-Dark";
|
||||
icon-theme = "breeze-dark";
|
||||
|
@ -52,27 +73,27 @@ in {
|
|||
'';
|
||||
};
|
||||
programs.kitty.settings = with theme; {
|
||||
background_opacity = "0.9";
|
||||
background = cssColor base;
|
||||
foreground = cssColor text;
|
||||
cursor = cssColor text;
|
||||
background_opacity = "0.85";
|
||||
background = color 0;
|
||||
foreground = color 15;
|
||||
cursor = color 15;
|
||||
selection_background = "#4f414c";
|
||||
color0 = cssColor surface1;
|
||||
color1 = cssColor red;
|
||||
color2 = cssColor green;
|
||||
color3 = cssColor yellow;
|
||||
color4 = cssColor blue;
|
||||
color5 = cssColor pink;
|
||||
color6 = cssColor teal;
|
||||
color7 = cssColor subtext1;
|
||||
color8 = cssColor surface2;
|
||||
color9 = cssColor red;
|
||||
color10 = cssColor green;
|
||||
color11 = cssColor yellow;
|
||||
color12 = cssColor blue;
|
||||
color13 = cssColor pink;
|
||||
color14 = cssColor teal;
|
||||
color15 = cssColor subtext0;
|
||||
color0 = color 0;
|
||||
color1 = color 9;
|
||||
color2 = color 10;
|
||||
color3 = color 11;
|
||||
color4 = color 12;
|
||||
color5 = color 13;
|
||||
color6 = color 14;
|
||||
color7 = color 7;
|
||||
color8 = color 8;
|
||||
color9 = color 9;
|
||||
color10 = color 10;
|
||||
color11 = color 11;
|
||||
color12 = color 12;
|
||||
color13 = color 13;
|
||||
color14 = color 14;
|
||||
color15 = color 15;
|
||||
};
|
||||
# Taken from https://github.com/jakehamilton/dotfiles/blob/master/waybar/style.css
|
||||
programs.waybar.style = with theme; ''
|
||||
|
@ -82,11 +103,12 @@ in {
|
|||
font-size: 14px;
|
||||
min-height: 24px;
|
||||
font-family: "NotoSansDisplay Nerd Font", "Noto Sans Mono CJK JP";
|
||||
color: ${cssColor base};
|
||||
color: ${color 0};
|
||||
}
|
||||
|
||||
window#waybar {
|
||||
background: transparent;
|
||||
color: ${color 15};
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
|
@ -107,7 +129,8 @@ in {
|
|||
margin-left: 12px;
|
||||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
background: ${cssColor surface0};
|
||||
background-color: ${color 0};
|
||||
color: ${color 15};
|
||||
transition: none;
|
||||
}
|
||||
|
||||
|
@ -115,17 +138,17 @@ in {
|
|||
transition: none;
|
||||
background: transparent;
|
||||
font-size: 16px;
|
||||
color: ${cssColor text};
|
||||
color: ${color 15};
|
||||
}
|
||||
|
||||
#workspaces button.focused {
|
||||
background: ${cssColor mauve};
|
||||
color: ${cssColor base};
|
||||
background: ${color 13};
|
||||
color: ${color 0};
|
||||
}
|
||||
|
||||
#workspaces button:hover {
|
||||
background: ${cssColor sapphire};
|
||||
color: ${cssColor base};
|
||||
background: ${color 10};
|
||||
color: ${color 0};
|
||||
}
|
||||
|
||||
#mpd {
|
||||
|
@ -135,13 +158,13 @@ in {
|
|||
padding-right: 16px;
|
||||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
background: ${cssColor green};
|
||||
background: ${color 2};
|
||||
transition: none;
|
||||
}
|
||||
|
||||
#mpd.disconnected,
|
||||
#mpd.stopped {
|
||||
background: ${cssColor red};
|
||||
background: ${color 4};
|
||||
}
|
||||
|
||||
#network {
|
||||
|
@ -152,7 +175,7 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
transition: none;
|
||||
background: ${cssColor mauve};
|
||||
background: ${color 13};
|
||||
}
|
||||
|
||||
#pulseaudio {
|
||||
|
@ -163,7 +186,7 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
transition: none;
|
||||
background: ${cssColor teal};
|
||||
background: ${color 11};
|
||||
}
|
||||
|
||||
#temperature, #battery {
|
||||
|
@ -174,7 +197,7 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
transition: none;
|
||||
background: ${cssColor green};
|
||||
background: ${color 2};
|
||||
}
|
||||
|
||||
#cpu, #backlight, #battery.warning {
|
||||
|
@ -185,7 +208,7 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
transition: none;
|
||||
background: ${cssColor yellow};
|
||||
background: ${color 14};
|
||||
}
|
||||
|
||||
#memory, #battery.critical {
|
||||
|
@ -196,7 +219,7 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 24px;
|
||||
transition: none;
|
||||
background: ${cssColor red};
|
||||
background: ${color 12};
|
||||
}
|
||||
|
||||
#clock {
|
||||
|
@ -208,19 +231,19 @@ in {
|
|||
margin-bottom: 0;
|
||||
border-radius: 26px;
|
||||
transition: none;
|
||||
background: ${cssColor surface0};
|
||||
color: ${cssColor text};
|
||||
background: ${color 0};
|
||||
color: ${color 15};
|
||||
}
|
||||
'';
|
||||
|
||||
wayland.windowManager.sway.extraConfig = with theme; ''
|
||||
# target title bg text indicator border
|
||||
client.focused ${cssColor pink} ${cssColor base} ${cssColor text} ${cssColor rosewater} ${cssColor pink}
|
||||
client.focused_inactive ${cssColor mauve} ${cssColor base} ${cssColor text} ${cssColor rosewater} ${cssColor mauve}
|
||||
client.unfocused ${cssColor mauve} ${cssColor base} ${cssColor text} ${cssColor rosewater} ${cssColor mauve}
|
||||
client.urgent ${cssColor peach} ${cssColor base} ${cssColor peach} ${cssColor overlay0} ${cssColor peach}
|
||||
client.placeholder ${cssColor overlay0} ${cssColor base} ${cssColor text} ${cssColor overlay0} ${cssColor overlay0}
|
||||
client.background ${cssColor base}
|
||||
client.focused ${color 5} ${color 0} ${color 15} ${color 12} ${color 5}
|
||||
client.focused_inactive ${color 13} ${color 0} ${color 15} ${color 12} ${color 13}
|
||||
client.unfocused ${color 13} ${color 0} ${color 15} ${color 12} ${color 13}
|
||||
client.urgent ${color 14} ${color 0} ${color 14} ${color 8} ${color 14}
|
||||
client.placeholder ${color 8} ${color 0} ${color 15} ${color 8} ${color 8}
|
||||
client.background ${color 0}
|
||||
seat seat0 xcursor_theme breeze-dark 24
|
||||
'';
|
||||
home.packages = with pkgs; [libsForQt5.breeze-icons libsForQt5.qt5ct vanilla-dmz];
|
||||
|
@ -232,14 +255,14 @@ in {
|
|||
};
|
||||
in {
|
||||
"*" = {
|
||||
bg-col = rasiColor base;
|
||||
bg-col-light = rasiColor base;
|
||||
border-col = rasiColor base;
|
||||
selected-col = rasiColor base;
|
||||
blue = rasiColor blue;
|
||||
fg-col = rasiColor text;
|
||||
fg-col2 = rasiColor red;
|
||||
grey = rasiColor overlay0;
|
||||
bg-col = color' 0;
|
||||
bg-col-light = color' 0;
|
||||
border-col = color' 0;
|
||||
selected-col = color' 0;
|
||||
blue = color' 1;
|
||||
fg-col = color' 15;
|
||||
fg-col2 = color' 12;
|
||||
grey = color' 8;
|
||||
width = 600;
|
||||
};
|
||||
element-text = element;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{lib, pkgs, config, ...}: {
|
||||
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
imports = [../../modules/wordpress.nix];
|
||||
services.mysql = {
|
||||
enable = true;
|
||||
|
|
49
flake.lock
49
flake.lock
|
@ -257,6 +257,32 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"colorpickle": {
|
||||
"inputs": {
|
||||
"naersk": [
|
||||
"naersk"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"utils": [
|
||||
"flake-utils"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682020898,
|
||||
"narHash": "sha256-XYSSFmqIjsvmgusWaOSD/WeaTyH8o83i+qma1BQgARU=",
|
||||
"owner": "AgathaSorceress",
|
||||
"repo": "colorpickle",
|
||||
"rev": "2574b83cb0454a146a0346bf0d6a134d62241e60",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "AgathaSorceress",
|
||||
"repo": "colorpickle",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
|
@ -1281,6 +1307,27 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1679567394,
|
||||
"narHash": "sha256-ZvLuzPeARDLiQUt6zSZFGOs+HZmE+3g4QURc8mkBsfM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"rev": "88cd22380154a2c36799fe8098888f0f59861a15",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "master",
|
||||
"repo": "naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix": {
|
||||
"inputs": {
|
||||
"lowdown-src": "lowdown-src",
|
||||
|
@ -1903,6 +1950,7 @@
|
|||
"attic": "attic",
|
||||
"cargo2nix": "cargo2nix",
|
||||
"chir-rs": "chir-rs",
|
||||
"colorpickle": "colorpickle",
|
||||
"crane": "crane",
|
||||
"dns": "dns",
|
||||
"emanote": "emanote",
|
||||
|
@ -1912,6 +1960,7 @@
|
|||
"home-manager": "home-manager",
|
||||
"hosts-list": "hosts-list",
|
||||
"hydra": "hydra",
|
||||
"naersk": "naersk",
|
||||
"nix-neovim": "nix-neovim",
|
||||
"nix-packages": "nix-packages",
|
||||
"nixos-config-for-netboot": "nixos-config-for-netboot",
|
||||
|
|
10
flake.nix
10
flake.nix
|
@ -24,6 +24,12 @@ rec {
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.rust-overlay.follows = "rust-overlay";
|
||||
};
|
||||
colorpickle = {
|
||||
url = "github:AgathaSorceress/colorpickle";
|
||||
inputs.naersk.follows = "naersk";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.utils.follows = "flake-utils";
|
||||
};
|
||||
crane = {
|
||||
url = "github:DarkKirb/crane";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
|
@ -60,6 +66,10 @@ rec {
|
|||
#inputs.nix.follows = "nix";
|
||||
#inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
naersk = {
|
||||
url = "github:nix-community/naersk/master";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nix-neovim = {
|
||||
url = "github:syberant/nix-neovim";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.wordpress;
|
||||
eachSite = cfg.sites;
|
||||
user = "wordpress";
|
||||
webserver = config.services.${cfg.webserver};
|
||||
stateDir = hostName: "/var/lib/wordpress/${hostName}";
|
||||
|
||||
pkg = hostName: cfg: pkgs.stdenv.mkDerivation rec {
|
||||
pkg = hostName: cfg:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "wordpress-${hostName}";
|
||||
version = src.version;
|
||||
src = cfg.package;
|
||||
|
@ -38,22 +41,32 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
mergeConfig = cfg: {
|
||||
mergeConfig = cfg:
|
||||
{
|
||||
# wordpress is installed onto a read-only file system
|
||||
DISALLOW_FILE_EDIT = true;
|
||||
AUTOMATIC_UPDATER_DISABLED = true;
|
||||
DB_NAME = cfg.database.name;
|
||||
DB_HOST = "${cfg.database.host}:${if cfg.database.socket != null then cfg.database.socket else toString cfg.database.port}";
|
||||
DB_HOST = "${cfg.database.host}:${
|
||||
if cfg.database.socket != null
|
||||
then cfg.database.socket
|
||||
else toString cfg.database.port
|
||||
}";
|
||||
DB_USER = cfg.database.user;
|
||||
DB_CHARSET = "utf8";
|
||||
# Always set DB_PASSWORD even when passwordFile is not set. This is the
|
||||
# default Wordpress behaviour.
|
||||
DB_PASSWORD = if (cfg.database.passwordFile != null) then { _file = cfg.database.passwordFile; } else "";
|
||||
} // cfg.settings;
|
||||
DB_PASSWORD =
|
||||
if (cfg.database.passwordFile != null)
|
||||
then {_file = cfg.database.passwordFile;}
|
||||
else "";
|
||||
}
|
||||
// cfg.settings;
|
||||
|
||||
wpConfig = hostName: cfg: let
|
||||
conf_gen = c: mapAttrsToList (k: v: "define('${k}', ${mkPhpValue v});") cfg.mergedConfig;
|
||||
in pkgs.writeTextFile {
|
||||
in
|
||||
pkgs.writeTextFile {
|
||||
name = "wp-config-${hostName}.php";
|
||||
text = ''
|
||||
<?php
|
||||
|
@ -76,15 +89,20 @@ let
|
|||
mkPhpValue = v: let
|
||||
isHasAttr = s: isAttrs v && hasAttr s v;
|
||||
in
|
||||
if isString v then escapeShellArg v
|
||||
if isString v
|
||||
then escapeShellArg v
|
||||
# NOTE: If any value contains a , (comma) this will not get escaped
|
||||
else if isList v && any lib.strings.isCoercibleToString v then escapeShellArg (concatMapStringsSep "," toString v)
|
||||
else if isInt v then toString v
|
||||
else if isBool v then boolToString v
|
||||
else if isHasAttr "_file" then "trim(file_get_contents(${lib.escapeShellArg v._file}))"
|
||||
else if isHasAttr "_raw" then v._raw
|
||||
else abort "The Wordpress config value ${lib.generators.toPretty {} v} can not be encoded."
|
||||
;
|
||||
else if isList v && any lib.strings.isCoercibleToString v
|
||||
then escapeShellArg (concatMapStringsSep "," toString v)
|
||||
else if isInt v
|
||||
then toString v
|
||||
else if isBool v
|
||||
then boolToString v
|
||||
else if isHasAttr "_file"
|
||||
then "trim(file_get_contents(${lib.escapeShellArg v._file}))"
|
||||
else if isHasAttr "_raw"
|
||||
then v._raw
|
||||
else abort "The Wordpress config value ${lib.generators.toPretty {} v} can not be encoded.";
|
||||
|
||||
secretsVars = ["AUTH_KEY" "SECURE_AUTH_KEY" "LOGGED_IN_KEY" "NONCE_KEY" "AUTH_SALT" "SECURE_AUTH_SALT" "LOGGED_IN_SALT" "NONCE_SALT"];
|
||||
secretsScript = hostStateDir: ''
|
||||
|
@ -95,14 +113,19 @@ let
|
|||
echo "<?php" >> "${hostStateDir}/secret-keys.php"
|
||||
${concatMapStringsSep "\n" (var: ''
|
||||
echo "define('${var}', '`tr -dc a-zA-Z0-9 </dev/urandom | head -c 64`');" >> "${hostStateDir}/secret-keys.php"
|
||||
'') secretsVars}
|
||||
'')
|
||||
secretsVars}
|
||||
echo "?>" >> "${hostStateDir}/secret-keys.php"
|
||||
chmod 440 "${hostStateDir}/secret-keys.php"
|
||||
fi
|
||||
'';
|
||||
|
||||
siteOpts = { lib, name, config, ... }:
|
||||
{
|
||||
siteOpts = {
|
||||
lib,
|
||||
name,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
|
@ -130,9 +153,11 @@ let
|
|||
};
|
||||
|
||||
plugins = mkOption {
|
||||
type = with types; coercedTo
|
||||
type = with types;
|
||||
coercedTo
|
||||
(listOf path)
|
||||
(l: warn "setting this option with a list is deprecated"
|
||||
(l:
|
||||
warn "setting this option with a list is deprecated"
|
||||
listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l))
|
||||
(attrsOf path);
|
||||
default = {};
|
||||
|
@ -151,9 +176,11 @@ let
|
|||
};
|
||||
|
||||
themes = mkOption {
|
||||
type = with types; coercedTo
|
||||
type = with types;
|
||||
coercedTo
|
||||
(listOf path)
|
||||
(l: warn "setting this option with a list is deprecated"
|
||||
(l:
|
||||
warn "setting this option with a list is deprecated"
|
||||
listToAttrs (map (p: nameValuePair (p.name or (throw "${p} does not have a name")) p) l))
|
||||
(attrsOf path);
|
||||
default = {inherit (pkgs.wordpressPackages.themes) twentytwentythree;};
|
||||
|
@ -342,18 +369,15 @@ let
|
|||
@ini_set( 'display_errors', 'On' );
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config.virtualHost.hostName = mkDefault name;
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
disabledModules = ["services/web-apps/wordpress.nix"];
|
||||
# interface
|
||||
options = {
|
||||
services.wordpress = {
|
||||
|
||||
sites = mkOption {
|
||||
type = types.attrsOf (types.submodule siteOpts);
|
||||
default = {};
|
||||
|
@ -373,53 +397,62 @@ in
|
|||
See [](#opt-services.httpd.virtualHosts) for further information.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
# implementation
|
||||
config = mkIf (eachSite != {}) (mkMerge [{
|
||||
|
||||
config = mkIf (eachSite != {}) (mkMerge [
|
||||
{
|
||||
assertions =
|
||||
(mapAttrsToList (hostName: cfg:
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.user == user;
|
||||
(mapAttrsToList (hostName: cfg: {
|
||||
assertion = cfg.database.createLocally -> cfg.database.user == user;
|
||||
message = ''services.wordpress.sites."${hostName}".database.user must be ${user} if the database is to be automatically provisioned'';
|
||||
}) eachSite) ++
|
||||
(mapAttrsToList (hostName: cfg:
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
|
||||
})
|
||||
eachSite)
|
||||
++ (mapAttrsToList (hostName: cfg: {
|
||||
assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
|
||||
message = ''services.wordpress.sites."${hostName}".database.passwordFile cannot be specified if services.wordpress.sites."${hostName}".database.createLocally is set to true.'';
|
||||
}) eachSite);
|
||||
|
||||
})
|
||||
eachSite);
|
||||
|
||||
services.mysql = mkIf (any (v: v.database.createLocally) (attrValues eachSite)) {
|
||||
enable = true;
|
||||
package = mkDefault pkgs.mariadb;
|
||||
ensureDatabases = mapAttrsToList (hostName: cfg: cfg.database.name) eachSite;
|
||||
ensureUsers = mapAttrsToList (hostName: cfg:
|
||||
{ name = cfg.database.user;
|
||||
ensureUsers =
|
||||
mapAttrsToList (
|
||||
hostName: cfg: {
|
||||
name = cfg.database.user;
|
||||
ensurePermissions = {"${cfg.database.name}.*" = "ALL PRIVILEGES";};
|
||||
}
|
||||
) eachSite;
|
||||
)
|
||||
eachSite;
|
||||
};
|
||||
|
||||
services.phpfpm.pools = mapAttrs' (hostName: cfg: (
|
||||
services.phpfpm.pools =
|
||||
mapAttrs' (hostName: cfg: (
|
||||
nameValuePair "wordpress-${hostName}" {
|
||||
inherit user;
|
||||
group = webserver.group;
|
||||
settings = {
|
||||
settings =
|
||||
{
|
||||
"listen.owner" = webserver.user;
|
||||
"listen.group" = webserver.group;
|
||||
} // cfg.poolConfig;
|
||||
}
|
||||
)) eachSite;
|
||||
|
||||
// cfg.poolConfig;
|
||||
}
|
||||
))
|
||||
eachSite;
|
||||
}
|
||||
|
||||
(mkIf (cfg.webserver == "httpd") {
|
||||
services.httpd = {
|
||||
enable = true;
|
||||
extraModules = ["proxy_fcgi"];
|
||||
virtualHosts = mapAttrs (hostName: cfg: mkMerge [ cfg.virtualHost {
|
||||
virtualHosts = mapAttrs (hostName: cfg:
|
||||
mkMerge [
|
||||
cfg.virtualHost
|
||||
{
|
||||
documentRoot = mkForce "${pkg hostName cfg}/share/wordpress";
|
||||
extraConfig = ''
|
||||
<Directory "${pkg hostName cfg}/share/wordpress">
|
||||
|
@ -449,7 +482,9 @@ in
|
|||
Require all denied
|
||||
</Files>
|
||||
'';
|
||||
} ]) eachSite;
|
||||
}
|
||||
])
|
||||
eachSite;
|
||||
};
|
||||
})
|
||||
|
||||
|
@ -460,7 +495,8 @@ in
|
|||
"Z '${cfg.uploadsDir}' 0750 ${user} ${webserver.group} - -"
|
||||
"d '${cfg.fontsDir}' 0750 ${user} ${webserver.group} - -"
|
||||
"Z '${cfg.fontsDir}' 0750 ${user} ${webserver.group} - -"
|
||||
]) eachSite);
|
||||
])
|
||||
eachSite);
|
||||
|
||||
systemd.services = mkMerge [
|
||||
(mapAttrs' (hostName: cfg: (
|
||||
|
@ -475,7 +511,9 @@ in
|
|||
User = user;
|
||||
Group = webserver.group;
|
||||
};
|
||||
})) eachSite)
|
||||
}
|
||||
))
|
||||
eachSite)
|
||||
|
||||
(optionalAttrs (any (v: v.database.createLocally) (attrValues eachSite)) {
|
||||
httpd.after = ["mysql.service"];
|
||||
|
@ -491,7 +529,8 @@ in
|
|||
(mkIf (cfg.webserver == "nginx") {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs (hostName: cfg: {
|
||||
virtualHosts =
|
||||
mapAttrs (hostName: cfg: {
|
||||
serverName = mkDefault hostName;
|
||||
root = "${pkg hostName cfg}/share/wordpress";
|
||||
extraConfig = ''
|
||||
|
@ -539,14 +578,16 @@ in
|
|||
'';
|
||||
};
|
||||
};
|
||||
}) eachSite;
|
||||
})
|
||||
eachSite;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.webserver == "caddy") {
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs' (hostName: cfg: (
|
||||
virtualHosts =
|
||||
mapAttrs' (hostName: cfg: (
|
||||
nameValuePair "${hostName}" {
|
||||
extraConfig = ''
|
||||
root * /${pkg hostName cfg}/share/wordpress
|
||||
|
@ -565,10 +606,9 @@ in
|
|||
rewrite @wp-admin {path}/index.php?{query}
|
||||
'';
|
||||
}
|
||||
)) eachSite;
|
||||
))
|
||||
eachSite;
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue