diff options
| author | Franck Cuny <franck@fcuny.net> | 2025-07-14 08:56:53 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2025-07-14 08:56:53 -0700 |
| commit | c4afe667db7734f41de3fca9d1c18e309abcc1d8 (patch) | |
| tree | 3b3d88d4c7c38a1758d5313e8116181900b8e864 /src/fcuny.net/default.nix | |
| parent | create common network configuration for nixos (diff) | |
| download | infra-c4afe667db7734f41de3fca9d1c18e309abcc1d8.tar.gz | |
import my website under `src`
This does not import the history of the previous repository.
Diffstat (limited to '')
| -rw-r--r-- | src/fcuny.net/default.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/fcuny.net/default.nix b/src/fcuny.net/default.nix new file mode 100644 index 0000000..b34bfe0 --- /dev/null +++ b/src/fcuny.net/default.nix @@ -0,0 +1,67 @@ +{ + pkgs ? import <nixpkgs> { }, +}: + +let + pname = "fcuny-net"; + version = "0.1.0"; + + site = pkgs.stdenv.mkDerivation { + inherit pname version; + src = ./.; + + nativeBuildInputs = with pkgs; [ + lychee + zola + ]; + + buildPhase = '' + zola build + lychee docs/*.html + ''; + + installPhase = '' + mkdir -p $out + cp -r docs/* $out/ + ''; + }; + + # Development server + serve = pkgs.writeShellScriptBin "serve-fcuny-net" '' + cd src/fcuny.net + ${pkgs.zola}/bin/zola serve --interface 0.0.0.0 --port 1111 + ''; + + # Nginx configuration + nginxConfig = pkgs.writeText "fcuny-net.conf" '' + server { + listen 80; + server_name fcuny.net; + + root ${site}; + index index.html; + + location / { + try_files $uri $uri/ =404; + } + + # Optional: Add some basic security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # Cache static assets + location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + } + ''; + +in +{ + inherit site serve nginxConfig; + + # Make site the default output + default = site; +} |
