diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2022-01-28 22:57:11 +0100 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2023-11-10 22:00:12 +0100 |
commit | d4914b6d157ca82a478e76e44c1c7f530d43f587 (patch) | |
tree | 3cd1846cda51b3979da220e45093ba778f2de610 | |
parent | 3dc0248dbc70fdba6d1a668ed00b4678dfae098c (diff) |
home-assistant: allow symlinks in static folder
Home Assistant by default does not follow symlinks in its static folders, which doesn't mix well with serving anything from the nix store.
-rw-r--r-- | pkgs/servers/home-assistant/default.nix | 4 | ||||
-rw-r--r-- | pkgs/servers/home-assistant/patches/static-symlinks.patch | 37 |
2 files changed, 41 insertions, 0 deletions
diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 3fb3e244928ca..c782d36d87f2a 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -396,6 +396,10 @@ in python.pkgs.buildPythonApplication rec { # leave this in, so users don't have to constantly update their downstream patch handling patches = [ + # Follow symlinks in /var/lib/hass/www + ./patches/static-symlinks.patch + + # Patch path to ffmpeg binary (substituteAll { src = ./patches/ffmpeg-path.patch; ffmpeg = "${lib.getBin ffmpeg-headless}/bin/ffmpeg"; diff --git a/pkgs/servers/home-assistant/patches/static-symlinks.patch b/pkgs/servers/home-assistant/patches/static-symlinks.patch new file mode 100644 index 0000000000000..7784a60f6b2a2 --- /dev/null +++ b/pkgs/servers/home-assistant/patches/static-symlinks.patch @@ -0,0 +1,37 @@ +diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py +index 2ec991750f..9a937006ce 100644 +--- a/homeassistant/components/frontend/__init__.py ++++ b/homeassistant/components/frontend/__init__.py +@@ -383,7 +383,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + + local = hass.config.path("www") + if os.path.isdir(local): +- hass.http.register_static_path("/local", local, not is_dev) ++ hass.http.register_static_path("/local", local, not is_dev, follow_symlinks=True) + + # Can be removed in 2023 + hass.http.register_redirect("/config/server_control", "/developer-tools/yaml") +diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py +index 122b7b79ce..3cf2b7e0db 100644 +--- a/homeassistant/components/http/__init__.py ++++ b/homeassistant/components/http/__init__.py +@@ -411,16 +411,16 @@ class HomeAssistantHTTP: + ) + + def register_static_path( +- self, url_path: str, path: str, cache_headers: bool = True ++ self, url_path: str, path: str, cache_headers: bool = True, follow_symlinks: bool = False + ) -> None: + """Register a folder or file to serve as a static path.""" + if os.path.isdir(path): + if cache_headers: + resource: CachingStaticResource | web.StaticResource = ( +- CachingStaticResource(url_path, path) ++ CachingStaticResource(url_path, path, follow_symlinks=follow_symlinks) + ) + else: +- resource = web.StaticResource(url_path, path) ++ resource = web.StaticResource(url_path, path, follow_symlinks=follow_symlinks) + self.app.router.register_resource(resource) + self.app["allow_configured_cors"](resource) + return |