Skip to content

Commit

Permalink
Merge pull request #7 from fufexan/nix
Browse files Browse the repository at this point in the history
nix/hm-module: init
  • Loading branch information
NotAShelf committed Jul 13, 2024
2 parents 304f19d + 8a897f6 commit 344c9ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = {nixpkgs, ...}: let
outputs = {
self,
nixpkgs,
...
}: let
systems = ["x86_64-linux" "aarch64-linux"];
forEachSystem = nixpkgs.lib.genAttrs systems;

Expand All @@ -14,5 +18,9 @@
packages = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
});

homeManagerModules = {
default = import ./nix/hm-module.nix self;
};
};
}
44 changes: 44 additions & 0 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
self: {
config,
pkgs,
lib,
...
}: let
cfg = config.services.tailray;

inherit (lib.meta) getExe;
inherit (lib.options) mkEnableOption mkPackageOption;
in {
meta.maintainers = with lib.maintainers; [fufexan];

options.services.tailray = {
enable = mkEnableOption "Tailray, a Tailscale tray";

package =
mkPackageOption pkgs "tailray" {}
// {
default = self.packages.${pkgs.system}.default;
};
};

config = lib.mkIf cfg.enable {
home.packages = [cfg.package];

systemd.user.services.tailray = {
Install.WantedBy = ["graphical-session.target"];

Unit = {
Description = "Tailscale tray item";
Requires = "tray.target";
After = ["graphical-session-pre.target" "tray.target"];
PartOf = ["graphical-session.target"];
};

Service = {
ExecStart = "${getExe cfg.package}";
Restart = "always";
RestartSec = "10";
};
};
};
}

0 comments on commit 344c9ba

Please sign in to comment.