Skip to content

Commit

Permalink
flake: Add module to configure daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
jhillyerd committed Mar 4, 2023
1 parent b43e869 commit 4708020
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
17 changes: 12 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
let
inherit (nixpkgs) lib;
inherit (flake-utils.lib) eachSystem system;

overlays = [
(import rust-overlay)
# Build Rust toolchain with helpers from rust-overlay
Expand All @@ -22,7 +25,11 @@
})
];
in
flake-utils.lib.eachDefaultSystem
{
nixosModules.hw-gauge-daemon = import ./module.nix self;
nixosModules.default = self.nixosModules.hw-gauge-daemon;
} //
eachSystem [ system.x86_64-linux ]
(system:
let
pkgs = import nixpkgs { inherit overlays system; };
Expand All @@ -32,6 +39,10 @@
scripts = import ./scripts.nix { inherit pkgs; };
in
{
packages = {
daemon = code.daemon;
};

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
flip-link
Expand All @@ -47,9 +58,5 @@
scripts.daemon.linux.ci
];
};

packages = {
daemon = code.daemon;
};
});
}
28 changes: 28 additions & 0 deletions module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
flake: { config, lib, pkgs, self, ... }:
with lib; let
cfg = config.services.hw-gauge-daemon;
in
{
options.services.hw-gauge-daemon = {
enable = mkEnableOption "Enable the hw-gauge daemon to display HW info";

package = mkOption {
type = types.package;
default = flake.packages.${pkgs.system}.daemon;
};
};

config = mkIf cfg.enable {
systemd.services.hw-gauge-daemon = {
wantedBy = [ "multi-user.target" ];

serviceConfig = {
ExecStart = "${cfg.package}/bin/hw-gauge-daemon";
DynamicUser = "yes";
Group = "dialout";
Restart = "on-failure";
};
};
};
}

0 comments on commit 4708020

Please sign in to comment.