diff --git a/hosts/lambdaos/configuration.nix b/hosts/lambdaos/configuration.nix index 5bbcc0a..9e1a3d8 100644 --- a/hosts/lambdaos/configuration.nix +++ b/hosts/lambdaos/configuration.nix @@ -67,12 +67,9 @@ networking = { hostName = "lambdaOS"; # Define your hostname. + networkmanager.enable = true; }; - networking.networkmanager.enable = true; - - programs.nm-applet.enable = true; - # Set your time zone. time.timeZone = "Europe/Amsterdam"; @@ -124,26 +121,26 @@ maple-mono-NF ]; - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryPackage = pkgs.pinentry-curses; - }; - xdg.portal.enable = true; programs = { + nm-applet.enable = true; + zsh.enable = true; + gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryPackage = pkgs.pinentry-curses; + }; + hyprland = { enable = true; package = inputs.hyprland.packages.${pkgs.system}.hyprland; }; nix-ld.enable = true; + nix-ld.libraries = with pkgs; [ wayland ]; diff --git a/hosts/nuos/configuration.nix b/hosts/nuos/configuration.nix index 7d968b2..f83432f 100644 --- a/hosts/nuos/configuration.nix +++ b/hosts/nuos/configuration.nix @@ -20,6 +20,8 @@ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/profiles/qemu-guest.nix") + ./home-assistant.nix + ../../common ]; @@ -110,7 +112,10 @@ nixos-rebuild git ]; - script = ''nixos-rebuild switch --flake github:itepastra/nixconf#nuOS''; + script = '' + nixos-rebuild boot --flake github:itepastra/nixconf#nuOS + shutdown -r +5 "System will reboot in 5 minutes" + ''; serviceConfig = { Type = "oneshot"; User = "root"; @@ -121,6 +126,7 @@ after = [ "network-online.target" ]; + restartIfChanged = false; }; virtualisation = { @@ -259,6 +265,9 @@ }; "calendar.itepastra.nl" = proxy "itepastra.nl" "http://[::1]:29341"; + + # home-assistant proxy + "home.itepastra.nl" = proxy "itepastra.nl" "http://[::1]:8123"; }; }; }; @@ -275,6 +284,7 @@ "itepastra.nl".extraDomainNames = [ "locked.itepastra.nl" "calendar.itepastra.nl" + "home.itepastra.nl" ]; }; }; diff --git a/hosts/nuos/home-assistant.nix b/hosts/nuos/home-assistant.nix new file mode 100644 index 0000000..8b5d039 --- /dev/null +++ b/hosts/nuos/home-assistant.nix @@ -0,0 +1,189 @@ +{ + pkgs, + config, + ... +}: +let + ha = { + url = "https://home.itepastra.nl"; + }; + +in +{ + config = { + + age.secrets = { + "ha/ns" = { + file = ../../secrets/home-assistant/ns.age; + owner = "hass"; + group = "hass"; + }; + }; + + services.home-assistant = { + enable = true; + extraComponents = [ + "esphome" + "met" + "radio_browser" + "wled" + "heos" + "hue" + "tado" + "dsmr" + "google_translate" + "syncthing" + "spotify" + "github" + "nederlandse_spoorwegen" + "caldav" + "discord" + ]; + + config = + let + windowOpenAutomation = device: entity_1: entity_2: name: { + alias = "Heater off on window open ${name}"; + description = "Turn off the heater when the window is opened in the room of ${name}"; + triggers = [ + { + type = "opened"; + device_id = device; + entity_id = entity_1; + domain = "binary_sensor"; + trigger = "device"; + } + ]; + conditions = [ ]; + actions = [ + { + device_id = device; + domain = "climate"; + entity_id = entity_2; + type = "set_hvac_mode"; + hvac_mode = "off"; + } + ]; + mode = "single"; + }; + + in + { + default_config = { }; + # "sensor" = [ + # { + # platform = "nederlandse_spoorwegen"; + # api_key_path = config.age.secrets."ha/ns".path; + # routes = [ + # { + # name = "Utrecht_Vaartsche-Leiden"; + # from = "Utvr"; + # to = "Ledn"; + # } + # { + # name = "Utrecht-Delft"; + # from = "Ut"; + # to = "Dt"; + # } + # ]; + # } + # ]; + "automation manual" = [ + (windowOpenAutomation "7d597f356438d1d3cd0c2a7d751cc27b" "binary_sensor.kamer_van_noa_window" + "climate.kamer_van_noa" + "noa" + ) + (windowOpenAutomation "9e94a205cc3d4f4168806e0242763d70" "binary_sensor.kamer_van_sjoerd_window" + "climate.kamer_van_sjoerd" + "sjoerd" + ) + (windowOpenAutomation "435489996d4fc2bfca3cd8beaf781fe4" "binary_sensor.kamer_van_lars_window" + "climate.kamer_van_lars" + "lars" + ) + (windowOpenAutomation "d9b52f250a8392bb3b3b49f08b2ae8bf" "binary_sensor.logeerkamer_window" + "climate.logeerkamer" + "guests" + ) + { + alias = "Notify noa when at store"; + description = "When Noa comes close to the jumbo, send a notification with the shopping list"; + triggers = [ + { + trigger = "zone"; + entity_id = "person.noa_aarts"; + zone = "zone.jumbo"; + event = "enter"; + } + ]; + conditions = [ ]; + actions = [ + { + action = "notify.mobile_app_noa_s_phone"; + data = { + title = "Grocery list"; + message = '' + There {% if states('todo.shopping_list') | int < 2 %} is{%else%} + are{%endif%} {{ states('todo.shopping_list')}} {% if + states('todo.shopping_list') | int < 2 %} product{%else%} + products{%endif%} left on the grocery list. + ''; + # data = { + # actions = [ + # { + # action = "URI"; + # title = "Open grocery list"; + # uri = "${ha.url}/todo?entity_id=todo.shopping_list"; + # } + # ]; + # }; + }; + } + ]; + mode = "single"; + } + ]; + + "automation ui" = "!include automations.yaml"; + + http = { + server_host = "::1"; + trusted_proxies = [ "::1" ]; + use_x_forwarded_for = true; + }; + }; + + package = ( + pkgs.home-assistant.override { + extraPackages = + py: with py; [ + psycopg2 + ]; + } + ); + # .overrideAttrs (oldAttrs: { + # doInstallCheck = false; + # }); + + }; + + systemd.tmpfiles.rules = [ + "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" + ]; + + nixpkgs.config.permittedInsecurePackages = [ + "openssl-1.1.1w" + ]; + + services.postgresql = { + enable = true; + ensureDatabases = [ "hass" ]; + ensureUsers = [ + { + name = "hass"; + ensureDBOwnership = true; + } + ]; + }; + }; +} diff --git a/secrets/home-assistant/ns.age b/secrets/home-assistant/ns.age new file mode 100644 index 0000000..99a4b58 --- /dev/null +++ b/secrets/home-assistant/ns.age @@ -0,0 +1,8 @@ +age-encryption.org/v1 +-> ssh-ed25519 tcnWbQ uDRGSw7hCiYn+g+elKfM8J+JSN0HeVnpEWTsOCXDGTs +3JggsuIG9liwZLsEKNInCbyzJoQgISbG9nV3Z3uEf2k +-> ssh-ed25519 ropO2g gj6oA/Yh7R21JPDptxC8vxExD9KbTph7l7i8CO9AcF4 +Qj//mgeKRtGd0zpC2b++T4+dJHb2/jdTYwbSXGb384Q +--- A/SQz9tUiuV2t7uwJcrjUwBp2pEpSZKN9zhyRndJhFo +:.#6F>߽ =8hOiM2$r/ +J_CeMi8ꀝ \ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix index ce1e066..34cccf5 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -26,4 +26,8 @@ in noa nuOS ]; + "home-assistant/ns.age".publicKeys = [ + noa + nuOS + ]; }