Skip to content

Commit 9f7456d

Browse files
nginx
1 parent 28cc8ea commit 9f7456d

File tree

7 files changed

+147
-390
lines changed

7 files changed

+147
-390
lines changed

hp/hp4/nginx.nix

Lines changed: 30 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,104 +9,54 @@
99
# https://github.com/nixinator/cardano-ops/blob/8a7be334a476a80829e17c8a0ca6ec374347a937/roles/explorer.nix#L313
1010
# grep ExecStartPre /etc/systemd/system/nginx.service
1111
services.nginx = {
12-
1312
enable = true;
14-
15-
# package = mkOption {
16-
# default = pkgs.nginxStable;
17-
1813
defaultHTTPListenPort = 8080;
19-
defaultSSLListenPort = 8443;
20-
21-
#openFirewall = true; # doesn't exist
22-
2314
statusPage = true;
2415

2516
recommendedProxySettings = true;
2617
recommendedTlsSettings = true;
27-
2818
recommendedZstdSettings = true;
2919
recommendedGzipSettings = true;
3020
recommendedOptimisation = true;
3121
recommendedBrotliSettings = true;
3222

33-
resolver = {
34-
addresses = [ "127.0.0.1" ]; # Point to local pdns-recursor
35-
# valid = "30s"; # Optional: Override DNS cache TTL
36-
# ipv6 = false; # Optional: Disable IPv6 lookups if desired
37-
};
38-
39-
# proxyCachePath = {
40-
# "main_cache" = {
41-
# # Path will be /var/cache/nginx/main_cache
42-
# levels = "1:2";
43-
# keysZoneName = "my_proxy_zone";
44-
# keysZoneSize = "10m";
45-
# maxSize = "10g";
46-
# inactive = "60m";
47-
# useTempPath = false;
48-
# };
49-
# };
50-
51-
eventsConfig = ''
52-
worker_connections 4096;
53-
'';
54-
55-
appendHttpConfig = ''
56-
proxy_cache_path /var/cache/nginx/main_cache levels=1:2 keys_zone=my_proxy_zone:10m max_size=10g inactive=60m use_temp_path=off;
57-
'';
58-
23+
# Minimal configuration for serving files
5924
virtualHosts."_" = {
60-
#listen = [{ addr = "0.0.0.0"; port = 3128; }];
61-
listen = [{ addr = "0.0.0.0"; port = 8080; }];
62-
63-
extraConfig = ''
64-
#resolver 127.0.0.1;
65-
66-
location / {
67-
proxy_http_version 1.1;
68-
proxy_pass $request_uri;
69-
#proxy_pass http://$host$uri$is_args$args;
70-
71-
proxy_set_header Host $host;
72-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
73-
proxy_set_header X-Real-IP $remote_addr;
74-
75-
proxy_cache my_proxy_zone;
76-
proxy_cache_key "$scheme$request_method$host$request_uri";
77-
proxy_cache_valid 200 302 10m;
78-
proxy_cache_valid 404 1m;
79-
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
80-
}
81-
'';
25+
serverName = "_";
26+
root = "/var/www/html";
27+
default = true;
28+
29+
locations."/" = {
30+
extraConfig = ''
31+
autoindex on;
32+
autoindex_exact_size on;
33+
autoindex_localtime on;
34+
#index index.html;
35+
'';
36+
};
37+
38+
locations."/nginx_status" = {
39+
extraConfig = ''
40+
stub_status on;
41+
access_log off;
42+
allow 127.0.0.1;
43+
allow ::1;
44+
allow 172.16.50.0/24;
45+
deny all;
46+
'';
47+
};
8248
};
8349
};
50+
51+
# Ensure the docRoot directory exists and has correct permissions
52+
systemd.tmpfiles.rules = [
53+
"d /var/www/html 0755 nginx nginx - -"
54+
];
55+
8456
# journalctl --follow --namespace nginx
8557

8658
systemd.services.nginx.serviceConfig.LogNamespace = "nginx";
8759

88-
# systemd.tmpfiles.rules = [
89-
# "d /var/cache/nginx 0700 nginx nginx - -"
90-
# "d /var/log/nginx 0755 nginx nginx - -"
91-
# ];
92-
systemd.tmpfiles.settings."nginx-dirs" = {
93-
"/var/cache/nginx"."d" = {
94-
mode = "0700";
95-
user = "nginx";
96-
group = "nginx";
97-
};
98-
"/var/log/nginx"."d" = {
99-
mode = "0755";
100-
user = "nginx";
101-
group = "nginx";
102-
};
103-
"/run/nginx"."d" = {
104-
mode = "0755";
105-
user = "nginx";
106-
group = "nginx";
107-
};
108-
};
109-
11060
services.prometheus.exporters.nginx = {
11161
enable = true;
11262
openFirewall = true;

laptops/t/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ update_oldm.:
5454
sudo nixos-rebuild switch
5555
#nix-shell -p vim
5656

57+
restart_display_manager:
58+
sudo systemctl restart display-manager.service
59+
5760
# end

laptops/t/configuration.nix

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Edit this configuration file to define what should be installed on
22
# your system. Help is available in the configuration.nix(5) man page
3-
# and in the NixOS manual (accessible by running nixos-help).
3+
# and in the NixOS manual (accessible by running 'nixos-help').
44

55
# sudo nixos-rebuild switch
66
# sudo nix-channel --update
@@ -46,7 +46,6 @@
4646
];
4747

4848
boot = {
49-
5049
loader.systemd-boot = {
5150
enable = true;
5251
consoleMode = "max";
@@ -63,8 +62,8 @@
6362

6463
# https://github.com/tolgaerok/nixos-2405-gnome/blob/main/core/boot/efi/efi.nix#L56C5-L56C21
6564
kernelParams = [
66-
#"nvidia-drm.modeset=1"
67-
#"nvidia-drm.fbdev=1"
65+
"nvidia-drm.modeset=1"
66+
"nvidia-drm.fbdev=1"
6867
# https://www.reddit.com/r/NixOS/comments/u5l3ya/cant_start_x_in_nixos/?rdt=56160
6968
#"nomodeset"
7069
];
@@ -78,50 +77,34 @@
7877
# https://nixos.org/manual/nixos/stable/options#opt-boot.binfmt.emulatedSystems
7978
binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ];
8079

81-
extraModulePackages = with config.boot.kernelPackages; [
82-
v4l2loopback
83-
#nvidia_x11
80+
extraModulePackages = [
81+
config.boot.kernelPackages.v4l2loopback
82+
pkgs.unstable.linuxPackages.nvidiaPackages.production
8483
];
8584

86-
# https://nixos.wiki/wiki/Libvirt#Nested_virtualization
87-
#extraModprobeConfig = "options kvm_intel nested=1";
88-
# https://gist.github.com/chrisheib/162c8cad466638f568f0fb7e5a6f4f6b#file-config_working-nix-L19
89-
extraModprobeConfig =
90-
"options nvidia "
91-
#""
92-
+ lib.concatStringsSep " " [
93-
# nvidia assume that by default your CPU does not support PAT,
94-
# but this is effectively never the case in 2023
95-
"NVreg_UsePageAttributeTable=1"
96-
# This is sometimes needed for ddc/ci support, see
97-
# https://www.ddcutil.com/nvidia/
98-
#
99-
# Current monitor does not support it, but this is useful for
100-
# the future
101-
"NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100"
102-
"options kvm_intel nested=1"
103-
# # https://nixos.wiki/wiki/OBS_Studio
104-
''
105-
options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1
106-
''
107-
];
85+
extraModprobeConfig = ''
86+
options nvidia NVreg_UsePageAttributeTable=1
87+
options nvidia NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100
88+
options kvm_intel nested=1
89+
options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1
90+
'';
10891
};
10992

11093
# For OBS
11194
security.polkit.enable = true;
11295

11396
nix = {
114-
gc = {
115-
automatic = true; # Enable automatic execution of the task
116-
dates = "weekly"; # Schedule the task to run weekly
117-
options = "--delete-older-than 10d"; # Specify options for the task: delete files older than 10 days
118-
randomizedDelaySec = "14m"; # Introduce a randomized delay of up to 14 minutes before executing the task
119-
};
12097
settings = {
12198
auto-optimise-store = true;
12299
experimental-features = [ "nix-command" "flakes" ];
123100
download-buffer-size = "500000000";
124101
};
102+
gc = {
103+
automatic = true; # Enable automatic execution of the task
104+
dates = "daily"; # Schedule the task to run daily
105+
options = "--delete-older-than 10d"; # Specify options for the task: delete files older than 10 days
106+
randomizedDelaySec = "14m"; # Introduce a randomized delay of up to 14 minutes before executing the task
107+
};
125108
};
126109

127110
# https://nixos.wiki/wiki/Networking
@@ -280,7 +263,7 @@
280263

281264
# This value determines the NixOS release from which the default
282265
# settings for stateful data, like file locations and database versions
283-
# on your system were taken. Its perfectly fine and recommended to leave
266+
# on your system were taken. It's perfectly fine and recommended to leave
284267
# this value at the release version of the first install of this system.
285268
# Before changing this value read the documentation for this option
286269
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
@@ -290,10 +273,20 @@
290273

291274
nixpkgs.config = {
292275
allowUnfree = true;
293-
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
294-
"nvidia-x11"
295-
"nvidia-settings"
296-
"nvidia-persistenced"
297-
];
276+
# allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
277+
# "nvidia-x11"
278+
# "nvidia-settings"
279+
# "nvidia-persistenced"
280+
# ];
298281
};
282+
283+
# hardware.opengl = {
284+
# enable = true;
285+
# driSupport = true;
286+
# driSupport32Bit = true;
287+
# extraPackages = with pkgs; [
288+
# vaapiVdpau
289+
# libvdpau-va-gl
290+
# ];
291+
# };
299292
}

0 commit comments

Comments
 (0)