mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
services/distant: init home-manager module
This commit is contained in:
parent
839c440e2c
commit
e42daf3404
@ -10,6 +10,7 @@ let
|
|||||||
./programs/pop-launcher.nix
|
./programs/pop-launcher.nix
|
||||||
./services/archivebox.nix
|
./services/archivebox.nix
|
||||||
./services/bleachbit.nix
|
./services/bleachbit.nix
|
||||||
|
./services/distant.nix
|
||||||
./services/gallery-dl.nix
|
./services/gallery-dl.nix
|
||||||
./services/plover.nix
|
./services/plover.nix
|
||||||
./services/yt-dlp.nix
|
./services/yt-dlp.nix
|
||||||
|
65
modules/home-manager/services/distant.nix
Normal file
65
modules/home-manager/services/distant.nix
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.distant;
|
||||||
|
|
||||||
|
settingsFormat = pkgs.formats.toml {};
|
||||||
|
settingsFile = settingsFormat.generate "distant-settings-${config.home.username}" cfg.settings;
|
||||||
|
|
||||||
|
hasCustomSocketPath = cfg.settings.manager.unix_socket != null;
|
||||||
|
defaultSocketPath = "%t/distant/%u.distant.sock";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.distant = {
|
||||||
|
enable = lib.mkEnableOption "Distant manager";
|
||||||
|
|
||||||
|
package = lib.mkOption {
|
||||||
|
description = lib.mkDoc "The package containing the `distant` executable.";
|
||||||
|
type = lib.types.package;
|
||||||
|
default = pkgs.distant;
|
||||||
|
defaultText = "pkgs.distant";
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
description = lib.mkDoc ''
|
||||||
|
The configuration settings to be passed to the service.
|
||||||
|
'';
|
||||||
|
types = settingsFormat.type;
|
||||||
|
default = { };
|
||||||
|
defaultText = "{}";
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
manager.unix_socket = "/path/to/socket.sock";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.user.services.distant-manager = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Distant manager daemon";
|
||||||
|
Documentation = [ "https://distant.dev" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStart = ''
|
||||||
|
${lib.getBin cfg.package}/bin/distant manager listen --config ${settingsFile} ${lib.optionalString (!hasCustomSocketPath) "--unix-socket ${defaultSocketPath}"}
|
||||||
|
'';
|
||||||
|
Restart = "on-failure";
|
||||||
|
StandardInput = "socket";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install.WantedBy = "default.target";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.user.sockets.distant-manager = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Distant manager daemon";
|
||||||
|
Documentation = [ "https://distant.dev" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Socket.ListenStream = if hasCustomSocketPath then cfg.settings.manager.unix_socket else defaultSocketPath;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user