Skip to content

Commit 344c9ba

Browse files
authored
Merge pull request #7 from fufexan/nix
nix/hm-module: init
2 parents 304f19d + 8a897f6 commit 344c9ba

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

flake.nix

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
33

4-
outputs = {nixpkgs, ...}: let
4+
outputs = {
5+
self,
6+
nixpkgs,
7+
...
8+
}: let
59
systems = ["x86_64-linux" "aarch64-linux"];
610
forEachSystem = nixpkgs.lib.genAttrs systems;
711

@@ -14,5 +18,9 @@
1418
packages = forEachSystem (system: {
1519
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
1620
});
21+
22+
homeManagerModules = {
23+
default = import ./nix/hm-module.nix self;
24+
};
1725
};
1826
}

nix/hm-module.nix

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
self: {
2+
config,
3+
pkgs,
4+
lib,
5+
...
6+
}: let
7+
cfg = config.services.tailray;
8+
9+
inherit (lib.meta) getExe;
10+
inherit (lib.options) mkEnableOption mkPackageOption;
11+
in {
12+
meta.maintainers = with lib.maintainers; [fufexan];
13+
14+
options.services.tailray = {
15+
enable = mkEnableOption "Tailray, a Tailscale tray";
16+
17+
package =
18+
mkPackageOption pkgs "tailray" {}
19+
// {
20+
default = self.packages.${pkgs.system}.default;
21+
};
22+
};
23+
24+
config = lib.mkIf cfg.enable {
25+
home.packages = [cfg.package];
26+
27+
systemd.user.services.tailray = {
28+
Install.WantedBy = ["graphical-session.target"];
29+
30+
Unit = {
31+
Description = "Tailscale tray item";
32+
Requires = "tray.target";
33+
After = ["graphical-session-pre.target" "tray.target"];
34+
PartOf = ["graphical-session.target"];
35+
};
36+
37+
Service = {
38+
ExecStart = "${getExe cfg.package}";
39+
Restart = "always";
40+
RestartSec = "10";
41+
};
42+
};
43+
};
44+
}

0 commit comments

Comments
 (0)