From 7879fc2febe19e1bccbf94f5e0572fc5420b38be Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Wed, 6 Sep 2023 11:20:33 +0300 Subject: [PATCH] Add nice server roles (not ready yet) --- README.md | 3 +++ machines/celerrime/default.nix | 22 ++++------------------ pkgs/ivabus-dev.nix | 2 +- roles/default.nix | 3 +++ roles/server/ivabus-dev.nix | 20 ++++++++++++++++++++ roles/server/nginx.nix | 17 +++++++++++++++++ 6 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 roles/server/ivabus-dev.nix create mode 100644 roles/server/nginx.nix diff --git a/README.md b/README.md index 7c455e0..f5f564a 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,9 @@ curl https://iva.bz/nix | sh ## TODO - Setup services (which I host) + - [x] ivabus.dev + - [ ] iva.bz + - [ ] ивабус.рф - Setup "secret" roles (I need them) - Setup router diff --git a/machines/celerrime/default.nix b/machines/celerrime/default.nix index 06ae464..7314d8d 100644 --- a/machines/celerrime/default.nix +++ b/machines/celerrime/default.nix @@ -27,6 +27,10 @@ in { torrent.enable = true; virtualisation.enable = false; yggdrasil-client.enable = true; + + server = { + ivabus-dev.enable = true; + }; }; networking.useDHCP = true; @@ -40,23 +44,5 @@ in { (retroarch.override { cores = with libretro; [ np2kai ];}) ]; - services.nginx = { - enable = true; - # Use recommended settings - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - - virtualHosts."ivabus.dev" = { - # i don't want to call package like this - root = pkgs.callPackage ../../pkgs/ivabus-dev.nix {}; - - extraConfig = '' - error_page 404 /404.html; - ''; - }; - }; - system.stateVersion = "23.05"; } diff --git a/pkgs/ivabus-dev.nix b/pkgs/ivabus-dev.nix index cb64157..a33725b 100644 --- a/pkgs/ivabus-dev.nix +++ b/pkgs/ivabus-dev.nix @@ -1,6 +1,6 @@ { pkgs ? import {}, bundlerEnv, ... }: let - version = "025b56be08da939ad016dcacfb833b8652d2848e"; + version = "130812885aee9f2e0a5f6a4b534a3b6b68431554"; repo = builtins.fetchGit { url = "https://github.com/ivabus/website"; rev = version; diff --git a/roles/default.nix b/roles/default.nix index 114a8c1..fede684 100644 --- a/roles/default.nix +++ b/roles/default.nix @@ -10,5 +10,8 @@ ./torrent.nix ./virtualisation.nix ./yggdrasil-client.nix + + ./server/nginx.nix + ./server/ivabus-dev.nix ]; } \ No newline at end of file diff --git a/roles/server/ivabus-dev.nix b/roles/server/ivabus-dev.nix new file mode 100644 index 0000000..1daba6c --- /dev/null +++ b/roles/server/ivabus-dev.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.roles.server.ivabus-dev; +in +{ + options.my.roles.server.ivabus-dev.enable = lib.mkEnableOption "Serve ivabus.dev"; + config = lib.mkIf (cfg.enable) { + my.roles.server.nginx.enable = true; + services.nginx = { + virtualHosts."ivabus.dev" = { + # i don't want to call package like this + root = pkgs.callPackage ../../pkgs/ivabus-dev.nix {}; + + extraConfig = '' + error_page 404 /404.html; + ''; + }; + }; + }; +} diff --git a/roles/server/nginx.nix b/roles/server/nginx.nix new file mode 100644 index 0000000..78d5042 --- /dev/null +++ b/roles/server/nginx.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.roles.server.nginx; +in +{ + # Don't call from machine setup, services will enable it automatically + options.my.roles.server.nginx.enable = lib.mkEnableOption "Initial nginx setup"; + config = lib.mkIf (cfg.enable) { + services.nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + }; + }; +} \ No newline at end of file