From 0b5f6200d8960870c6a99e8cf07d0126a20cdeb8 Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Tue, 7 Nov 2023 16:47:40 +0000 Subject: [PATCH] Fix asterisk-sounds-de There was a race condition that lead to incorrect user permissions on the sounds directory. The solution to use the preStart script is better and fixes this issue as well. --- hosts/aluminium/services/asterisk.nix | 8 -------- .../default.nix} | 0 pkgs/asterisk-sounds-de/module.nix | 15 +++++++++++++++ pkgs/default.nix | 2 +- pkgs/modules.nix | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) rename pkgs/{asterisk/sounds-de.nix => asterisk-sounds-de/default.nix} (100%) create mode 100644 pkgs/asterisk-sounds-de/module.nix diff --git a/hosts/aluminium/services/asterisk.nix b/hosts/aluminium/services/asterisk.nix index 82e00ea..820689c 100644 --- a/hosts/aluminium/services/asterisk.nix +++ b/hosts/aluminium/services/asterisk.nix @@ -172,14 +172,6 @@ in ]; }; - system.activationScripts.symlink-asterisk-sounds-de = lib.stringAfter [ "var" ] '' - sounds="/var/lib/asterisk/sounds" - sounds_de="$sounds/de" - mkdir -p "$sounds" - [ -L "$sounds_de" ] && rm "$sounds_de" - ln -s "${pkgs.asterisk-sounds-de}/" "$sounds_de" - ''; - systemd.services."asterisk-reload-endpoint@" = { description = "Check if asterisk endpoint is identified and reload it when it is not."; serviceConfig = { diff --git a/pkgs/asterisk/sounds-de.nix b/pkgs/asterisk-sounds-de/default.nix similarity index 100% rename from pkgs/asterisk/sounds-de.nix rename to pkgs/asterisk-sounds-de/default.nix diff --git a/pkgs/asterisk-sounds-de/module.nix b/pkgs/asterisk-sounds-de/module.nix new file mode 100644 index 0000000..0bfbeda --- /dev/null +++ b/pkgs/asterisk-sounds-de/module.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +let cfg = config; +in +{ + config = lib.mkIf cfg.services.asterisk.enable { + systemd.services.asterisk.preStart = lib.mkMerge [ + (lib.mkAfter '' + sounds_de="/var/lib/asterisk/sounds/de" + [ -L "$sounds_de" ] && rm "$sounds_de" + ln -s "${pkgs.asterisk-sounds-de}/" "$sounds_de" + '') + ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 1d0a068..1d92bc8 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -6,7 +6,7 @@ let in { ariang = callPackage ./ariang { }; - asterisk-sounds-de = callPackage ./asterisk/sounds-de.nix { }; + asterisk-sounds-de = callPackage ./asterisk-sounds-de { }; docker-machine-driver-hetzner = callPackage ./docker-machine-driver-hetzner { inherit (inputs.gomod2nix.legacyPackages.${system}) buildGoApplication; }; diff --git a/pkgs/modules.nix b/pkgs/modules.nix index 3e1a8e3..f61aa63 100644 --- a/pkgs/modules.nix +++ b/pkgs/modules.nix @@ -2,6 +2,7 @@ { imports = [ + ./asterisk-sounds-de/module.nix ./myintercom-doorbell/module.nix ./pretix/module.nix ];