Completely reformat to satisfy nixfmt

This commit is contained in:
Greg Hellings
2024-10-19 01:20:46 -05:00
parent 7abb613f20
commit a71eb7485a
56 changed files with 1749 additions and 1393 deletions
+1 -3
View File
@@ -1,8 +1,6 @@
{ ... }:
{
imports = [
../baseline.nix
];
imports = [ ../baseline.nix ];
system.stateVersion = 4;
home-manager = {
useGlobalPkgs = true;
+42 -34
View File
@@ -1,4 +1,9 @@
{ lib, config, pkgs, ... }:
{
lib,
config,
pkgs,
...
}:
let
cfg = config.greg.backup;
@@ -14,7 +19,8 @@ let
type = "sendonly";
};
makeRestic = _: job:
makeRestic =
_: job:
let
who = "${config.services.syncthing.user}:${config.services.syncthing.group}";
in
@@ -27,48 +33,50 @@ let
};
in
with lib; {
with lib;
{
options = {
greg.backup = {
jobs = mkOption {
default = { };
type = with types; attrsOf (submodule (
{ ... }:
{
options = {
src = mkOption {
type = types.str;
description = "Local path (string form) to backup from";
};
type =
with types;
attrsOf (
submodule (
{ ... }:
{
options = {
src = mkOption {
type = types.str;
description = "Local path (string form) to backup from";
};
dest = mkOption {
type = types.str;
};
dest = mkOption { type = types.str; };
id = mkOption {
type = types.str;
description = "The unique folder ID for this";
};
};
}
));
id = mkOption {
type = types.str;
description = "The unique folder ID for this";
};
};
}
)
);
};
};
};
config = mkIf ((attrValues cfg.jobs) != [ ])
{
age.secrets = {
restic-pw.file = ../../secrets/restic-pw.age;
restic-env.file = ../../secrets/restic-env.age;
};
greg.syncthing = {
enable = true;
};
services = {
syncthing.settings.folders = mapAttrs makeSyncFolders cfg.jobs;
restic.backups = mapAttrs makeRestic cfg.jobs;
};
config = mkIf ((attrValues cfg.jobs) != [ ]) {
age.secrets = {
restic-pw.file = ../../secrets/restic-pw.age;
restic-env.file = ../../secrets/restic-env.age;
};
greg.syncthing = {
enable = true;
};
services = {
syncthing.settings.folders = mapAttrs makeSyncFolders cfg.jobs;
restic.backups = mapAttrs makeRestic cfg.jobs;
};
};
}
+560 -494
View File
File diff suppressed because it is too large Load Diff
+21 -8
View File
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.databases;
@@ -7,12 +12,17 @@ in
{
options.greg.databases = lib.mkOption {
default = { };
type = with lib.types; attrsOf (submodule (
{ ... }: {
# Options reserved for future expansion
options = { };
}
));
type =
with lib.types;
attrsOf (
submodule (
{ ... }:
{
# Options reserved for future expansion
options = { };
}
)
);
};
config = lib.mkIf (dbs != [ ]) {
@@ -22,7 +32,10 @@ in
package = pkgs.postgresql_15;
checkConfig = true;
ensureDatabases = dbs;
ensureUsers = map (db: { name = db; ensureDBOwnership = true; }) dbs;
ensureUsers = map (db: {
name = db;
ensureDBOwnership = true;
}) dbs;
settings = {
log_connections = true;
log_statement = "all";
+9 -5
View File
@@ -1,10 +1,16 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.greg.gnome;
in
with lib; {
with lib;
{
options = {
greg.gnome.enable = mkEnableOption "Enable my default Gnome3 setup";
};
@@ -24,9 +30,7 @@ with lib; {
xkb.layout = "us";
};
udev.packages = with pkgs; [
gnome-settings-daemon
];
udev.packages = with pkgs; [ gnome-settings-daemon ];
pipewire.enable = true;
+31 -22
View File
@@ -1,37 +1,46 @@
{ config, pkgs, lib, options, ... }:
{
config,
pkgs,
lib,
options,
...
}:
let
cfg = config.greg.kde;
in
with lib; {
with lib;
{
options = {
greg.kde.enable = mkEnableOption "Enable my default KDE setup";
};
config = mkIf cfg.enable {
# Sets up a basic KDE installation
services = {
xserver = {
enable = true;
xkb.layout = "us";
# Trackpad support
libinput.enable = true;
};
services =
{
xserver = {
enable = true;
xkb.layout = "us";
# Trackpad support
libinput.enable = true;
};
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
} // (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
desktopManager.plasma6.enable = true;
displayManager = {
defaultSession = "plasma";
sddm.enable = true;
};
});
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
}
// (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
desktopManager.plasma6.enable = true;
displayManager = {
defaultSession = "plasma";
sddm.enable = true;
};
});
programs.dconf.enable = true;
programs.sway.enable = true; # Gives us Wayland
+13 -8
View File
@@ -1,9 +1,15 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.kiwix-serve;
in
with lib; {
with lib;
{
options.services.kiwix-serve = {
enable = mkEnableOption "Enable the Kiwix web server";
@@ -22,16 +28,15 @@ with lib; {
proxy = mkOption {
type = types.str;
default = "";
description = ''Upstream proxy, if any, to configure with kiwix. Specify
host and port. E.g. "localhost:8080"
'';
description = ''
Upstream proxy, if any, to configure with kiwix. Specify
host and port. E.g. "localhost:8080"
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [
pkgs.kiwix-tools
];
environment.systemPackages = [ pkgs.kiwix-tools ];
systemd.services.kiwix-serve = {
enable = true;
+6 -1
View File
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.linode;
+18 -13
View File
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.print;
@@ -16,19 +21,19 @@ with lib;
# ipp://printer.thehellings.lan:631/ - generic postscript printer
services.printing = {
enable = true;
drivers = with pkgs; [
gutenprint
] ++ (lib.optional pkgs.stdenv.isx86_64 gutenprintBin);
drivers = with pkgs; [ gutenprint ] ++ (lib.optional pkgs.stdenv.isx86_64 gutenprintBin);
};
hardware.printers.ensurePrinters = [{
name = "HomeLexmarkColorPrinter";
location = "Home office";
deviceUri = "ipp://printer.thehellings.lan:631/";
model = "drv:///sample.drv/generic.ppd";
ppdOptions = {
PageSize = "Letter";
};
}];
hardware.printers.ensurePrinters = [
{
name = "HomeLexmarkColorPrinter";
location = "Home office";
deviceUri = "ipp://printer.thehellings.lan:631/";
model = "drv:///sample.drv/generic.ppd";
ppdOptions = {
PageSize = "Letter";
};
}
];
};
}
+55 -48
View File
@@ -10,69 +10,76 @@ let
enableACME = dest.ssl;
locations."${dest.path}" = {
proxyPass = dest.target;
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
'' + dest.extraConfig;
extraConfig =
''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
''
+ dest.extraConfig;
};
serverAliases = lib.mkIf dest.genAliases [ "${alias name}" ];
};
in
with lib; {
with lib;
{
options = {
greg.proxies = mkOption {
default = { };
example = literalExpression ''
{ host-name = {
target = proxyLocation;
ssl = true;
};
'';
{ host-name = {
target = proxyLocation;
ssl = true;
};
'';
description = ''
Quick and simple Nginx proxy configurations.
Use this to configure a very simple proxy that does not
need any extra customization options other than SSL
enablement.
'';
Quick and simple Nginx proxy configurations.
Use this to configure a very simple proxy that does not
need any extra customization options other than SSL
enablement.
'';
type = with types; attrsOf (submodule (
{ ... }:
{
options = {
genAliases = mkOption {
type = types.bool;
description = "Whether to auto-generate short alias name";
default = true;
};
type =
with types;
attrsOf (
submodule (
{ ... }:
{
options = {
genAliases = mkOption {
type = types.bool;
description = "Whether to auto-generate short alias name";
default = true;
};
target = mkOption {
type = types.str;
description = ''The destination that is being proxied.'';
example = "http://localhost:8080";
};
target = mkOption {
type = types.str;
description = ''The destination that is being proxied.'';
example = "http://localhost:8080";
};
ssl = mkOption {
type = types.bool;
description = "Whether to enable SSL in front of the proxy";
default = false;
};
ssl = mkOption {
type = types.bool;
description = "Whether to enable SSL in front of the proxy";
default = false;
};
path = mkOption {
type = types.str;
description = "The path prefix for this proxy";
default = "/";
};
path = mkOption {
type = types.str;
description = "The path prefix for this proxy";
default = "/";
};
extraConfig = mkOption {
type = types.str;
description = "Extra nginx config options";
default = "";
};
};
}
));
extraConfig = mkOption {
type = types.str;
description = "Extra nginx config options";
default = "";
};
};
}
)
);
};
};
+35 -15
View File
@@ -1,22 +1,39 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
names = mylist: (lib.strings.concatMapStringsSep "," (x: ''"${x}"'') mylist);
# Pass the names of the wan/lan ports
nftConfig =
{ wan
, lan
, limitedLan ? [ ]
, openPorts ? [ "ssh" "67" "53" ]
, # ssh, dhcpd, dns
openUDPPorts ? [ "67" "53" ] # dhcpd, dns
{
wan,
lan,
limitedLan ? [ ],
openPorts ? [
"ssh"
"67"
"53"
],
# ssh, dhcpd, dns
openUDPPorts ? [
"67"
"53"
], # dhcpd, dns
}:
let
lanList = names lan;
allLan = names (lan ++ limitedLan);
wanName = names wan;
portsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${toString x} accept") openPorts;
udpPortsString = lib.strings.concatMapStringsSep "\n" (x: "iifname { ${lanList}, \"tailscale0\" } udp dport ${toString x} accept") openUDPPorts;
portsString = lib.strings.concatMapStringsSep "\n" (
x: "iifname { ${lanList}, \"tailscale0\" } tcp dport ${toString x} accept"
) openPorts;
udpPortsString = lib.strings.concatMapStringsSep "\n" (
x: "iifname { ${lanList}, \"tailscale0\" } udp dport ${toString x} accept"
) openUDPPorts;
in
lib.strings.concatStringsSep "\n" [
"table ip filter {"
@@ -61,7 +78,8 @@ let
cfg = config.greg.router;
in
with lib; {
with lib;
{
options.greg.router = {
enable = mkEnableOption "Enable NFTables and routing";
wan = mkOption {
@@ -82,11 +100,13 @@ with lib; {
config = mkIf cfg.enable {
networking.nftables = {
enable = true;
ruleset = (nftConfig {
inherit (cfg) lan wan;
openPorts = config.networking.firewall.allowedTCPPorts;
openUDPPorts = config.networking.firewall.allowedUDPPorts;
});
ruleset = (
nftConfig {
inherit (cfg) lan wan;
openPorts = config.networking.firewall.allowedTCPPorts;
openUDPPorts = config.networking.firewall.allowedUDPPorts;
}
);
};
environment.systemPackages = [
+8 -2
View File
@@ -1,10 +1,16 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.greg.rpi4;
in
with lib; {
with lib;
{
options = {
greg.rpi4 = {
enable = mkEnableOption "Enable support for Raspberry Pi 4s";
+2 -1
View File
@@ -4,7 +4,8 @@ let
cfg = config.greg.sway;
in
with lib; {
with lib;
{
options = {
greg.sway.enable = mkEnableOption "Enable my default Gnome3 setup";
};
+2 -1
View File
@@ -3,7 +3,8 @@
let
cfg = config.greg.syncthing;
in
with lib; {
with lib;
{
options.greg.syncthing = {
enable = mkEnableOption "Setup my personal minimal configuration for Syncthing";
};
+6 -1
View File
@@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }:
{
pkgs,
lib,
config,
...
}:
let
cfg = config.greg.vmdev;