diff --git a/flake.lock b/flake.lock index 2e96fb6..dab8d99 100644 --- a/flake.lock +++ b/flake.lock @@ -75,11 +75,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1665613119, - "narHash": "sha256-VTutbv5YKeBGWou6ladtgfx11h6et+Wlkdyh4jPJ3p0=", + "lastModified": 1665132027, + "narHash": "sha256-zoHPqSQSENt96zTk6Mt1AP+dMNqQDshXKQ4I6MfjP80=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e06bd4b64bbfda91d74f13cb5eca89485d47528f", + "rev": "9ecc270f02b09b2f6a76b98488554dd842797357", "type": "github" }, "original": { @@ -90,11 +90,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1665643254, - "narHash": "sha256-IBVWNJxGCsshwh62eRfR6+ry3bSXmulB3VQRzLQo3hk=", + "lastModified": 1665259268, + "narHash": "sha256-ONFhHBLv5nZKhwV/F2GOH16197PbvpyWhoO0AOyktkU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ba187fbdc5e35322c7dff556ef2c47bddfd6e8d7", + "rev": "c5924154f000e6306030300592f4282949b2db6c", "type": "github" }, "original": { diff --git a/systems/LoutreOS/services.nix b/systems/LoutreOS/services.nix index bab9d54..376fb3a 100644 --- a/systems/LoutreOS/services.nix +++ b/systems/LoutreOS/services.nix @@ -174,35 +174,31 @@ in home-assistant = { enable = true; - extraComponents = [ - # Components required to complete the onboarding - "met" - "radio_browser" - ]; config = { - default_config = {}; homeassistant = { - latitude = 48.60038; - longitude = 7.74063; - elevation = 146; + elevation = 143; }; - meteo_france = null; - #influxdb = null; - #config = null; - #dhcp = null; - #frontend = null; - #history = null; + influxdb = null; + config = null; + dhcp = null; + frontend = null; + history = null; http = { use_x_forwarded_for = true; trusted_proxies = [ "127.0.0.1" ]; }; - #logbook = null; - #map = null; - #mobile_app = null; - #person = null; - #script = null; - #sun = null; - #system_health = null; + logbook = null; + map = null; + mobile_app = null; + person = null; + script = null; + sun = null; + system_health = null; + yeelight.devices = { + "10.40.249.0".name = "Chambre"; + "10.40.249.1".name = "Bureau"; + "10.40.249.2".name = "Cuisine"; + }; zha = null; esphome = null; light = [ @@ -210,9 +206,8 @@ in platform = "group"; name = "Salon"; entities = [ - "light.ikea_of_sweden_tradfri_bulb_e27_cws_806lm_e69e6dfe_level_light_color_on_off" - "light.ikea_of_sweden_tradfri_bulb_e27_cws_806lm_43c25efe_level_light_color_on_off" - "light.ikea_of_sweden_tradfri_bulb_e27_cws_806lm_3d0f76fe_level_light_color_on_off" + "light.bureau" + "light.cuisine" ]; } ]; @@ -222,317 +217,317 @@ in host = "10.30.0.1"; } ]; - #tplink.switch = [ - # { host = "10.30.50.7"; } - #]; - #sensor = [ - # { - # platform = "template"; - # sensors = { - # serveur_amps = { - # friendly_name_template = "{{ states.switch.serveur.name}} Current"; - # value_template = ''{{ states.switch.serveur.attributes["current_a"] | float }}''; - # unit_of_measurement = "A"; - # }; - # serveur_watts = { - # friendly_name_template = "{{ states.switch.serveur.name}} Current Consumption"; - # value_template = ''{{ states.switch.serveur.attributes["current_power_w"] | float }}''; - # unit_of_measurement = "W"; - # }; - # serveur_total_kwh = { - # friendly_name_template = "{{ states.switch.serveur.name}} Total Consumption"; - # value_template = ''{{ states.switch.serveur.attributes["total_energy_kwh"] | float }}''; - # unit_of_measurement = "kWh"; - # }; - # serveur_volts = { - # friendly_name_template = "{{ states.switch.serveur.name}} Voltage"; - # value_template = ''{{ states.switch.serveur.attributes["voltage"] | float }}''; - # unit_of_measurement = "V"; - # }; - # serveur_today_kwh = { - # friendly_name_template = "{{ states.switch.serveur.name}} Today's Consumption"; - # value_template = ''{{ states.switch.serveur.attributes["today_energy_kwh"] | float }}''; - # unit_of_measurement = "kWh"; - # }; - # }; - # } - #]; - #switch = [ - # { - # platform = "wake_on_lan"; - # name = "PC Fixe"; - # mac = "b4:2e:99:ed:24:26"; - # host = "10.30.135.71"; - # broadcast_address = "10.30.255.255"; - # } - #]; - #device_tracker = [ - # { - # platform = "ping"; - # hosts = { telephone_paul = "10.30.50.2"; }; - # } - #]; - #scene = [ - # { - # name = "Movie"; - # icon = "mdi:movie-open"; - # entities = { - # "light.salon" = { - # state = "on"; - # xy_color = [0.299 0.115]; - # brightness = 50; - # }; - # "light.bande_led_tv" = { - # state = "on"; - # effect = "Movie"; - # brightness = 180; - # }; - # "light.bande_led_bureau" = { - # state = "on"; - # xy_color = [0.299 0.115]; - # brightness = 130; - # }; - # }; - # } - # { - # name = "Home"; - # icon = "mdi:home"; - # entities = { - # "light.salon" = { - # state = "on"; - # kelvin = 2700; - # brightness = 255; - # }; - # }; - # } - # { - # name = "Night"; - # icon = "mdi:weather-night"; - # entities = { - # "light.salon" = { - # state = "off"; - # }; - # "light.bande_led_tv" = { - # state = "off"; - # }; - # "light.bande_led_bureau" = { - # state = "off"; - # }; - # "light.chambre" = { - # state = "on"; - # kelvin = 1900; - # brightness = 50; - # }; - # }; - # } - #]; - #automation = let - # min_sun_elevation = 4; + tplink.switch = [ + { host = "10.30.50.7"; } + ]; + sensor = [ + { + platform = "template"; + sensors = { + serveur_amps = { + friendly_name_template = "{{ states.switch.serveur.name}} Current"; + value_template = ''{{ states.switch.serveur.attributes["current_a"] | float }}''; + unit_of_measurement = "A"; + }; + serveur_watts = { + friendly_name_template = "{{ states.switch.serveur.name}} Current Consumption"; + value_template = ''{{ states.switch.serveur.attributes["current_power_w"] | float }}''; + unit_of_measurement = "W"; + }; + serveur_total_kwh = { + friendly_name_template = "{{ states.switch.serveur.name}} Total Consumption"; + value_template = ''{{ states.switch.serveur.attributes["total_energy_kwh"] | float }}''; + unit_of_measurement = "kWh"; + }; + serveur_volts = { + friendly_name_template = "{{ states.switch.serveur.name}} Voltage"; + value_template = ''{{ states.switch.serveur.attributes["voltage"] | float }}''; + unit_of_measurement = "V"; + }; + serveur_today_kwh = { + friendly_name_template = "{{ states.switch.serveur.name}} Today's Consumption"; + value_template = ''{{ states.switch.serveur.attributes["today_energy_kwh"] | float }}''; + unit_of_measurement = "kWh"; + }; + }; + } + ]; + switch = [ + { + platform = "wake_on_lan"; + name = "PC Fixe"; + mac = "b4:2e:99:ed:24:26"; + host = "10.30.135.71"; + broadcast_address = "10.30.255.255"; + } + ]; + device_tracker = [ + { + platform = "ping"; + hosts = { telephone_paul = "10.30.50.2"; }; + } + ]; + scene = [ + { + name = "Movie"; + icon = "mdi:movie-open"; + entities = { + "light.salon" = { + state = "on"; + xy_color = [0.299 0.115]; + brightness = 50; + }; + "light.bande_led_tv" = { + state = "on"; + effect = "Movie"; + brightness = 180; + }; + "light.bande_led_bureau" = { + state = "on"; + xy_color = [0.299 0.115]; + brightness = 130; + }; + }; + } + { + name = "Home"; + icon = "mdi:home"; + entities = { + "light.salon" = { + state = "on"; + kelvin = 2700; + brightness = 255; + }; + }; + } + { + name = "Night"; + icon = "mdi:weather-night"; + entities = { + "light.salon" = { + state = "off"; + }; + "light.bande_led_tv" = { + state = "off"; + }; + "light.bande_led_bureau" = { + state = "off"; + }; + "light.chambre" = { + state = "on"; + kelvin = 1900; + brightness = 50; + }; + }; + } + ]; + automation = let + min_sun_elevation = 4; - # switch_chambre = { - # domain = "zha"; - # platform = "device"; - # device_id = "3329ecdcad244e5e8fc0f4b96d52ffe1"; - # }; + switch_chambre = { + domain = "zha"; + platform = "device"; + device_id = "3329ecdcad244e5e8fc0f4b96d52ffe1"; + }; - # switch_entree = { - # domain = "zha"; - # platform = "device"; - # device_id = "7cd814190ec543dba76a7aa7e7996c41"; - # }; + switch_entree = { + domain = "zha"; + platform = "device"; + device_id = "7cd814190ec543dba76a7aa7e7996c41"; + }; - # remote = { - # domain = "zha"; - # platform = "device"; - # device_id = "d1230b76264e483388a8fdaad4f44143"; - # }; - #in [ - # # ENTREE + remote = { + domain = "zha"; + platform = "device"; + device_id = "d1230b76264e483388a8fdaad4f44143"; + }; + in [ + # ENTREE - # { - # alias = "Aziz lumière"; - # trigger = [ - # { - # platform = "numeric_state"; - # entity_id = "sun.sun"; - # value_template = "{{ state.attributes.elevation }}"; - # below = min_sun_elevation; - # } - # ]; - # condition = [ - # { - # condition = "state"; - # entity_id = "person.paul"; - # state = "home"; - # } - # # Sun below max elevation - # { - # condition = "template"; - # value_template = "{{ state_attr('sun.sun', 'elevation') < ${toString min_sun_elevation} }}"; - # } - # ]; - # action = { - # scene = "scene.home"; - # }; - # } - # { - # alias = "Aziz lumière switch"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "turn_on"; - # } // switch_entree; - # action = { - # scene = "scene.home"; - # }; - # } - # { - # alias = "Adios"; - # trigger = [ - # { - # platform = "state"; - # entity_id = "person.paul"; - # to = "not_home"; - # } - # ({ - # type = "remote_button_short_press"; - # subtype = "turn_off"; - # } // switch_entree) - # ]; - # action = [ - # { - # service = "light.turn_off"; - # entity_id = "all"; - # } - # { - # service = "media_player.turn_off"; - # entity_id = "all"; - # } - # ]; - # } + { + alias = "Aziz lumière"; + trigger = [ + { + platform = "numeric_state"; + entity_id = "sun.sun"; + value_template = "{{ state.attributes.elevation }}"; + below = min_sun_elevation; + } + ]; + condition = [ + { + condition = "state"; + entity_id = "person.paul"; + state = "home"; + } + # Sun below max elevation + { + condition = "template"; + value_template = "{{ state_attr('sun.sun', 'elevation') < ${toString min_sun_elevation} }}"; + } + ]; + action = { + scene = "scene.home"; + }; + } + { + alias = "Aziz lumière switch"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_on"; + } // switch_entree; + action = { + scene = "scene.home"; + }; + } + { + alias = "Adios"; + trigger = [ + { + platform = "state"; + entity_id = "person.paul"; + to = "not_home"; + } + ({ + type = "remote_button_short_press"; + subtype = "turn_off"; + } // switch_entree) + ]; + action = [ + { + service = "light.turn_off"; + entity_id = "all"; + } + { + service = "media_player.turn_off"; + entity_id = "all"; + } + ]; + } - # # REMOTE + # REMOTE - # { - # alias = "Button toggle"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "turn_on"; - # } // remote; - # action = { - # choose = { - # conditions = { - # condition = "template"; - # value_template = '' - # {% set domain = 'light' %} - # {% set state = 'off' %} - # {{ states[domain] | count == states[domain] | selectattr('state','eq',state) | list | count }} - # ''; - # }; - # sequence = { - # scene = "scene.home"; - # }; - # }; - # default = { - # service = "light.turn_off"; - # entity_id = "all"; - # }; - # }; - # } - # { - # alias = "Button scene movie"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "right"; - # } // remote; - # action = { - # scene = "scene.movie"; - # }; - # } - # { - # alias = "Button scene home"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "left"; - # } // remote; - # action = { - # scene = "scene.home"; - # }; - # } - # { - # alias = "Button light up"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "dim_up"; - # } // remote; - # action = { - # service = "light.turn_on"; - # entity_id = "light.salon"; - # data = { - # brightness_step = 25; - # }; - # }; - # } - # { - # alias = "Button light down"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "dim_down"; - # } // remote; - # action = { - # service = "light.turn_on"; - # entity_id = "light.salon"; - # data = { - # brightness_step = -25; - # }; - # }; - # } + { + alias = "Button toggle"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_on"; + } // remote; + action = { + choose = { + conditions = { + condition = "template"; + value_template = '' + {% set domain = 'light' %} + {% set state = 'off' %} + {{ states[domain] | count == states[domain] | selectattr('state','eq',state) | list | count }} + ''; + }; + sequence = { + scene = "scene.home"; + }; + }; + default = { + service = "light.turn_off"; + entity_id = "all"; + }; + }; + } + { + alias = "Button scene movie"; + trigger = { + type = "remote_button_short_press"; + subtype = "right"; + } // remote; + action = { + scene = "scene.movie"; + }; + } + { + alias = "Button scene home"; + trigger = { + type = "remote_button_short_press"; + subtype = "left"; + } // remote; + action = { + scene = "scene.home"; + }; + } + { + alias = "Button light up"; + trigger = { + type = "remote_button_short_press"; + subtype = "dim_up"; + } // remote; + action = { + service = "light.turn_on"; + entity_id = "light.salon"; + data = { + brightness_step = 25; + }; + }; + } + { + alias = "Button light down"; + trigger = { + type = "remote_button_short_press"; + subtype = "dim_down"; + } // remote; + action = { + service = "light.turn_on"; + entity_id = "light.salon"; + data = { + brightness_step = -25; + }; + }; + } - # # CHAMBRE + # CHAMBRE - # { - # alias = "Button scene night"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "turn_on"; - # } // switch_chambre; - # action = { - # scene = "scene.night"; - # }; - # } - # { - # alias = "Button scene dodo"; - # trigger = { - # type = "remote_button_short_press"; - # subtype = "turn_off"; - # } // switch_chambre; - # action = { - # service = "light.turn_off"; - # entity_id = "all"; - # }; - # } - # { - # alias = "Button scene lumière chambre ON"; - # trigger = { - # type = "remote_button_long_press"; - # subtype = "dim_up"; - # } // switch_chambre; - # action = { - # service = "light.turn_on"; - # entity_id = "light.chambre"; - # }; - # } - # { - # alias = "Button scene lumière chambre OFF"; - # trigger = { - # type = "remote_button_long_press"; - # subtype = "dim_down"; - # } // switch_chambre; - # action = { - # service = "light.turn_off"; - # entity_id = "light.chambre"; - # }; - # } - #]; + { + alias = "Button scene night"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_on"; + } // switch_chambre; + action = { + scene = "scene.night"; + }; + } + { + alias = "Button scene dodo"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_off"; + } // switch_chambre; + action = { + service = "light.turn_off"; + entity_id = "all"; + }; + } + { + alias = "Button scene lumière chambre ON"; + trigger = { + type = "remote_button_long_press"; + subtype = "dim_up"; + } // switch_chambre; + action = { + service = "light.turn_on"; + entity_id = "light.chambre"; + }; + } + { + alias = "Button scene lumière chambre OFF"; + trigger = { + type = "remote_button_long_press"; + subtype = "dim_down"; + } // switch_chambre; + action = { + service = "light.turn_off"; + entity_id = "light.chambre"; + }; + } + ]; }; }; }; diff --git a/systems/LoutreOS/web.nix b/systems/LoutreOS/web.nix index 9731dae..1cacd80 100644 --- a/systems/LoutreOS/web.nix +++ b/systems/LoutreOS/web.nix @@ -61,10 +61,10 @@ in isSystemUser = true; group = config.users.groups.webdav.name; }; - # wordpress = { - # isSystemUser = true; - # group = config.services.nginx.group; - # }; + wordpress = { + isSystemUser = true; + group = config.services.nginx.group; + }; }; services = { @@ -83,19 +83,19 @@ in # }; # }; - # "wordpress-designyourfuture" = { - # user = config.users.users.wordpress.name; - # group = config.services.nginx.group; - # settings = { - # "listen.owner" = config.services.nginx.user; - # "pm" = "dynamic"; - # "pm.max_children" = 32; - # "pm.start_servers" = 2; - # "pm.min_spare_servers" = 2; - # "pm.max_spare_servers" = 4; - # "pm.max_requests" = 500; - # }; - # }; + "wordpress-designyourfuture" = { + user = config.users.users.wordpress.name; + group = config.services.nginx.group; + settings = { + "listen.owner" = config.services.nginx.user; + "pm" = "dynamic"; + "pm.max_children" = 32; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 2; + "pm.max_spare_servers" = 4; + "pm.max_requests" = 500; + }; + }; drive = { @@ -316,53 +316,52 @@ in } ]; "designyourfuture.amandoline-creations.fr" = base { - "/".alias = "/var/www/amandoleene-designyourfuture/"; - # "/" = { - # priority = 200; - # extraConfig = '' - # try_files $uri $uri/ /index.php$is_args$args; - # ''; - # }; - # "~ \\.php$" = { - # priority = 500; - # extraConfig = '' - # fastcgi_split_path_info ^(.+\.php)(/.+)$; - # fastcgi_pass unix:${config.services.phpfpm.pools."wordpress-designyourfuture".socket}; - # fastcgi_index index.php; - # include "${config.services.nginx.package}/conf/fastcgi.conf"; - # fastcgi_param PATH_INFO $fastcgi_path_info; - # fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - # # Mitigate https://httpoxy.org/ vulnerabilities - # fastcgi_param HTTP_PROXY ""; - # fastcgi_intercept_errors off; - # fastcgi_buffer_size 16k; - # fastcgi_buffers 4 16k; - # fastcgi_connect_timeout 300; - # fastcgi_send_timeout 300; - # fastcgi_read_timeout 300; - # ''; - # }; - # "~ /\\." = { - # priority = 800; - # extraConfig = "deny all;"; - # }; - # "~* /(?:uploads|files)/.*\\.php$" = { - # priority = 900; - # extraConfig = "deny all;"; - # }; - # "~* \\.(js|css|png|jpg|jpeg|gif|ico)$" = { - # priority = 1000; - # extraConfig = '' - # expires max; - # log_not_found off; - # ''; - # }; - } // { - # root = "/var/www/wordpress-designyourfuture"; - # extraConfig = '' - # index index.php; - # ''; - }; + "/" = { + priority = 200; + extraConfig = '' + try_files $uri $uri/ /index.php$is_args$args; + ''; + }; + "~ \\.php$" = { + priority = 500; + extraConfig = '' + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:${config.services.phpfpm.pools."wordpress-designyourfuture".socket}; + fastcgi_index index.php; + include "${config.services.nginx.package}/conf/fastcgi.conf"; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + # Mitigate https://httpoxy.org/ vulnerabilities + fastcgi_param HTTP_PROXY ""; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + fastcgi_connect_timeout 300; + fastcgi_send_timeout 300; + fastcgi_read_timeout 300; + ''; + }; + "~ /\\." = { + priority = 800; + extraConfig = "deny all;"; + }; + "~* /(?:uploads|files)/.*\\.php$" = { + priority = 900; + extraConfig = "deny all;"; + }; + "~* \\.(js|css|png|jpg|jpeg|gif|ico)$" = { + priority = 1000; + extraConfig = '' + expires max; + log_not_found off; + ''; + }; + } // { + root = "/var/www/wordpress-designyourfuture"; + extraConfig = '' + index index.php; + ''; + }; }; }; @@ -393,10 +392,10 @@ in python-ci.enable = true; - # mysql = { - # enable = true; - # package = pkgs.mariadb; - # }; + mysql = { + enable = true; + package = pkgs.mariadb; + }; }; systemd.services.nginx.serviceConfig = {