From 09f7db14c352815e6d8ce39c33df77afcc406150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Wed, 12 Jul 2023 20:50:01 +0200 Subject: [PATCH] fix: use specialArgs instead of _module.args Avoids infinite recursion issues in some cases. --- flake.nix | 13 ++++------ modules/flakeDefaults.nix | 4 +-- services/home-assistant/wyoming.nix | 38 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 services/home-assistant/wyoming.nix diff --git a/flake.nix b/flake.nix index eeee53f..88b244b 100644 --- a/flake.nix +++ b/flake.nix @@ -100,14 +100,7 @@ nixpkgs.overlays = systemDefaults.overlays; - imports = systemDefaults.modules ++ [ - hardwareConfig - config - { - # make arguments available to modules - _module.args = { inherit self inputs; }; - } - ]; + imports = systemDefaults.modules ++ [ hardwareConfig config ]; environment.systemPackages = with pkgs; [ agenix.packages.x86_64-linux.default ]; @@ -118,6 +111,7 @@ (createUser' name args) ({ inherit home-manager; } // args2)); createMediaGroup = _: { users.groups.media.gid = 600; }; }; + specialArgs = { inherit inputs; }; in rec { inherit lib overlays nixosModules homeManagerModules; @@ -145,6 +139,7 @@ [ deploy-rs.defaultPackage.x86_64-linux ]; }) ]; + inherit specialArgs; }; nixosConfigurations.pilot1 = nixpkgs.lib.nixosSystem { @@ -164,6 +159,7 @@ config = ./home/felschr-work.nix; }) ]; + inherit specialArgs; }; nixosConfigurations.home-server = nixpkgs.lib.nixosSystem { @@ -189,6 +185,7 @@ config = ./home/felschr-server.nix; }) ]; + inherit specialArgs; }; deploy.nodes.home-server = { diff --git a/modules/flakeDefaults.nix b/modules/flakeDefaults.nix index 687f53a..505f065 100644 --- a/modules/flakeDefaults.nix +++ b/modules/flakeDefaults.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, self, inputs, ... }: +{ pkgs, lib, inputs, ... }: let flakes = lib.filterAttrs (name: value: value ? outputs) inputs; @@ -6,7 +6,7 @@ let in { # Let 'nixos-version --json' know about the Git revision # of this flake. - system.configurationRevision = lib.mkIf (self ? rev) self.rev; + system.configurationRevision = lib.mkIf (inputs.self ? rev) inputs.self.rev; nix = { extraOptions = "experimental-features = nix-command flakes"; diff --git a/services/home-assistant/wyoming.nix b/services/home-assistant/wyoming.nix new file mode 100644 index 0000000..c7bb15e --- /dev/null +++ b/services/home-assistant/wyoming.nix @@ -0,0 +1,38 @@ +{ inputs, ... }: + +{ + # TODO they don't exist, so not disabling them + /* disabledModules = [ + "services/audio/wyoming/piper.nix" + "services/audio/wyoming/faster-whisper.nix" + ]; + */ + + # TODO fails with infinite recursion, why? + # TODO perhaps because of the `pkgs.unstable` override? + imports = [ + "${inputs.nixpkgs-unstable}/nixos/modules/services/audio/wyoming/piper.nix" + "${inputs.nixpkgs-unstable}/nixos/modules/services/audio/wyoming/faster-whisper.nix" + + ]; + + /* services.wyoming.piper.servers = { + "en" = { + enable = true; + voice = "en_GB-alba-medium"; + uri = "tcp://0.0.0.0:10200"; + speaker = 0; + }; + }; + + services.wyoming.faster-whisper.servers = { + "tiny-en" = { + enable = true; + model = "tiny-int8"; + language = "en"; + uri = "tcp://0.0.0.0:10300"; + device = "cpu"; + }; + }; + */ +}