Compare commits

..

No commits in common. "9fb7f68b07f4223c72e25e149600e2d252dff2fc" and "0b0556f05707b9b473c9a7217067a231fe8e9456" have entirely different histories.

2 changed files with 69 additions and 160 deletions

View File

@ -87,11 +87,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1722924007, "lastModified": 1723859949,
"narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=", "narHash": "sha256-kiaGz4deGYKMjJPOji/JVvSP/eTefrIA3rAjOnOpXl4=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "91010a5613ffd7ee23ee9263213157a1c422b705", "rev": "076b9a905af8a52b866c8db068d6da475839d97b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -108,11 +108,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1723080788, "lastModified": 1723685519,
"narHash": "sha256-C5LbM5VMdcolt9zHeLQ0bYMRjUL+N+AL5pK7/tVTdes=", "narHash": "sha256-GkXQIoZmW2zCPp1YFtAYGg/xHNyFH/Mgm79lcs81rq0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "ffc1f95f6c28e1c6d1e587b51a2147027a3e45ed", "rev": "276a0d055a720691912c6a34abb724e395c8e38a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -145,11 +145,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1723337675, "lastModified": 1723942423,
"narHash": "sha256-JKEthOttE4K+qLicLEFBqHcy/LHPLEAJtcVNjzWG5aY=", "narHash": "sha256-uxstga6zuQJUWKliCb8Ji9v0AZV1vZdnOoaX8Djwv5w=",
"owner": "bandithedoge", "owner": "bandithedoge",
"repo": "nixpkgs-firefox-darwin", "repo": "nixpkgs-firefox-darwin",
"rev": "6ffec5acd449b5f2ab4b22c271ad1670a790a1e1", "rev": "4a17fec79e6c600f3c2e57984197cb7834a616b0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -267,11 +267,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1723015306, "lastModified": 1723399884,
"narHash": "sha256-jQnFEtH20/OsDPpx71ntZzGdRlpXhUENSQCGTjn//NA=", "narHash": "sha256-97wn0ihhGqfMb8WcUgzzkM/TuAxce2Gd20A8oiruju4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "b3d5ea65d88d67d4ec578ed11d4d2d51e3de525e", "rev": "086f619dd991a4d355c07837448244029fc2d9ab",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -307,11 +307,11 @@
"markview-nvim-src": { "markview-nvim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1723341339, "lastModified": 1723885833,
"narHash": "sha256-/82M85uv63L/rCMTU/w1LRJgg1F5CYl7881Vq9UPDKo=", "narHash": "sha256-Z7iy0LW9WjH4U9dhX3zCyCTnsZZMlMCHJnn8xku6osU=",
"owner": "OXY2DEV", "owner": "OXY2DEV",
"repo": "markview.nvim", "repo": "markview.nvim",
"rev": "c9fa1065098663c3bfe7e07656937c3d2f3dabea", "rev": "738ddc0390449c0652f34b99a6cbe0699b2fcf58",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -362,7 +362,7 @@
"nextcloud-snappymail": { "nextcloud-snappymail": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1723347706, "lastModified": 1723952471,
"narHash": "sha256-HlqO7xlMSRGgBtwi0t5oz5v7iw0zTSHysc9wGVRwGZI=", "narHash": "sha256-HlqO7xlMSRGgBtwi0t5oz5v7iw0zTSHysc9wGVRwGZI=",
"type": "tarball", "type": "tarball",
"url": "https://snappymail.eu/repository/nextcloud/snappymail-2.36.4-nextcloud.tar.gz" "url": "https://snappymail.eu/repository/nextcloud/snappymail-2.36.4-nextcloud.tar.gz"
@ -395,11 +395,11 @@
}, },
"nixlib": { "nixlib": {
"locked": { "locked": {
"lastModified": 1722732880, "lastModified": 1723337705,
"narHash": "sha256-do2Mfm3T6SR7a5A804RhjQ+JTsF5hk4JTPGjCTRM/m8=", "narHash": "sha256-znSU0DeNDPt7+LMAfFkvKloMaeQ6yl/U5SqV/ktl1vA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs.lib", "repo": "nixpkgs.lib",
"rev": "8bebd4c74f368aacb047f0141db09ec6b339733c", "rev": "ace7856d327b618d3777e31b1f224b3ab57ed71a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -416,11 +416,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1723078345, "lastModified": 1723870831,
"narHash": "sha256-HSxOQEKNZXiJe9aWnckTTCThOhcRCabwHa32IduDKLk=", "narHash": "sha256-rXQKvogLHY3BxRVVt5unpbi0zpRf965f57gplWSzQ5k=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-generators", "repo": "nixos-generators",
"rev": "d6c5d29f58acc10ea82afff1de2b28f038f572bd", "rev": "32e9d82bada67fc5155e8d4d99b6fc3a1765bfdc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -431,11 +431,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1723175592, "lastModified": 1723637854,
"narHash": "sha256-M0xJ3FbDUc4fRZ84dPGx5VvgFsOzds77KiBMW/mMTnI=", "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5e0ca22929f3342b19569b21b2f3462f053e497b", "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -463,11 +463,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1723345421, "lastModified": 1723949656,
"narHash": "sha256-KJ/+Q43cumayNUUvz6VCImL6PcRYnLuupDnXg9mA+xo=", "narHash": "sha256-4C7TBGD97Vj6gDbw3n+uw7sxGUD1PkJgMsn/UYyaNRs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nur", "repo": "nur",
"rev": "638e850bd503b43214c8e39a838c625f011d9b10", "rev": "eefd7f643ffeb25543019d48952e66ddae3da583",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -479,11 +479,11 @@
"nvim-lint-src": { "nvim-lint-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1723296187, "lastModified": 1723839733,
"narHash": "sha256-PoCx65jQGEoKFyedNs1IoQFcsw7jd3kEbRyZE8mkSzA=", "narHash": "sha256-V35ivsZnL9M5ge7E+7fqcLjjM3xsDGCLmxTmQ8iZNiA=",
"owner": "mfussenegger", "owner": "mfussenegger",
"repo": "nvim-lint", "repo": "nvim-lint",
"rev": "ad0fe35e80f5cd31a0f19176d7b30e5c3011119d", "rev": "debabca63c0905b59ce596a55a8e33eafdf66342",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -528,11 +528,11 @@
"nvim-treesitter-src": { "nvim-treesitter-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1723278970, "lastModified": 1723928672,
"narHash": "sha256-KF/5Ng0mzrZv/ghyAeEJWuyP0SwA5JKNJCg8Ozoob8g=", "narHash": "sha256-VqAaWEkLmIXZnFyY1PsfFRrVH2gen9ONkUEKIlJCpik=",
"owner": "nvim-treesitter", "owner": "nvim-treesitter",
"repo": "nvim-treesitter", "repo": "nvim-treesitter",
"rev": "8a966f32c973511f9697264b3533e9846d29fd09", "rev": "6d74da7f0a29c35ee7636e157e72dd221e8d6197",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -734,11 +734,11 @@
"tiny-inline-diagnostic-nvim-src": { "tiny-inline-diagnostic-nvim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1723294442, "lastModified": 1723808284,
"narHash": "sha256-Y2Suu8ISSKRvgVTEYo9Fl8+Z4d6ZjhtFGXjt0x2iw30=", "narHash": "sha256-RFX4iPDDG7s+jN8uLqv4oHhddsqVBYP+oyFycaBKIsg=",
"owner": "rachartier", "owner": "rachartier",
"repo": "tiny-inline-diagnostic.nvim", "repo": "tiny-inline-diagnostic.nvim",
"rev": "7b212b214aed37d8ae1a26ac6ca9593223a23ddb", "rev": "957e1a4710f2cbad66b747c579ab8b450bda9dd6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -833,11 +833,11 @@
"tree-sitter-python": { "tree-sitter-python": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1721001135, "lastModified": 1723942537,
"narHash": "sha256-H6t98tuXJW2VD5Ay+rOfnp9p5ZljyPxvtIy60PycMUQ=", "narHash": "sha256-x9PTCiwa5hVLLqc3wFfI68KCyOlx6XtcTCJynZ0fDSk=",
"owner": "tree-sitter", "owner": "tree-sitter",
"repo": "tree-sitter-python", "repo": "tree-sitter-python",
"rev": "0dee05ef958ba2eae88d1e65f24b33cad70d4367", "rev": "55a9b8a4fbfbaf0d10cdd47dd4a9d02606c4c218",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -58,129 +58,38 @@
} }
]; ];
services.caddy = services.caddy = {
let adapter = "''"; # Required to enable JSON
default_logger_name = "other"; configFile = pkgs.writeText "Caddyfile" (
roll_size_mb = 10; builtins.toJSON {
# Extract list of hostnames (fqdns) from current caddy routes apps.http.servers.main = {
getHostnameFromMatch = match: if (lib.hasAttr "host" match) then match.host else [ ]; listen = [ ":443" ];
getHostnameFromRoute =
route:
if (lib.hasAttr "match" route) then (lib.concatMap getHostnameFromMatch route.match) else [ ];
hostnames_non_unique = lib.concatMap getHostnameFromRoute config.caddy.routes;
hostnames = lib.unique hostnames_non_unique;
# Create attrset of subdomains to their fqdns
hostname_map = builtins.listToAttrs (
map (hostname: {
name = builtins.head (lib.splitString "." hostname);
value = hostname;
}) hostnames
);
in
{
adapter = "''"; # Required to enable JSON
configFile = pkgs.writeText "Caddyfile" (
builtins.toJSON {
apps.http.servers.main = {
listen = [ ":443" ];
# These routes are pulled from the rest of this repo # These routes are pulled from the rest of this repo
routes = config.caddy.routes; routes = config.caddy.routes;
errors.routes = config.caddy.blocks; errors.routes = config.caddy.blocks;
# Uncommenting collects access logs logs = { }; # Uncommenting collects access logs
logs = { };
inherit default_logger_name; apps.http.servers.metrics = { }; # Enables Prometheus metrics
# Invert hostnames keys and values apps.tls.automation.policies = config.caddy.tlsPolicies;
logger_names = lib.mapAttrs' (name: value: {
name = value; # Setup logging to file
value = name; logging.logs.main = {
}) hostname_map; encoder = {
}; format = "console";
}; };
apps.http.servers.metrics = { }; # Enables Prometheus metrics writer = {
apps.tls.automation.policies = config.caddy.tlsPolicies; output = "file";
filename = "${config.services.caddy.logDir}/caddy.log";
# Setup logging to journal and files roll = true;
logging.logs = roll_size_mb = 1;
{ };
# System logs and catch-all level = "INFO";
# Must be called `default` to override Caddy's built-in default logger };
default = { }
level = "INFO"; );
encoder.format = "console"; };
writer = {
output = "stderr";
};
exclude = map (hostname: "http.log.access.${hostname}") (builtins.attrNames hostname_map);
};
# This is for the default access logs (anything not captured by hostname)
other = {
level = "INFO";
encoder.format = "json";
writer = {
output = "file";
filename = "${config.services.caddy.logDir}/other.log";
roll = true;
inherit roll_size_mb;
};
include = [ "http.log.access.${default_logger_name}" ];
};
# This is for using the Caddy API, which will probably never happen
admin = {
level = "INFO";
encoder.format = "json";
writer = {
output = "file";
filename = "${config.services.caddy.logDir}/admin.log";
roll = true;
inherit roll_size_mb;
};
include = [ "admin.api" ];
};
# This is for debugging
debug = {
level = "DEBUG";
encoder.format = "console";
writer = {
output = "file";
filename = "${config.services.caddy.logDir}/debug.log";
roll = true;
roll_keep = 1;
inherit roll_size_mb;
};
};
}
# These are the access logs for individual hostnames
// (lib.mapAttrs (name: value: {
level = "INFO";
encoder.format = "json";
writer = {
output = "file";
filename = "${config.services.caddy.logDir}/${name}-access.log";
roll = true;
inherit roll_size_mb;
};
include = [ "http.log.access.${name}" ];
}) hostname_map)
# We also capture just the errors separately for easy debugging
// (lib.mapAttrs' (name: value: {
name = "${name}-error";
value = {
level = "ERROR";
encoder.format = "json";
writer = {
output = "file";
filename = "${config.services.caddy.logDir}/${name}-error.log";
roll = true;
inherit roll_size_mb;
};
include = [ "http.log.access.${name}" ];
};
}) hostname_map);
}
);
};
systemd.services.caddy.serviceConfig = { systemd.services.caddy.serviceConfig = {