Skip to content

Commit

Permalink
utils(mkVhost): add error_page config
Browse files Browse the repository at this point in the history
  • Loading branch information
soopyc committed Sep 10, 2023
1 parent 26320f8 commit 64a840c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
home-manager,
...
} @ inputs: let
_utils = import ./global/utils.nix {};
utils = import ./global/utils.nix;
lib = nixpkgs.lib;

systems = [
Expand All @@ -61,7 +61,7 @@
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});
in {
nixosConfigurations = {
koumakan = import ./systems/koumakan {inherit _utils lib inputs;};
koumakan = import ./systems/koumakan {inherit utils lib inputs;};
};

devShells = forAllSystems (pkgs: {
Expand Down
29 changes: 22 additions & 7 deletions global/utils.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
# see /docs/utils.md for a usage guide
{...}:
# let
# lib = pkgs.lib;
# in
rec {
mkVhost = opts:
{
inputs,
system,
...
}: rec {
mkVhost = {extraConfig ? "", ...} @ opts:
{
# ideally mkOverride/mkDefault would be used, but i have 0 idea how it works.
forceSSL = true;
useACMEHost = "global.c.soopy.moe";
kTLS = true;
}
// opts;
// opts
// {
# we do some funny things here
locations =
opts.locations
// {
"/_cgi/error/" = {alias = "${inputs.mystia.packages.${system}.staticly}/nginx_error_pages/";};
};
extraConfig =
''
error_page 503 /_cgi/error/503.html;
error_page 502 /_cgi/error/502.html;
error_page 404 /_cgi/error/404.html;
''
+ extraConfig;
};

mkSimpleProxy = {
port,
Expand Down
8 changes: 6 additions & 2 deletions systems/koumakan/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
lib,
_utils,
utils,
inputs,
...
}:
Expand All @@ -10,7 +10,11 @@ lib.nixosSystem {
# see docs/tips_n_tricks.md#extra_opts for syntax
# see docs/utils.md for functions
specialArgs = {
inherit inputs _utils;
inherit inputs;
_utils = utils {
inherit inputs;
system = "x86_64-linux";
};
};

modules = [
Expand Down

0 comments on commit 64a840c

Please sign in to comment.