-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
109 lines (101 loc) · 3.24 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
rec {
description = "Daemon for receiving notifications from Home Assistant and displaying them using libnotify.";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ moduleWithSystem, ... }:
let
pname = "ha-notifier";
version = "0.1.1";
in
{
perSystem =
{ pkgs, ... }:
(
let
beam-pkg = pkgs.beam.packagesWith pkgs.erlang_26;
elixir = beam-pkg.elixir_1_17;
mixRelease = beam-pkg.mixRelease.override { inherit elixir; };
elixir-ls = pkgs.elixir-ls.override { inherit elixir mixRelease; };
in
{
devShells.default = pkgs.mkShell {
buildInputs = [
elixir
elixir-ls
];
shellHook = ''
echo "$(elixir --version | tr -s '\n')"
echo ""
echo "LFG."
'';
};
packages.default = mixRelease (
let
src = ./.;
mixFodDeps = beam-pkg.fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
hash = "sha256-sMLIHpXEirMNiYJwLUvRv5ZJkPYJDwz6QFMGMiYDHro=";
};
in
{
inherit
src
pname
version
mixFodDeps
;
}
);
}
);
flake = {
homeManagerModules.default = moduleWithSystem (
{ pkgs, self' }:
{ config, lib, ... }:
let
cfg = config.services.${pname};
in
{
options.services.${pname} = {
enable = lib.mkEnableOption pname;
port = lib.mkOption {
type = lib.types.port;
default = 8124;
description = "Port to listen for Home Assistant via the REST integration.";
};
};
config = lib.mkIf cfg.enable {
systemd.user.services.${pname} = {
Unit.Description = description;
Install.WantedBy = [ "default.target" ];
Service = {
ExecStart = "${pkgs.writeShellScript "ha-notifier" ''
#!/run/current-system/sw/bin/bash
export RELEASE_DISTRIBUTION=none
export RELEASE_COOKIE=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20)
export PORT=${toString cfg.port}
${self'.packages.default}/bin/ha_notifier start
''}";
Restart = "on-failure";
RestartSec = "5";
};
};
};
}
);
};
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
}
);
}