From fef4f25ca4f64d46bbf9d3d5220f36d5be4d5103 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sun, 26 May 2024 14:05:14 -0700 Subject: [PATCH] chore: nf-fmt-nix --- modules/nixos/home-assistant.nix | 5 +- modules/nixos/vouch.nix | 2 +- nixos/access/home-assistant.nix | 16 +++-- nixos/home-assistant.nix | 41 +++++------ nixos/vouch.nix | 10 +-- packages/grocy/pygrocy.nix | 114 ++++++++++++++++--------------- systems/tei/cloudflared.nix | 3 +- systems/tei/nixos.nix | 36 +++++----- 8 files changed, 123 insertions(+), 104 deletions(-) diff --git a/modules/nixos/home-assistant.nix b/modules/nixos/home-assistant.nix index 5fc312de..13df657f 100644 --- a/modules/nixos/home-assistant.nix +++ b/modules/nixos/home-assistant.nix @@ -278,7 +278,7 @@ in { androidtvremote2 ]) (mkIf cfg.grocy.enable [ - (python3Packages.callPackage ../../packages/grocy/pygrocy.nix { }) + (python3Packages.callPackage ../../packages/grocy/pygrocy.nix {}) ]) ]; extraComponents = mkMerge [ @@ -306,7 +306,8 @@ in { (map ({platform, ...}: platform) cfg.config.tts or []) ]; customComponents = [ - (mkIf (cfg.reverseProxy.enable && cfg.reverseProxy.auth.enable) + ( + mkIf (cfg.reverseProxy.enable && cfg.reverseProxy.auth.enable) pkgs.home-assistant-custom-components.auth-header ) ]; diff --git a/modules/nixos/vouch.nix b/modules/nixos/vouch.nix index 776e293e..b123a41b 100644 --- a/modules/nixos/vouch.nix +++ b/modules/nixos/vouch.nix @@ -23,7 +23,7 @@ in { options.services.vouch-proxy = with types; { enable = mkEnableOption "vouch"; - package = mkPackageOption pkgs "vouch-proxy" { }; + package = mkPackageOption pkgs "vouch-proxy" {}; user = mkOption { type = str; default = "vouch-proxy"; diff --git a/nixos/access/home-assistant.nix b/nixos/access/home-assistant.nix index dbd55ce9..21401ab8 100644 --- a/nixos/access/home-assistant.nix +++ b/nixos/access/home-assistant.nix @@ -32,7 +32,7 @@ in { }; }; virtualHosts = let - vouchHost = { config, ... }: { + vouchHost = {config, ...}: { vouch = { requireAuth = mkDefault false; auth.lua = { @@ -60,7 +60,11 @@ in { }; }; # TODO: restrict to "/auth/authorize" and "/auth/login_flow" only..? - "/auth/" = { virtualHost, config, ... }: { + "/auth/" = { + virtualHost, + config, + ... + }: { proxy = { inherit headers; enable = true; @@ -78,13 +82,13 @@ in { }; }; in { - home-assistant = { ... }: { - imports = [ vouchHost ]; + home-assistant = {...}: { + imports = [vouchHost]; inherit name locations; proxy.upstream = mkDefault upstreamName; }; - home-assistant'local = { ... }: { - imports = [ vouchHost ]; + home-assistant'local = {...}: { + imports = [vouchHost]; vouch.enable = mkDefault nginx.virtualHosts.home-assistant.vouch.enable; inherit name listen' locations; ssl.cert = { diff --git a/nixos/home-assistant.nix b/nixos/home-assistant.nix index ebd69a74..4920fa30 100644 --- a/nixos/home-assistant.nix +++ b/nixos/home-assistant.nix @@ -65,28 +65,31 @@ in { address4 #address6 ]; - guest = logistics ++ [ - # bedroom tv - "10.1.1.67" - ]; + guest = + logistics + ++ [ + # bedroom tv + "10.1.1.67" + ]; kat = koishi; arc = shanghai ++ nue; enableTrustedAuth = false; - in mkIf enableTrustedAuth [ - { - type = "trusted_networks"; - #allow_bypass_login = true; - trusted_networks = guest; - trusted_users = - genAttrs guest (_: "4051fcce77564010a836fd6b108bbb4b") - #genAttrs arc (_: "0c9c9382890746c2b246b76557f22953") - #genAttrs kat (_: "a6e96c523d334aabaea71743839ef584") - ; - } - { - type = "homeassistant"; - } - ]; + in + mkIf enableTrustedAuth [ + { + type = "trusted_networks"; + #allow_bypass_login = true; + trusted_networks = guest; + trusted_users = + genAttrs guest (_: "4051fcce77564010a836fd6b108bbb4b") + #genAttrs arc (_: "0c9c9382890746c2b246b76557f22953") + #genAttrs kat (_: "a6e96c523d334aabaea71743839ef584") + ; + } + { + type = "homeassistant"; + } + ]; }; frontend = { themes = "!include_dir_merge_named themes"; diff --git a/nixos/vouch.nix b/nixos/vouch.nix index 0d1b890a..bcb81ef3 100644 --- a/nixos/vouch.nix +++ b/nixos/vouch.nix @@ -13,10 +13,12 @@ in { services.vouch-proxy = { enable = mkDefault true; package = mkIf hassVouch (pkgs.vouch-proxy.overrideAttrs (old: { - postPatch = '' - sed -i handlers/login.go \ - -e 's/badStrings *=.*$/badStrings = []string{}/' - '' + old.postPatch or ""; + postPatch = + '' + sed -i handlers/login.go \ + -e 's/badStrings *=.*$/badStrings = []string{}/' + '' + + old.postPatch or ""; doCheck = false; })); domain = mkDefault "login.${config.networking.domain}"; diff --git a/packages/grocy/pygrocy.nix b/packages/grocy/pygrocy.nix index 3d59aba1..2be92ffe 100644 --- a/packages/grocy/pygrocy.nix +++ b/packages/grocy/pygrocy.nix @@ -1,63 +1,69 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, backports-zoneinfo -, deprecation -, pydantic -, requests -, responses -, pre-commit -, isort -, vcrpy -, pytest -, pytest-recording -, pytest-mock -, pythonOlder -# requires an instance of grocy api running... -, doCheckGrocy ? false +{ + lib, + buildPythonPackage, + fetchFromGitHub, + backports-zoneinfo, + deprecation, + pydantic, + requests, + responses, + pre-commit, + isort, + vcrpy, + pytest, + pytest-recording, + pytest-mock, + pythonOlder, + # requires an instance of grocy api running... + doCheckGrocy ? false, }: let inherit (lib.lists) optional optionals; inherit (lib.strings) optionalString; -in buildPythonPackage rec { - pname = "pygrocy"; - version = "2.1.0"; - format = "setuptools"; +in + buildPythonPackage rec { + pname = "pygrocy"; + version = "2.1.0"; + format = "setuptools"; - src = fetchFromGitHub { - owner = "SebRut"; - repo = "pygrocy"; - rev = "v${version}"; - hash = "sha256-ijwcdWMeBnYPhrNYt/IxucPvzc+0InudLxJSMVwulNw="; - }; + src = fetchFromGitHub { + owner = "SebRut"; + repo = "pygrocy"; + rev = "v${version}"; + hash = "sha256-ijwcdWMeBnYPhrNYt/IxucPvzc+0InudLxJSMVwulNw="; + }; - postPatch = optionalString (!doCheckGrocy) '' - rm test/test_grocy.py - ''; + postPatch = optionalString (!doCheckGrocy) '' + rm test/test_grocy.py + ''; - propagatedBuildInputs = [ - requests - deprecation - pydantic - ] ++ optional (pythonOlder "3.9") backports-zoneinfo; + propagatedBuildInputs = + [ + requests + deprecation + pydantic + ] + ++ optional (pythonOlder "3.9") backports-zoneinfo; - pythonImportsCheck = [ - "pygrocy" - ]; + pythonImportsCheck = [ + "pygrocy" + ]; - checkInputs = [ - pytest - pytest-recording - pytest-mock - ] ++ optionals doCheckGrocy [ - responses - pre-commit - isort - vcrpy - ]; + checkInputs = + [ + pytest + pytest-recording + pytest-mock + ] + ++ optionals doCheckGrocy [ + responses + pre-commit + isort + vcrpy + ]; - meta = { - homepage = "https://github.com/SebRut/pygrocy"; - license = lib.licenses.mit; - broken = pythonOlder "3.8"; - }; -} + meta = { + homepage = "https://github.com/SebRut/pygrocy"; + license = lib.licenses.mit; + broken = pythonOlder "3.8"; + }; + } diff --git a/systems/tei/cloudflared.nix b/systems/tei/cloudflared.nix index 2f5ae625..097fbb9c 100644 --- a/systems/tei/cloudflared.nix +++ b/systems/tei/cloudflared.nix @@ -19,7 +19,8 @@ in { (nginx.virtualHosts.zigbee2mqtt.proxied.cloudflared.getIngress {}) (nginx.virtualHosts.grocy.proxied.cloudflared.getIngress {}) (nginx.virtualHosts.barcodebuddy.proxied.cloudflared.getIngress {}) - (if home-assistant.reverseProxy.auth.enable + ( + if home-assistant.reverseProxy.auth.enable then (nginx.virtualHosts.home-assistant.proxied.cloudflared.getIngress {}) else { ${home-assistant.domain} = assert home-assistant.enable && home-assistant.reverseProxy.enable; { diff --git a/systems/tei/nixos.nix b/systems/tei/nixos.nix index e4bf6b45..098948b4 100644 --- a/systems/tei/nixos.nix +++ b/systems/tei/nixos.nix @@ -11,23 +11,25 @@ in { imports = let inherit (meta) nixos; - in [ - nixos.reisen-ct - nixos.sops - nixos.tailscale - nixos.cloudflared - nixos.postgres - nixos.nginx - nixos.access.zigbee2mqtt - nixos.access.grocy - nixos.access.barcodebuddy - nixos.home-assistant - nixos.zigbee2mqtt - nixos.syncplay - nixos.grocy - nixos.barcodebuddy - ./cloudflared.nix - ] ++ optional hassVouchAuth nixos.access.home-assistant; + in + [ + nixos.reisen-ct + nixos.sops + nixos.tailscale + nixos.cloudflared + nixos.postgres + nixos.nginx + nixos.access.zigbee2mqtt + nixos.access.grocy + nixos.access.barcodebuddy + nixos.home-assistant + nixos.zigbee2mqtt + nixos.syncplay + nixos.grocy + nixos.barcodebuddy + ./cloudflared.nix + ] + ++ optional hassVouchAuth nixos.access.home-assistant; services.nginx = { proxied.enable = true;