Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{ stdenv, fetchFromGitHub }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "hass-custom-alarm-${version}";
version = "1.3.1";
src = fetchFromGitHub {
owner = "gazoscalvertos";
repo = "Hass-Custom-Alarm";
rev = "v${version}";
sha256 = "1xlwsyg45kmvx3gvkv7k5imbhkxan0s573lalkcqcflf078w7555";
};
dontInstall = true;
unpackPhase = ''
mkdir $out
cp -r * $out/.
'';
}
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.hass-custom-alarm;
hassConfig = config.services.home-assistant;
configDir = hassConfig.configDir;
in {
options.services.hass-custom-alarm = {
enable = mkEnableOption "Home Assistant Custom Alarm Panel";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
hass-custom-alarm
];
systemd.services.hass-custom-alarm = {
description = "Home Assistant Custom Alarm Panel";
before = [ "home-assistant.service" ];
preStart = ''
mkdir -p ${configDir}/custom-alarm
mkdir -p ${configDir}/www/alarm
mkdir -p ${configDir}/www/lib
mkdir -p ${configDir}/panels
mkdir -p ${configDir}/custom_components/alarm_control_panel
ln -s ${pkgs.hass-custom-alarm}/alarm.yaml ${configDir}/custom-alarm/alarm.yaml
ln -s ${pkgs.hass-custom-alarm}/www/alarm/alarm.css ${configDir}/www/alarm/alarm.css
ln -s ${pkgs.hass-custom-alarm}/www/lib/countdown360.js ${configDir}/www/lib/countdown360.js
ln -s ${pkgs.hass-custom-alarm}/www/lib/jquery-3.2.1.min.js ${configDir}/www/lib/jquery-3.2.1.min.js
ln -s ${pkgs.hass-custom-alarm}/panels/alarm.html ${configDir}/panels/alarm.html
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
User = "hass";
Group = "hass";
Restart = "no";
ProtectSystem = "strict";
ReadWritePaths = "${configDir}";
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.