serve static files with exts

This commit is contained in:
Ivan Kirilov Dimitrov 2024-07-31 12:31:08 +02:00
parent f7c30d7627
commit 070b86b15b
No known key found for this signature in database
GPG Key ID: 0BDAD4B211C49294
3 changed files with 35 additions and 633 deletions

View File

@ -19,30 +19,6 @@
"devshell": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717408969,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=",
"owner": "numtide",
"repo": "devshell",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"devshell_2": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": [
"webshite",
"ide",
@ -97,20 +73,6 @@
}
},
"flake-compat_3": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1696426674,
@ -126,6 +88,20 @@
"type": "github"
}
},
"flake-compat_4": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_5": {
"flake": false,
"locked": {
@ -142,72 +118,10 @@
"type": "github"
}
},
"flake-compat_6": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_7": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_8": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_9": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"pic",
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
@ -230,7 +144,7 @@
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"pic",
"webshite",
"ide",
"neovim-nightly-overlay",
"hercules-ci-effects",
@ -251,75 +165,6 @@
}
},
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717285511,
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_4": {
"inputs": {
"nixpkgs-lib": [
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1717285511,
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_5": {
"inputs": {
"nixpkgs-lib": [
"webshite",
"ide",
"neovim-nightly-overlay",
"hercules-ci-effects",
"nixpkgs"
]
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"flake-parts_6": {
"inputs": {
"nixpkgs-lib": [
"webshite",
@ -345,7 +190,7 @@
"flake-utils": {
"inputs": {
"systems": [
"pic",
"webshite",
"ide",
"systems"
]
@ -382,80 +227,18 @@
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": [
"webshite",
"ide",
"systems"
]
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fnx": {
"inputs": {
"nixpkgs": [
"pic",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1720333712,
"narHash": "sha256-qZmpIPUe4mwdBGmKPBJ5KzvXH6GOCXheiusTAgNjAAA=",
"owner": "nix-community",
"repo": "fenix",
"rev": "b78c98c53a46e2a2d6479a920f98aa0aeae56281",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-compat": "flake-compat_3",
"gitignore": "gitignore",
"nixpkgs": [
"pic",
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
],
"nixpkgs-stable": [
"pic",
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
@ -477,70 +260,8 @@
},
"git-hooks_2": {
"inputs": {
"flake-compat": "flake-compat_4",
"flake-compat": "flake-compat_5",
"gitignore": "gitignore_2",
"nixpkgs": [
"pic",
"ide",
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718879355,
"narHash": "sha256-RTyqP4fBX2MdhNuMP+fnR3lIwbdtXhyj7w7fwtvgspc=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "8cd35b9496d21a6c55164d8547d9d5280162b07a",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"git-hooks_3": {
"inputs": {
"flake-compat": "flake-compat_7",
"gitignore": "gitignore_3",
"nixpkgs": [
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
],
"nixpkgs-stable": [
"webshite",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718879355,
"narHash": "sha256-RTyqP4fBX2MdhNuMP+fnR3lIwbdtXhyj7w7fwtvgspc=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "8cd35b9496d21a6c55164d8547d9d5280162b07a",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"git-hooks_4": {
"inputs": {
"flake-compat": "flake-compat_9",
"gitignore": "gitignore_4",
"nixpkgs": [
"webshite",
"ide",
@ -569,54 +290,6 @@
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pic",
"ide",
"neovim-nightly-overlay",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gitignore_2": {
"inputs": {
"nixpkgs": [
"pic",
"ide",
"nixvim",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gitignore_3": {
"inputs": {
"nixpkgs": [
"webshite",
@ -640,7 +313,7 @@
"type": "github"
}
},
"gitignore_4": {
"gitignore_2": {
"inputs": {
"nixpkgs": [
"webshite",
@ -667,30 +340,6 @@
"hercules-ci-effects": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": [
"pic",
"ide",
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718018037,
"narHash": "sha256-03rLBd/lKecgaKz0j5ESUf9lDn5R0SJatZTKLL5unWE=",
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"rev": "0ab08b23ce3c3f75fe9a5598756b6fb8bcf0b414",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"type": "github"
}
},
"hercules-ci-effects_2": {
"inputs": {
"flake-parts": "flake-parts_5",
"nixpkgs": [
"webshite",
"ide",
@ -713,29 +362,6 @@
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1719037157,
"narHash": "sha256-aOKd8+mhBsLQChCu1mn/W5ww79ta5cXVE59aJFrifM8=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "cd886711998fe5d9ff7979fdd4b4cbd17b1f1511",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"webshite",
@ -783,37 +409,12 @@
"flake-utils": "flake-utils",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": [
"pic",
"webshite",
"nixpkgs"
],
"nixvim": "nixvim",
"systems": "systems_2"
},
"locked": {
"lastModified": 1720081265,
"narHash": "sha256-MQjLb0AhXlJM5icYj9KJ+FYV/dDGiGKvPQIGcDuceiM=",
"owner": "ivandimitrov8080",
"repo": "flake-ide",
"rev": "ede87ccb5225e562efb1be4c68b645c3b2c7dca6",
"type": "github"
},
"original": {
"owner": "ivandimitrov8080",
"repo": "flake-ide",
"type": "github"
}
},
"ide_2": {
"inputs": {
"flake-utils": "flake-utils_3",
"neovim-nightly-overlay": "neovim-nightly-overlay_2",
"nixpkgs": [
"webshite",
"nixpkgs"
],
"nixvim": "nixvim_2",
"systems": "systems_4"
},
"locked": {
"lastModified": 1720387774,
"narHash": "sha256-vbdLOPW2s5HZ/aRJl2GtcL1d4racetoPRn6W7dGVl+E=",
@ -830,38 +431,11 @@
},
"neovim-nightly-overlay": {
"inputs": {
"flake-compat": "flake-compat",
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"hercules-ci-effects": "hercules-ci-effects",
"neovim-src": "neovim-src",
"nixpkgs": [
"pic",
"ide",
"nixpkgs"
]
},
"locked": {
"lastModified": 1719211247,
"narHash": "sha256-GaEckCf2RaHzoEDj/j07BIV6eyDOT5wCFVSdbbkZ87U=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "820da0e6b6127df9ad05ef3af40d767577e21ba1",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"type": "github"
}
},
"neovim-nightly-overlay_2": {
"inputs": {
"flake-compat": "flake-compat_6",
"flake-parts": "flake-parts_4",
"git-hooks": "git-hooks_3",
"hercules-ci-effects": "hercules-ci-effects_2",
"neovim-src": "neovim-src_2",
"nixpkgs": [
"webshite",
"ide",
@ -898,46 +472,7 @@
"type": "github"
}
},
"neovim-src_2": {
"flake": false,
"locked": {
"lastModified": 1719138008,
"narHash": "sha256-+rM0RjvuW6/vzxdJxEU6KvQEF159NXrgB+irtS044Cc=",
"owner": "neovim",
"repo": "neovim",
"rev": "be999e6a0e5b251b2b37500d06636d4167334c6e",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "neovim",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1719128254,
"narHash": "sha256-I7jMpq0CAOZA/i70+HDQO/ulLttyQu/K70cSESiMX7A=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "50581970f37f06a4719001735828519925ef8310",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-darwin_2": {
"inputs": {
"nixpkgs": [
"webshite",
@ -994,13 +529,13 @@
"nixvim": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat_3",
"flake-compat": "flake-compat_4",
"flake-parts": "flake-parts_3",
"git-hooks": "git-hooks_2",
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": [
"pic",
"webshite",
"ide",
"nixpkgs"
],
@ -1020,88 +555,19 @@
"type": "github"
}
},
"nixvim_2": {
"inputs": {
"devshell": "devshell_2",
"flake-compat": "flake-compat_8",
"flake-parts": "flake-parts_6",
"git-hooks": "git-hooks_4",
"home-manager": "home-manager_2",
"nix-darwin": "nix-darwin_2",
"nixpkgs": [
"webshite",
"ide",
"nixpkgs"
],
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
"lastModified": 1719228487,
"narHash": "sha256-eJUcZAjOcGAoh97ZRsy+ls8IkHPMpDuh0IpRKSmoWs4=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "66c8592b31845cb0a1335ecc31ea40e89bed1a38",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"pic": {
"inputs": {
"fnx": "fnx",
"ide": "ide",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1720370679,
"narHash": "sha256-Ac3Pi3GUl0d2zf+//acge7p4mZEYq/CzpkH5nvVSvyQ=",
"owner": "ivandimitrov8080",
"repo": "pic.idimitrov.dev",
"rev": "a8a6c47be00f2c62640e6bd7302478bff252e579",
"type": "github"
},
"original": {
"owner": "ivandimitrov8080",
"repo": "pic.idimitrov.dev",
"type": "github"
}
},
"root": {
"inputs": {
"hosts": "hosts",
"nixpkgs": "nixpkgs",
"pic": "pic",
"simple-nixos-mailserver": "simple-nixos-mailserver",
"vpsadminos": "vpsadminos",
"webshite": "webshite"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1720292183,
"narHash": "sha256-CPcdVpsgmNXYVsw4nKPrM23J5mYXtiotYMz2BjPDIKU=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "058c88da66797eb588b47a4aac3e42847d1333d7",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"simple-nixos-mailserver": {
"inputs": {
"blobs": "blobs",
"flake-compat": "flake-compat_5",
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
],
@ -1151,60 +617,7 @@
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1680978846,
"narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
"owner": "nix-systems",
"repo": "x86_64-linux",
"rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "x86_64-linux",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"pic",
"ide",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1718522839,
"narHash": "sha256-ULzoKzEaBOiLRtjeY3YoGFJMwWSKRYOic6VNw2UyTls=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "68eb1dc333ce82d0ab0c0357363ea17c31ea1f81",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"treefmt-nix_2": {
"inputs": {
"nixpkgs": [
"webshite",
@ -1244,7 +657,7 @@
},
"webshite": {
"inputs": {
"ide": "ide_2",
"ide": "ide",
"nixpkgs": [
"nixpkgs"
]

View File

@ -5,7 +5,6 @@
simple-nixos-mailserver = { url = "gitlab:simple-nixos-mailserver/nixos-mailserver"; inputs.nixpkgs.follows = "nixpkgs"; };
hosts = { url = "github:StevenBlack/hosts"; inputs.nixpkgs.follows = "nixpkgs"; };
webshite = { url = "github:ivandimitrov8080/idimitrov.dev"; inputs.nixpkgs.follows = "nixpkgs"; };
pic = { url = "github:ivandimitrov8080/pic.idimitrov.dev"; inputs.nixpkgs.follows = "nixpkgs"; };
};
outputs =
@ -14,7 +13,6 @@
, simple-nixos-mailserver
, hosts
, webshite
, pic
, ...
}:
let
@ -22,13 +20,7 @@
myOverlay = final: prev: {
scripts = (final.buildEnv { name = "scripts"; paths = [ ./. ]; });
webshite = webshite.packages.${system}.default;
pic = pic.packages.${system}.default.overrideAttrs (prev: {
env = {
FILEPATH = "/var/pic";
};
});
};
in
{
nixosConfigurations = {

View File

@ -12,6 +12,10 @@ let
allow 10.0.0.4/32;
deny all;
'';
extensions = [ "html" "txt" "png" "jpg" "jpeg" ];
serveStatic = exts: ''
try_files $uri $uri/ ${pkgs.lib.strings.concatStringsSep " " (builtins.map (x: "$uri." + "${x}") exts)} =404;
'';
in
{
services = {
@ -28,9 +32,7 @@ in
forceSSL = true;
locations."/" = {
root = "${pkgs.webshite}";
extraConfig = ''
try_files $uri $uri/ $uri.html $uri.txt =404;
'';
extraConfig = serveStatic extensions;
};
extraConfig = webshiteConfig;
};
@ -39,9 +41,7 @@ in
forceSSL = true;
locations."/" = {
root = "${pkgs.webshite}";
extraConfig = ''
try_files $uri $uri/ $uri.html $uri.txt =404;
'';
extraConfig = serveStatic extensions;
};
extraConfig = webshiteConfig;
};
@ -62,14 +62,11 @@ in
root = "/var/pic";
extraConfig = ''
autoindex on;
${serveStatic ["png"]}
'';
};
locations."/*.png" = {
proxyPass = "http://127.0.0.1:8000";
};
};
};
};
};
}