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