nixos/nginx: add build time syntax validation#474858
Open
gepbird wants to merge 3 commits intoNixOS:masterfrom
Open
nixos/nginx: add build time syntax validation#474858gepbird wants to merge 3 commits intoNixOS:masterfrom
gepbird wants to merge 3 commits intoNixOS:masterfrom
Conversation
b8800be to
2f6b529
Compare
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Dec 29, 2025
Flake lock file updates:
• Added input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Dec 29, 2025
Flake lock file updates:
• Added input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
2f6b529 to
346f915
Compare
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Dec 31, 2025
Flake lock file updates:
• Updated input 'gep-dotfiles':
'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=1d6fd8b5f42aaf08c29f5d2448f8b11270911c1d' (2025-12-26)
→ 'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=b76c0c3a0f2433a32d4d3279b0b8ef0afbfe3827' (2025-12-29)
• Removed input 'gep-dotfiles/nixpkgs-patch-nixos-ente-auth-init'
• Updated input 'home-manager':
'github:nix-community/home-manager/3613abcbd7cf373a59b7f582260ca6b7bd703eaf' (2025-12-28)
→ 'github:nix-community/home-manager/e4e78a2cbeaddd07ab7238971b16468cc1d14daf' (2025-12-30)
• Updated input 'nixos-hardware':
'github:NixOS/nixos-hardware/c5db9569ac9cc70929c268ac461f4003e3e5ca80' (2025-12-24)
→ 'github:NixOS/nixos-hardware/9b3c38bf6c260d0e88154ef07fa833fa845bfd14' (2025-12-30)
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/3e2499d5539c16d0d173ba53552a4ff8547f4539' (2025-12-25)
→ 'github:NixOS/nixpkgs/c0b0e0fddf73fd517c3471e546c0df87a42d53f4' (2025-12-28)
• Updated input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
→ 'NixOS/nixpkgs#474858'
• Updated input 'nur':
'github:nix-community/NUR/d52c57e1439e4df5f0c733522798c97031a3c9ee' (2025-12-28)
→ 'github:nix-community/NUR/572a9dc34f5f0b6b2c460e92185d63c1fdbb8a9c' (2025-12-30)
• Updated input 'treefmt-nix':
'github:numtide/treefmt-nix/42d96e75aa56a3f70cab7e7dc4a32868db28e8fd' (2025-12-17)
→ 'github:numtide/treefmt-nix/dec15f37015ac2e774c84d0952d57fcdf169b54d' (2025-12-30)
346f915 to
dab92e7
Compare
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Jan 4, 2026
Flake lock file updates:
• Updated input 'gep-dotfiles':
'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=b76c0c3a0f2433a32d4d3279b0b8ef0afbfe3827' (2025-12-29)
→ 'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=ae28d5d6da1c3a1e880da578b2e3cfb2722710f2' (2026-01-04)
• Added input 'gep-dotfiles/nixpkgs-patch-grayjay-fix-build':
'NixOS/nixpkgs#475903'
• Added input 'gep-dotfiles/nixpkgs-patch-nvim-treesitter-legacy':
follows 'nixpkgs-patch-nvim-treesitter-legacy'
• Updated input 'gep-dotfiles/nvim-gep':
'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=5a0910846c385ba01566f8fddd64d2918188f33b' (2025-12-24)
→ 'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=c00a8b55a2608a200bbdbd4e7449f428fcf71966' (2026-01-03)
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly':
'github:nix-community/neovim-nightly-overlay/14a21b492d6acd79495b14c9d127a94b77c0b72c' (2025-12-24)
→ 'github:nix-community/neovim-nightly-overlay/519c66e44d81e2a752759d60320dbd6f06c14437' (2026-01-03)
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly/neovim-src':
'github:neovim/neovim/1aa26f5d55550dd12c2cfd0f74618f0dcd6467ec' (2025-12-23)
→ 'github:neovim/neovim/067b5743f543798f4e58003816fc930f4106c2b0' (2026-01-02)
• Added input 'gep-dotfiles/nvim-gep/nixpkgs-patch-nvim-treesitter-legacy':
follows 'gep-dotfiles/nixpkgs-patch-nvim-treesitter-legacy'
• Added input 'gep-dotfiles/nvim-gep/nixpkgs-patcher':
follows 'gep-dotfiles'
• Updated input 'gep-dotfiles/nvim-gep/nixvim':
'github:nix-community/nixvim/1787eeda5a2ce35bcd57dbb482718b0d897786ae' (2025-12-22)
→ 'github:nix-community/nixvim/d61584cc4cac9af1ba74ad235992df575391276d' (2026-01-02)
• Updated input 'gep-dotfiles/nvim-gep/nvim-treesitter-textobjects':
'github:nvim-treesitter/nvim-treesitter-textobjects/f7122acf1bd2c9e4626651ad33bf5944be9d9392' (2025-12-24)
→ 'github:nvim-treesitter/nvim-treesitter-textobjects/28a3494c075ef0f353314f627546537e43c09592' (2026-01-03)
• Updated input 'home-manager':
'github:nix-community/home-manager/e4e78a2cbeaddd07ab7238971b16468cc1d14daf' (2025-12-30)
→ 'github:nix-community/home-manager/1cfa305fba94468f665de1bd1b62dddf2e0cb012' (2026-01-03)
• Updated input 'nixos-hardware':
'github:NixOS/nixos-hardware/9b3c38bf6c260d0e88154ef07fa833fa845bfd14' (2025-12-30)
→ 'github:NixOS/nixos-hardware/40b1a28dce561bea34858287fbb23052c3ee63fe' (2025-12-31)
• Updated input 'nixos-raspberrypi':
'github:nvmd/nixos-raspberrypi/a12cce5710031c44e0e36b581d8e71bc4f157907' (2025-11-26)
→ 'github:nvmd/nixos-raspberrypi/f517fc39419afb6fbec31f9a44de7d41e3a9ad76' (2026-01-02)
• Updated input 'nixos-raspberrypi/flake-compat':
'github:edolstra/flake-compat/f387cd2afec9419c8ee37694406ca490c3f34ee5' (2025-10-27)
→ follows ''
• Updated input 'nixos-raspberrypi/nixpkgs':
'github:nvmd/nixpkgs/59714dfc31ef9b9d78c6d581f12169b6665767f8' (2025-11-25)
→ 'github:nvmd/nixpkgs/31926ce9afb1c915fa4190b77ca9be389ccaf18e' (2026-01-02)
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/c0b0e0fddf73fd517c3471e546c0df87a42d53f4' (2025-12-28)
→ 'github:NixOS/nixpkgs/fb7944c166a3b630f177938e478f0378e64ce108' (2026-01-02)
• Added input 'nixpkgs-patch-librechat-fix-build':
'NixOS/nixpkgs#476747'
• Removed input 'nixpkgs-patch-nixos-anubis-fix-eval-warning'
• Updated input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
→ 'NixOS/nixpkgs#474858'
• Added input 'nixpkgs-patch-nvim-treesitter-legacy':
'NixOS/nixpkgs#472119'
• Updated input 'nur':
'github:nix-community/NUR/572a9dc34f5f0b6b2c460e92185d63c1fdbb8a9c' (2025-12-30)
→ 'github:nix-community/NUR/ed59c24d452493c9c0d3d297c1b6c0412d353b4c' (2026-01-03)
• Updated input 'treefmt-nix':
'github:numtide/treefmt-nix/dec15f37015ac2e774c84d0952d57fcdf169b54d' (2025-12-30)
→ 'github:numtide/treefmt-nix/d56486eb9493ad9c4777c65932618e9c2d0468fc' (2026-01-03)
• Updated input 'ymstnt-dotfiles':
'github:ymstnt/dotfiles/eba522a10a47e00d9e6305a63b12f99e3b2f1175' (2025-12-26)
→ 'github:ymstnt/dotfiles/91c3cd11f9ac27dbd51a20637c5cb57838bcacd4' (2025-12-31)
It is a lightweight version of `-T` that only validates the syntax, skips testing modules, avoids creating a pidfile, etc. Impurities like inet host resolution (requires internet) and SSL certificate lookups (usually requires accessing /var/lib/acme/) are disabled with `-S`.
dab92e7 to
4307bff
Compare
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Mar 13, 2026
Flake lock file updates:
• Updated input 'gep-dotfiles':
'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=6c6a8ef57218740a6cb06a5036017e3f77227458' (2026-03-04)
→ 'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=c602cda507a4c3a24ca046c295d41ee8669864cb' (2026-03-12)
• Updated input 'gep-dotfiles/nix-index-database':
'github:nix-community/nix-index-database/a2051ff239ce2e8a0148fa7a152903d9a78e854f' (2026-03-01)
→ 'github:nix-community/nix-index-database/1c1d8ea87b047788fd7567adf531418c5da321ec' (2026-03-08)
• Updated input 'gep-dotfiles/nvim-gep':
'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=3c3c90b39c9a0c746bc8d103fdf925dcb27dede1' (2026-02-22)
→ 'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=0d0f4c406770943dbdce12c1bc888a667fdbdc10' (2026-03-12)
• Removed input 'gep-dotfiles/nvim-gep/blink-cmp-redraw-fix'
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly':
'github:nix-community/neovim-nightly-overlay/9ea828da7d7a4f21beb909a541a2da790031059c' (2026-02-22)
→ 'github:nix-community/neovim-nightly-overlay/f165d4768ca760f4c98b63286562b6fa79a8b114' (2026-03-12)
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly/neovim-src':
'github:neovim/neovim/940d5c239b088fe0e994a220b4d524ddb44760e9' (2026-02-21)
→ 'github:neovim/neovim/99a0b2f7b86d447af752ee7436dd5fd69fc6a101' (2026-03-11)
• Updated input 'gep-dotfiles/nvim-gep/nixvim':
'github:nix-community/nixvim/ed0424f0b08d303a7348f52f7850ad1b2704f9ba' (2026-02-15)
→ 'github:nix-community/nixvim/21ae25e13b01d3b4cdc750b5f9e7bad68b150c10' (2026-03-01)
• Updated input 'home-manager':
'github:nix-community/home-manager/5a75730e6f21ee624cbf86f4915c6e7489c74acc' (2026-03-04)
→ 'github:nix-community/home-manager/4aeef1941f862fe3a70d1b8264b4e289358c2325' (2026-03-12)
• Updated input 'moe':
'github:tchfoo/moe/9674c748f8e598adbc0af93d60a8539106f9b806' (2026-03-04)
→ 'github:tchfoo/moe/9142448ce48c968014bc543da2e4fbdf55788ed1' (2026-03-12)
• Updated input 'nixos-hardware':
'github:NixOS/nixos-hardware/41c6b421bdc301b2624486e11905c9af7b8ec68e' (2026-02-24)
→ 'github:NixOS/nixos-hardware/3966ce987e1a9a164205ac8259a5fe8a64528f72' (2026-03-08)
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/80bdc1e5ce51f56b19791b52b2901187931f5353' (2026-03-04)
→ 'github:NixOS/nixpkgs/62dc67aa6a52b4364dd75994ec00b51fbf474e50' (2026-03-10)
• Removed input 'nixpkgs-patch-nixos-librechat-add-meilisearch-support'
• Updated input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
→ 'NixOS/nixpkgs#474858'
• Removed input 'nixpkgs-patch-pocket-id-2-4-0'
• Updated input 'nixpkgs-patcher':
'github:gepbird/nixpkgs-patcher/69d83828fbd61d88eb494d08b2fb7da2c6e2d2fc' (2026-03-03)
→ 'github:gepbird/nixpkgs-patcher/f2908367abf8ed4b0fee691bb481bde0f8015fc4' (2026-03-06)
• Updated input 'nur':
'github:nix-community/NUR/5882037d8ba7e2265f40cd37f757329bcab14a08' (2026-03-05)
→ 'github:nix-community/NUR/e4a86a2faa20b9f3a25f2224a827946fde130977' (2026-03-12)
• Updated input 'sops-nix':
'github:Mic92/sops-nix/1d9b98a29a45abe9c4d3174bd36de9f28755e3ff' (2026-03-02)
→ 'github:Mic92/sops-nix/d1ff3b1034d5bab5d7d8086a7803c5a5968cd784' (2026-03-09)
• Updated input 'treefmt-nix':
'github:numtide/treefmt-nix/3710e0e1218041bbad640352a0440114b1e10428' (2026-03-04)
→ 'github:numtide/treefmt-nix/71b125cd05fbfd78cab3e070b73544abe24c5016' (2026-03-12)
• Updated input 'ymstnt-dotfiles':
'git+https://git.tchfoo.com/ymstnt/dotfiles?ref=refs/heads/main&rev=cf6351b209835f120ef7ab715a4b51920fea597e' (2026-03-04)
→ 'git+https://git.tchfoo.com/ymstnt/dotfiles?ref=refs/heads/main&rev=eb4b001ad4649088baecb6410ccb73e521bdeba9' (2026-03-10)
gepbird
added a commit
to tchfoo/raspi-dotfiles
that referenced
this pull request
Mar 13, 2026
Flake lock file updates:
• Updated input 'gep-dotfiles':
'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=6c6a8ef57218740a6cb06a5036017e3f77227458' (2026-03-04)
→ 'git+https://git.tchfoo.com/gepbird/dotfiles?ref=refs/heads/main&rev=c602cda507a4c3a24ca046c295d41ee8669864cb' (2026-03-12)
• Updated input 'gep-dotfiles/nix-index-database':
'github:nix-community/nix-index-database/a2051ff239ce2e8a0148fa7a152903d9a78e854f' (2026-03-01)
→ 'github:nix-community/nix-index-database/1c1d8ea87b047788fd7567adf531418c5da321ec' (2026-03-08)
• Updated input 'gep-dotfiles/nvim-gep':
'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=3c3c90b39c9a0c746bc8d103fdf925dcb27dede1' (2026-02-22)
→ 'git+https://git.tchfoo.com/gepbird/nvim?ref=refs/heads/main&rev=0d0f4c406770943dbdce12c1bc888a667fdbdc10' (2026-03-12)
• Removed input 'gep-dotfiles/nvim-gep/blink-cmp-redraw-fix'
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly':
'github:nix-community/neovim-nightly-overlay/9ea828da7d7a4f21beb909a541a2da790031059c' (2026-02-22)
→ 'github:nix-community/neovim-nightly-overlay/f165d4768ca760f4c98b63286562b6fa79a8b114' (2026-03-12)
• Updated input 'gep-dotfiles/nvim-gep/neovim-nightly/neovim-src':
'github:neovim/neovim/940d5c239b088fe0e994a220b4d524ddb44760e9' (2026-02-21)
→ 'github:neovim/neovim/99a0b2f7b86d447af752ee7436dd5fd69fc6a101' (2026-03-11)
• Updated input 'gep-dotfiles/nvim-gep/nixvim':
'github:nix-community/nixvim/ed0424f0b08d303a7348f52f7850ad1b2704f9ba' (2026-02-15)
→ 'github:nix-community/nixvim/21ae25e13b01d3b4cdc750b5f9e7bad68b150c10' (2026-03-01)
• Updated input 'home-manager':
'github:nix-community/home-manager/5a75730e6f21ee624cbf86f4915c6e7489c74acc' (2026-03-04)
→ 'github:nix-community/home-manager/be0c641a6a5564caa33982faa1fe2c60d92131c7' (2026-03-13)
• Updated input 'moe':
'github:tchfoo/moe/9674c748f8e598adbc0af93d60a8539106f9b806' (2026-03-04)
→ 'github:tchfoo/moe/9142448ce48c968014bc543da2e4fbdf55788ed1' (2026-03-12)
• Updated input 'nixos-hardware':
'github:NixOS/nixos-hardware/41c6b421bdc301b2624486e11905c9af7b8ec68e' (2026-02-24)
→ 'github:NixOS/nixos-hardware/3966ce987e1a9a164205ac8259a5fe8a64528f72' (2026-03-08)
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/80bdc1e5ce51f56b19791b52b2901187931f5353' (2026-03-04)
→ 'github:NixOS/nixpkgs/fe416aaedd397cacb33a610b33d60ff2b431b127' (2026-03-12)
• Removed input 'nixpkgs-patch-nixos-librechat-add-meilisearch-support'
• Updated input 'nixpkgs-patch-nixos-nginx-add-build-time-syntax-validation':
'NixOS/nixpkgs#474858'
→ 'NixOS/nixpkgs#474858'
• Removed input 'nixpkgs-patch-pocket-id-2-4-0'
• Updated input 'nixpkgs-patcher':
'github:gepbird/nixpkgs-patcher/69d83828fbd61d88eb494d08b2fb7da2c6e2d2fc' (2026-03-03)
→ 'github:gepbird/nixpkgs-patcher/f2908367abf8ed4b0fee691bb481bde0f8015fc4' (2026-03-06)
• Updated input 'nur':
'github:nix-community/NUR/5882037d8ba7e2265f40cd37f757329bcab14a08' (2026-03-05)
→ 'github:nix-community/NUR/9dbc79857dc2d1cb5acdc8a71df0902f966f9a2b' (2026-03-13)
• Updated input 'sops-nix':
'github:Mic92/sops-nix/1d9b98a29a45abe9c4d3174bd36de9f28755e3ff' (2026-03-02)
→ 'github:Mic92/sops-nix/d1ff3b1034d5bab5d7d8086a7803c5a5968cd784' (2026-03-09)
• Updated input 'treefmt-nix':
'github:numtide/treefmt-nix/3710e0e1218041bbad640352a0440114b1e10428' (2026-03-04)
→ 'github:numtide/treefmt-nix/71b125cd05fbfd78cab3e070b73544abe24c5016' (2026-03-12)
• Updated input 'ymstnt-dotfiles':
'git+https://git.tchfoo.com/ymstnt/dotfiles?ref=refs/heads/main&rev=cf6351b209835f120ef7ab715a4b51920fea597e' (2026-03-04)
→ 'git+https://git.tchfoo.com/ymstnt/dotfiles?ref=refs/heads/main&rev=eb4b001ad4649088baecb6410ccb73e521bdeba9' (2026-03-10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and summary
Simple mistakes like forgetting a
;when writing nginx configs can take down all your sites.This is because the
nginx -ttest command is being executed in thepreStartof the systemd service. Moving this check to build time avoids these accidental small down times.Fixes #35395.
Prior work
This has been attempted previously in #205561, but it caused some issues and was reverted in #209075.
The main issues were
nginx -tbeing impure: it tried to access the internet to resolve hosts, and tried to read SSL certificates on the disk, which are not available in the nix sandbox.(A
gixycheck was added in #57979, it makes the config fail to build if it finds security issues, but it doesn't detect syntax errors.)Implementation
To combat the previous issues, I created an nginx patch that adds a new
-Sflag, which behaves like-T, but is skips the impure checks.Testing
Manually tested this with our config which has
proxyPassoption with a remote domain that requires internet access to resolve, and of course we have SSL certificates. Syntax validation passes with the current config, and fails with eg. removing a;.I'd be happy to add automatic tests, but not sure what's the best approach. The problem is NixOS tests are for runtime asserts, some lib tests that I've met are eval time, what about build time assertions? Is a bash script (with eg. expect) next to the nginx NixOS test preferred, or converting the build time failure to eval time with IFD (I know it's disallowed for regular uses, not sure about tests)?
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.