Compare commits

..

No commits in common. "59a52dc0337f557009f5b3f83e71af402130dae3" and "9c5de4c54ff60b32a2442caffeb37d9f7a7f9939" have entirely different histories.

50 changed files with 281 additions and 284 deletions

114
flake.lock generated
View File

@ -138,6 +138,26 @@
"type": "github"
}
},
"firefox-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1737161595,
"narHash": "sha256-Txp3uh0KdB3+Pe6xihU0JWWe0LK8iXTUnZ8bOcKu3w0=",
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"rev": "3224752c71a5245e90cfae360e0dc5de98e2b53c",
"type": "github"
},
"original": {
"owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -193,6 +213,24 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": [
"mac-app-util",
@ -212,9 +250,9 @@
"type": "indirect"
}
},
"flake-utils_2": {
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
"systems": "systems_3"
},
"locked": {
"lastModified": 1705309234,
@ -283,15 +321,37 @@
"type": "github"
}
},
"mac-app-util": {
"jujutsu": {
"inputs": {
"cl-nix-lite": "cl-nix-lite",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems"
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1737163288,
"narHash": "sha256-PROBXqOUzgqIG66S74P1nyg7MbNoQ01k3oF0IM7qpHY=",
"owner": "martinvonz",
"repo": "jj",
"rev": "83d40d2c425fa2e050bdac8837b19e5beb3bef25",
"type": "github"
},
"original": {
"owner": "martinvonz",
"repo": "jj",
"type": "github"
}
},
"mac-app-util": {
"inputs": {
"cl-nix-lite": "cl-nix-lite",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_2"
},
"locked": {
"lastModified": 1732920695,
@ -361,7 +421,7 @@
},
"nix2vim": {
"inputs": {
"flake-utils": "flake-utils_2",
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs"
]
@ -594,9 +654,11 @@
"darwin": "darwin",
"disko": "disko",
"fidget-nvim-src": "fidget-nvim-src",
"firefox-darwin": "firefox-darwin",
"gh-collaborators": "gh-collaborators",
"hmts-nvim-src": "hmts-nvim-src",
"home-manager": "home-manager",
"jujutsu": "jujutsu",
"mac-app-util": "mac-app-util",
"nextcloud-cookbook": "nextcloud-cookbook",
"nextcloud-external": "nextcloud-external",
@ -631,6 +693,27 @@
"zenyd-mpv-scripts": "zenyd-mpv-scripts"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"jujutsu",
"nixpkgs"
]
},
"locked": {
"lastModified": 1735784864,
"narHash": "sha256-tIl5p3ueaPw7T5T1UXkLc8ISMk6Y8CI/D/rd0msf73I=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "04d5f1836721461b256ec452883362c5edc5288e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"snipe-nvim-src": {
"flake": false,
"locked": {
@ -648,6 +731,21 @@
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1689347925,
"narHash": "sha256-ozenz5bFe1UUqOn7f60HRmgc01BgTGIKZ4Xl+HbocGQ=",
@ -662,7 +760,7 @@
"type": "github"
}
},
"systems_2": {
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",

View File

@ -34,11 +34,11 @@
inputs.nixpkgs.follows = "nixpkgs";
};
# # Use official Firefox binary for macOS
# firefox-darwin = {
# url = "github:bandithedoge/nixpkgs-firefox-darwin";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# Use official Firefox binary for macOS
firefox-darwin = {
url = "github:bandithedoge/nixpkgs-firefox-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
# Better App install management in macOS
mac-app-util = {
@ -175,12 +175,12 @@
flake = false;
};
# # Git alternative
# # Fixes: https://github.com/martinvonz/jj/issues/4784
# jujutsu = {
# url = "github:martinvonz/jj";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# Git alternative
# Fixes: https://github.com/martinvonz/jj/issues/4784
jujutsu = {
url = "github:martinvonz/jj";
inputs.nixpkgs.follows = "nixpkgs";
};
# Ren and rep - CLI find and replace
rep = {
@ -275,7 +275,7 @@
overlays = [
inputs.nur.overlays.default
inputs.nix2vim.overlay
# inputs.jujutsu.overlays.default # Fix: https://github.com/martinvonz/jj/issues/4784
inputs.jujutsu.overlays.default # Fix: https://github.com/martinvonz/jj/issues/4784
(import ./overlays/neovim-plugins.nix inputs)
(import ./overlays/tree-sitter.nix inputs)
(import ./overlays/mpv-scripts.nix inputs)

View File

@ -1,16 +0,0 @@
# Return a list of all hosts
{ lib, ... }:
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix "default.nix" name))
# Import each host function
map
(file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
})
# Convert to an attrset of hostname -> host function
(builtins.listToAttrs)
]

View File

@ -16,27 +16,27 @@
];
options = {
# user = lib.mkOption {
# type = lib.types.str;
# description = "Primary user of the system";
# };
# fullName = lib.mkOption {
# type = lib.types.str;
# description = "Human readable name of the user";
# };
# userDirs = {
# # Required to prevent infinite recursion when referenced by himalaya
# download = lib.mkOption {
# type = lib.types.str;
# description = "XDG directory for downloads";
# default = if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
# };
# };
# identityFile = lib.mkOption {
# type = lib.types.str;
# description = "Path to existing private key file.";
# default = "/etc/ssh/ssh_host_ed25519_key";
# };
user = lib.mkOption {
type = lib.types.str;
description = "Primary user of the system";
};
fullName = lib.mkOption {
type = lib.types.str;
description = "Human readable name of the user";
};
userDirs = {
# Required to prevent infinite recursion when referenced by himalaya
download = lib.mkOption {
type = lib.types.str;
description = "XDG directory for downloads";
default = if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
};
};
identityFile = lib.mkOption {
type = lib.types.str;
description = "Path to existing private key file.";
default = "/etc/ssh/ssh_host_ed25519_key";
};
# homePath = lib.mkOption {
# type = lib.types.path;
# description = "Path of user's home directory.";

View File

@ -13,7 +13,7 @@ let
packagesDirectory = lib.filesystem.listFilesRecursive ../pkgs;
packages = lib.pipe packagesDirectory [
# Get only files called package.nix
(builtins.filter (name: (name == "package.nix")))
(builtins.filter (name: (lib.hasSuffix "package.nix" name)))
# Apply callPackage to create a derivation
(builtins.map prev.callPackage)
# Convert the list to an attrset

View File

@ -1,7 +1,4 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
];
imports = lib.filesystem.listFilesRecursive ./.;
}

View File

@ -1,49 +0,0 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.calendar;
in
{
options.nmasur.presets.programs.calendar = {
enable = lib.mkEnableOption "Calendar application";
username = lib.mkOption {
type = lib.types.str;
description = "Username for the calendar service backend";
default = config.nmasur.settings.username;
};
hostname = lib.mkOption {
type = lib.types.str;
description = "Hostname for the calendar service backend";
};
url = lib.mkOption {
type = lib.types.str;
description = "Username for the calendar service backend";
default = "https://${cfg.hostname}/remote.php/dav/principals/users/${cfg.username}";
};
};
config = lib.mkIf cfg.enable {
accounts.calendar.accounts.default = {
basePath = "other/calendars"; # Where to save calendars in ~ directory
name = "personal";
local.type = "filesystem";
primary = true;
remote = {
passwordCommand = [ "" ];
type = "caldav";
url = cfg.url;
userName = cfg.username;
};
};
home.packages = [ pkgs.gnome-calendar ];
};
}

View File

@ -20,7 +20,7 @@ in
accounts.email.accounts.home.himalaya = {
enable = true;
settings = {
downloads-dir = config.xdg.userDirs.download;
downloads-dir = config.userDirs.download;
smtp-insecure = true;
};
};

View File

@ -26,10 +26,9 @@ in
];
programs.gh-dash.enable = lib.mkDefault true;
programs.gh-dash.enable = true;
programs.helix.enable = lib.mkDefault true;
programs.zed-editor.enable = lib.mkDefault true;
programs.himalaya.enable = lib.mkDefault true;
};

View File

@ -16,14 +16,14 @@ in
config = lib.mkIf cfg.enable {
# Allow Nix to manage the default applications list
xdg.mimeApps.enable = lib.mkDefault true;
mimeApps.enable = lib.mkDefault true;
# Set directories for application defaults
xdg.userDirs = {
userDirs = {
enable = lib.mkDefault true;
createDirectories = lib.mkDefault true;
documents = lib.mkDefault "$HOME/documents";
download = lib.mkDefault "$HOME/downloads";
download = lib.mkDefault config.userDirs.download;
music = lib.mkDefault "$HOME/media/music";
pictures = lib.mkDefault "$HOME/media/images";
videos = lib.mkDefault "$HOME/media/videos";

View File

@ -1,7 +1,4 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
];
imports = lib.filesystem.listFilesRecursive ./.;
}

View File

@ -7,7 +7,6 @@
let
cfg = config.nmasur.presets.programs.fish;
inherit (config.nmasur.settings) username;
in
{
@ -19,7 +18,7 @@ in
environment.shells = [ pkgs.fish ];
users.users.${username}.shell = pkgs.fish;
users.users.${config.user}.shell = pkgs.fish;
# Speeds up fish launch time on macOS
programs.fish.useBabelfish = true;

View File

@ -6,7 +6,6 @@
let
cfg = config.nmasur.presets.services.hammerspoon;
inherit (config.nmasur.settings) username;
in
{
@ -20,7 +19,7 @@ in
system.activationScripts.postUserActivation.text = ''
defaults write org.hammerspoon.Hammerspoon MJConfigFile "${
config.home-manager.users.${username}.xdg.configHome
config.home-manager.users.${config.user}.xdg.configHome
}/hammerspoon/init.lua"
sudo killall Dock
'';

View File

@ -1,14 +0,0 @@
{ lib, ... }:
{
options.nmasur.settings = {
username = lib.mkOption {
type = lib.types.str;
description = "Primary username for the system";
};
fullName = lib.mkOption {
type = lib.types.str;
description = "Human readable name of the user";
};
};
}

View File

@ -1,7 +1,4 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
];
imports = lib.filesystem.listFilesRecursive ./.;
}

View File

@ -0,0 +1,8 @@
{ lib, ... }:
{
options.hostnames = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
};
}

View File

@ -0,0 +1,33 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.calendar;
in
{
options.nmasur.presets.programs.calendar.enable = lib.mkEnableOption "Calendar application";
config = lib.mkIf cfg.enable {
accounts.calendar.accounts.default = {
basePath = "other/calendars"; # Where to save calendars in ~ directory
name = "personal";
local.type = "filesystem";
primary = true;
remote = {
passwordCommand = [ "" ];
type = "caldav";
url = "https://${config.hostnames.content}/remote.php/dav/principals/users/${config.user}";
userName = config.user;
};
};
home.packages = [ pkgs.gnome-calendar ];
};
}

View File

@ -5,7 +5,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.actualbudget;
in
@ -61,7 +60,7 @@ in
# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ hostnames.budget ]; } ];
match = [ { host = [ config.hostnames.budget ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -72,7 +71,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.budget ];
services.cloudflare-dyndns.domains = [ config.hostnames.budget ];
# Backups
services.restic.backups.default.paths = [ "/var/lib/actualbudget" ];

View File

@ -7,7 +7,6 @@
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.actualbudget;
# This config specifies ports for Prometheus to scrape information
@ -99,7 +98,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/sonarr*" ];
}
];
@ -115,7 +114,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/radarr*" ];
}
];
@ -130,7 +129,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/readarr*" ];
}
];
@ -145,7 +144,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/prowlarr*" ];
}
];
@ -161,7 +160,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/bazarr*" ];
}
];
@ -181,7 +180,7 @@ in
group = "download";
match = [
{
host = [ hostnames.download ];
host = [ config.hostnames.download ];
path = [ "/sabnzbd*" ];
}
];
@ -194,7 +193,7 @@ in
}
{
group = "download";
match = [ { host = [ hostnames.download ]; } ];
match = [ { host = [ config.hostnames.download ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -205,7 +204,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.download ];
services.cloudflare-dyndns.domains = [ config.hostnames.download ];
# Enable Prometheus exporters
systemd.services = lib.mapAttrs' (name: attrs: {

View File

@ -13,16 +13,15 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.bind;
localIp = "192.168.1.218";
localServices = [
hostnames.stream
hostnames.content
hostnames.books
hostnames.download
hostnames.photos
config.hostnames.stream
config.hostnames.content
config.hostnames.books
config.hostnames.download
config.hostnames.photos
];
mkRecord = service: "${service} A ${localIp}";
localRecords = lib.concatLines (map mkRecord localServices);

View File

@ -1,7 +1,7 @@
# Calibre-web is an E-Book library and management tool.
# - Exposed to the public via Caddy.
# - Hostname defined with hostnames.books
# - Hostname defined with config.hostnames.books
# - File directory backed up to S3 on a cron schedule.
{
@ -13,7 +13,6 @@
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.calibre-web;
libraryPath = "/data/books";
in
@ -39,7 +38,7 @@ in
# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ hostnames.books ]; } ];
match = [ { host = [ config.hostnames.books ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -55,7 +54,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.books ];
services.cloudflare-dyndns.domains = [ config.hostnames.books ];
# Grant user access to Calibre directories
users.users.${config.user}.extraGroups = [ "calibre-web" ];

View File

@ -4,7 +4,6 @@
...
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.filebrowser;
in
{
@ -21,7 +20,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.files ]; } ];
match = [ { host = [ config.hostnames.files ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -34,7 +33,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.files ];
services.cloudflare-dyndns.domains = [ config.hostnames.files ];
};

View File

@ -12,7 +12,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.gitea-runner-local;
in
@ -43,7 +42,7 @@ in
wget
];
name = config.networking.hostName;
url = "https://${hostnames.git}";
url = "https://${config.hostnames.git}";
tokenFile = config.secrets.giteaRunnerToken.dest;
};

View File

@ -6,7 +6,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.gitea;
giteaPath = "/var/lib/gitea"; # Default service directory
in
@ -29,7 +28,7 @@ in
DISABLE_HTTP_GIT = false;
# Allow requests hitting the specified hostname.
ACCESS_CONTROL_ALLOW_ORIGIN = hostnames.git;
ACCESS_CONTROL_ALLOW_ORIGIN = config.hostnames.git;
# Automatically create viable users/orgs on push.
ENABLE_PUSH_CREATE_USER = true;
@ -41,7 +40,7 @@ in
server = {
HTTP_PORT = 3001;
HTTP_ADDRESS = "127.0.0.1";
ROOT_URL = "https://${hostnames.git}/";
ROOT_URL = "https://${config.hostnames.git}/";
SSH_PORT = 22;
START_SSH_SERVER = false; # Use sshd instead
DISABLE_SSH = false;
@ -66,7 +65,7 @@ in
{
match = [
{
host = [ hostnames.git ];
host = [ config.hostnames.git ];
path = [ "/metrics*" ];
}
];
@ -79,7 +78,7 @@ in
}
# Allow access to primary server.
{
match = [ { host = [ hostnames.git ]; } ];
match = [ { host = [ config.hostnames.git ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -92,7 +91,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.git ];
services.cloudflare-dyndns.domains = [ config.hostnames.git ];
# Scrape the metrics endpoint for Prometheus.
prometheus.scrapeTargets = [

View File

@ -6,7 +6,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.grafana;
promUid = "victoriametrics";
in
@ -32,7 +31,7 @@ in
enable = true;
settings = {
server = {
domain = hostnames.metrics;
domain = config.hostnames.metrics;
http_addr = "127.0.0.1";
http_port = 3000;
protocol = "http";
@ -452,7 +451,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.git}/admin/runners";
url = "https://${config.hostnames.git}/admin/runners";
}
];
options = {
@ -526,7 +525,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.stream}";
url = "https://${config.hostnames.stream}";
}
];
options = {
@ -786,7 +785,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}";
url = "https://${config.hostnames.download}";
}
];
}
@ -808,7 +807,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/bazarr";
url = "https://${config.hostnames.download}/bazarr";
}
];
}
@ -830,7 +829,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/radarr";
url = "https://${config.hostnames.download}/radarr";
}
];
}
@ -852,7 +851,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/readarr";
url = "https://${config.hostnames.download}/readarr";
}
];
}
@ -874,7 +873,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.content}";
url = "https://${config.hostnames.content}";
}
];
}
@ -896,7 +895,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.books}";
url = "https://${config.hostnames.books}";
}
];
}
@ -918,7 +917,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/sabnzbd";
url = "https://${config.hostnames.download}/sabnzbd";
}
];
}
@ -940,7 +939,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.influxdb}";
url = "https://${config.hostnames.influxdb}";
}
];
}
@ -962,7 +961,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.stream}";
url = "https://${config.hostnames.stream}";
}
];
}
@ -984,7 +983,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/sonarr";
url = "https://${config.hostnames.download}/sonarr";
}
];
}
@ -1006,7 +1005,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.irc}";
url = "https://${config.hostnames.irc}";
}
];
}
@ -1028,7 +1027,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.download}/prowlarr";
url = "https://${config.hostnames.download}/prowlarr";
}
];
}
@ -1050,7 +1049,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.metrics}";
url = "https://${config.hostnames.metrics}";
}
];
}
@ -1072,7 +1071,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.git}";
url = "https://${config.hostnames.git}";
}
];
}
@ -1094,7 +1093,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.secrets}";
url = "https://${config.hostnames.secrets}";
}
];
}
@ -1116,7 +1115,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.prometheus}/vmui";
url = "https://${config.hostnames.prometheus}/vmui";
}
];
}
@ -1138,7 +1137,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.paperless}";
url = "https://${config.hostnames.paperless}";
}
];
}
@ -1160,7 +1159,7 @@ in
{
targetBlank = true;
title = "";
url = "https://${hostnames.audiobooks}";
url = "https://${config.hostnames.audiobooks}";
}
];
}
@ -2563,7 +2562,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.metrics ]; } ];
match = [ { host = [ config.hostnames.metrics ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -2576,6 +2575,6 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.metrics ];
services.cloudflare-dyndns.domains = [ config.hostnames.metrics ];
};
}

View File

@ -1,7 +1,6 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.immich;
in
@ -20,7 +19,7 @@ in
machine-learning.environment = { };
mediaLocation = "/data/images";
secretsFile = null;
settings.server.externalDomain = "https://${hostnames.photos}";
settings.server.externalDomain = "https://${config.hostnames.photos}";
environment = {
IMMICH_ENV = "production";
IMMICH_LOG_LEVEL = "log";
@ -31,7 +30,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.photos ]; } ];
match = [ { host = [ config.hostnames.photos ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -42,10 +41,10 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.photos ];
services.cloudflare-dyndns.domains = [ config.hostnames.photos ];
# Point localhost to the local domain
networking.hosts."127.0.0.1" = [ hostnames.photos ];
networking.hosts."127.0.0.1" = [ config.hostnames.photos ];
# Backups
services.restic.backups.default.paths = [ "/data/images" ];

View File

@ -6,7 +6,6 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.influxdb2;
in
{
@ -57,7 +56,7 @@ in
caddy.routes = lib.mkIf config.services.influxdb2.enable [
{
match = [ { host = [ hostnames.influxdb ]; } ];
match = [ { host = [ config.hostnames.influxdb ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -68,6 +67,6 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.influxdb ];
services.cloudflare-dyndns.domains = [ config.hostnames.influxdb ];
};
}

View File

@ -9,7 +9,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.jellyfin;
in
{
@ -26,7 +25,7 @@ in
{
match = [
{
host = [ hostnames.stream ];
host = [ config.hostnames.stream ];
path = [ "/metrics*" ];
}
];
@ -39,7 +38,7 @@ in
}
# Allow access to normal route.
{
match = [ { host = [ hostnames.stream ]; } ];
match = [ { host = [ config.hostnames.stream ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -50,7 +49,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.stream ];
services.cloudflare-dyndns.domains = [ config.hostnames.stream ];
# Create videos directory, allow anyone in Jellyfin group to manage it
systemd.tmpfiles.rules = [

View File

@ -6,7 +6,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.minecraft-server;
localPort = 25564;
publicPort = 49732;
@ -53,7 +52,7 @@ in
networking.firewall.allowedTCPPorts = [ publicPort ];
cloudflare.noProxyDomains = [ hostnames.minecraft ];
cloudflare.noProxyDomains = [ config.hostnames.minecraft ];
## Automatically start and stop Minecraft server based on player connections

View File

@ -6,7 +6,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.nextcloud;
in
{
@ -31,7 +30,7 @@ in
settings = {
default_phone_region = "US";
# Allow access when hitting either of these hosts or IPs
trusted_domains = [ hostnames.content ];
trusted_domains = [ config.hostnames.content ];
trusted_proxies = [ "127.0.0.1" ];
maintenance_window_start = 4; # Run jobs at 4am UTC
log_type = "file";
@ -65,7 +64,7 @@ in
# Point Caddy to Nginx
caddy.routes = [
{
match = [ { host = [ hostnames.content ]; } ];
match = [ { host = [ config.hostnames.content ]; } ];
handle = [
{
handler = "subroute";
@ -196,7 +195,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.content ];
services.cloudflare-dyndns.domains = [ config.hostnames.content ];
# Create credentials file for nextcloud
secrets.nextcloud = {
@ -218,11 +217,11 @@ in
systemd.services.phpfpm-nextcloud.serviceConfig.StateDirectoryMode = lib.mkForce "0770";
# Log metrics to prometheus
networking.hosts."127.0.0.1" = [ hostnames.content ];
networking.hosts."127.0.0.1" = [ config.hostnames.content ];
services.prometheus.exporters.nextcloud = {
enable = config.prometheus.exporters.enable;
username = config.services.nextcloud.config.adminuser;
url = "https://${hostnames.content}";
url = "https://${config.hostnames.content}";
passwordFile = config.services.nextcloud.config.adminpassFile;
};
prometheus.scrapeTargets = [

View File

@ -1,7 +1,6 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.ntfy-sh;
in
@ -12,7 +11,7 @@ in
services.ntfy-sh = {
enable = true;
settings = {
base-url = "https://${hostnames.notifications}";
base-url = "https://${config.hostnames.notifications}";
upstream-base-url = "https://ntfy.sh";
listen-http = ":8333";
behind-proxy = true;
@ -23,7 +22,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.notifications ]; } ];
match = [ { host = [ config.hostnames.notifications ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -34,7 +33,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.notifications ];
services.cloudflare-dyndns.domains = [ config.hostnames.notifications ];
};
}

View File

@ -3,7 +3,6 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.paperless;
in
{
@ -34,7 +33,7 @@ in
{
match = [
{
host = [ hostnames.paperless ];
host = [ config.hostnames.paperless ];
# path = [ "/paperless*" ]; # Change path name in Caddy
}
];
@ -48,7 +47,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.paperless ];
services.cloudflare-dyndns.domains = [ config.hostnames.paperless ];
secrets.paperless = {
source = ../../../private/prometheus.age;

View File

@ -11,7 +11,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.prometheus-remote-write;
in
{
@ -26,7 +25,7 @@ in
remoteWrite = [
{
name = config.networking.hostName;
url = "https://${hostnames.prometheus}/api/v1/write";
url = "https://${config.hostnames.prometheus}/api/v1/write";
basic_auth = {
# Uses password hashed with bcrypt above
username = "prometheus";

View File

@ -1,6 +1,5 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.thelounge;
in
{
@ -23,7 +22,7 @@ in
# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ hostnames.irc ]; } ];
match = [ { host = [ config.hostnames.irc ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -34,6 +33,6 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.irc ];
services.cloudflare-dyndns.domains = [ config.hostnames.irc ];
};
}

View File

@ -9,7 +9,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.transmission;
in
{
@ -38,7 +37,7 @@ in
# This is a salted hash of the real password
# https://github.com/tomwijnroks/transmission-pwgen
rpc-password = "{c4c5145f6e18bcd3c7429214a832440a45285ce26jDOBGVW";
rpc-host-whitelist = hostnames.transmission;
rpc-host-whitelist = config.hostnames.transmission;
rpc-host-whitelist-enabled = true;
rpc-whitelist = lib.mkDefault "127.0.0.1"; # Overwritten by Cloudflare
rpc-whitelist-enabled = true;
@ -46,7 +45,7 @@ in
};
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.transmission ];
services.cloudflare-dyndns.domains = [ config.hostnames.transmission ];
# Bind transmission to wireguard namespace
systemd.services.transmission = lib.mkIf config.wireguard.enable {
@ -67,14 +66,14 @@ in
caddy.routes =
let
# Set if the download domain is the same as the Transmission domain
useDownloadDomain = hostnames.download == hostnames.transmission;
useDownloadDomain = config.hostnames.download == config.hostnames.transmission;
in
lib.mkAfter [
{
group = if useDownloadDomain then "download" else "transmission";
match = [
{
host = [ hostnames.transmission ];
host = [ config.hostnames.transmission ];
path = if useDownloadDomain then [ "/transmission*" ] else null;
}
];

View File

@ -1,7 +1,6 @@
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.uptime-kuma;
in
@ -21,7 +20,7 @@ in
# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ hostnames.status ]; } ];
match = [ { host = [ config.hostnames.status ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -34,7 +33,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.status ];
services.cloudflare-dyndns.domains = [ config.hostnames.status ];
};

View File

@ -10,7 +10,6 @@
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.vaultwarden;
vaultwardenPath = "/var/lib/bitwarden_rs"; # Default service directory
in
@ -23,7 +22,7 @@ in
services.vaultwarden = {
enable = true;
config = {
DOMAIN = "https://${hostnames.secrets}";
DOMAIN = "https://${config.hostnames.secrets}";
SIGNUPS_ALLOWED = false;
SIGNUPS_VERIFY = true;
INVITATIONS_ALLOWED = true;
@ -53,7 +52,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.secrets ]; } ];
match = [ { host = [ config.hostnames.secrets ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -67,7 +66,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.secrets ];
services.cloudflare-dyndns.domains = [ config.hostnames.secrets ];
## Backup config

View File

@ -10,7 +10,6 @@
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.victoriametrics;
username = "prometheus";
@ -80,7 +79,7 @@ in
caddy.routes = [
{
match = [ { host = [ hostnames.prometheus ]; } ];
match = [ { host = [ config.hostnames.prometheus ]; } ];
handle = [
{
handler = "reverse_proxy";
@ -91,7 +90,7 @@ in
];
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.prometheus ];
services.cloudflare-dyndns.domains = [ config.hostnames.prometheus ];
};
}

View File

@ -10,7 +10,6 @@
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.vm-agent;
username = "prometheus";
@ -38,7 +37,7 @@ in
package = pkgs-stable.vmagent;
prometheusConfig = prometheusConfig;
remoteWrite = {
url = "https://${hostnames.prometheus}/api/v1/write";
url = "https://${config.hostnames.prometheus}/api/v1/write";
basicAuthUsername = username;
basicAuthPasswordFile = config.secrets.vmagent.dest;
};

View File

@ -1,19 +0,0 @@
{ lib, ... }:
{
options.nmasur.settings = {
username = lib.mkOption {
type = lib.types.str;
description = "Primary username for the system";
};
fullName = lib.mkOption {
type = lib.types.str;
description = "Human readable name of the user";
};
options.hostnames = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
description = "Map of service names to FQDNs";
default = { };
};
};
}

View File

@ -27,7 +27,6 @@ in
identityFile = lib.mkOption {
type = lib.types.path;
description = "Path containing decryption identity.";
default = "/etc/ssh/ssh_host_ed25519_key";
};
secrets = lib.mkOption {
@ -92,7 +91,7 @@ in
script = ''
echo "${attrs.prefix}$(
${pkgs.age}/bin/age --decrypt \
--identity ${config.identityFile} ${attrs.source}
--identity ${config.secretsIdentityFile} ${attrs.source}
)" > ${attrs.dest}
chown '${attrs.owner}':'${attrs.group}' '${attrs.dest}'

View File

@ -5,7 +5,6 @@
...
}:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.services.filebrowser;
dataDir = "/var/lib/filebrowser";
@ -58,7 +57,7 @@ in
};
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.files ];
services.cloudflare-dyndns.domains = [ config.hostnames.files ];
};

View File

@ -2,22 +2,14 @@
# together with triggers.
{ config, lib, ... }:
let
inherit (config.nmasur.settings) hostnames;
cfg = config.nmasur.presets.services.n8n;
in
{
options.nmasur.presets.services.n8n.enable = lib.mkEnableOption "n8n low-code automation tool";
config = lib.mkIf cfg.enable {
config = lib.mkIf config.services.n8n.enable {
unfreePackages = [ "n8n" ];
services.n8n = {
webhookUrl = "https://${hostnames.n8n}";
webhookUrl = "https://${config.hostnames.n8n}";
settings = {
listen_address = "127.0.0.1";
port = 5678;
@ -30,12 +22,12 @@ in
};
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ hostnames.n8n ];
services.cloudflare-dyndns.domains = [ config.hostnames.n8n ];
# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ hostnames.n8n ]; } ];
match = [ { host = [ config.hostnames.n8n ]; } ];
handle = [
{
handler = "reverse_proxy";