From 7042c8b56d851be4bdcf27e4160a1e2dfb30874b Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 5 May 2022 18:01:37 +0900 Subject: Enable user (web) directories --- configuration.nix | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'configuration.nix') diff --git a/configuration.nix b/configuration.nix index 46bebac..91d8904 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,14 +1,26 @@ -{ config, pkgs, ... }: -{ +{ config, lib, pkgs, ... }: +let + domain = "loang.net"; +in { environment = { enableAllTerminfo = true; - systemPackages = with pkgs; [ git vim ]; + systemPackages = with pkgs; [ git rsync vim ]; + }; + + fileSystems = lib.mapAttrs' (user: dir: { + name = "/var/www/${domain}/~${user}"; + value = { + device = "${config.users.users.${user}.home}/${dir}"; + options = [ "bind" ]; + }; + }) { + cnx = "www"; }; imports = [ ./vpsadminos.nix ]; networking = { - domain = "loang.net"; + domain = domain; firewall = { allowedTCPPorts = [ @@ -41,19 +53,10 @@ services = { nginx = { enable = true; - virtualHosts = let - users = config.users.users; - in { - "loang.net" = { - enableACME = true; - forceSSL = true; - root = "/var/www/loang.net"; - }; - "cnx.loang.net" = { - enableACME = true; - forceSSL = true; - root = "${users.cnx.home}/web"; - }; + virtualHosts.${domain} = { + enableACME = true; + forceSSL = true; + root = "/var/www/${domain}"; }; }; -- cgit 1.4.1