-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nix): format nix files and fix home-manager module
- Loading branch information
Showing
5 changed files
with
163 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,78 @@ | ||
self: { | ||
self: | ||
{ | ||
lib, | ||
config, | ||
pkgs, | ||
... | ||
}: let | ||
}: | ||
let | ||
inherit (pkgs.stdenv.hostPlatform) system; | ||
inherit (lib) mapAttrs' mkIf; | ||
cfg = config.services.watgbridge; | ||
|
||
package = self.packages."${system}".watgbridge; | ||
in { | ||
in | ||
{ | ||
options = { | ||
services.watgbridge = import ../commonOptions.nix { inherit lib package; }; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
home.packages = [ cfg.package ]; | ||
|
||
systemd.user.services = mapAttrs' (key: settings: let | ||
systemd.user.services = mapAttrs' ( | ||
key: settings: | ||
let | ||
|
||
instanceName = ( | ||
if settings.name != null then | ||
"watgbridge-${settings.name}" | ||
else | ||
"watgbridge-${key}" | ||
); | ||
watgbridgePackage = ( | ||
if settings.package != null then | ||
settings.package | ||
else | ||
cfg.commonSettings.package | ||
); | ||
instanceName = ( | ||
if settings.name != null then "watgbridge-${settings.name}" else "watgbridge-${key}" | ||
); | ||
watgbridgePackage = ( | ||
if settings.package != null then settings.package else cfg.commonSettings.package | ||
); | ||
|
||
maxRuntime = ( | ||
if settings.maxRuntime != null then | ||
settings.maxRuntime | ||
else | ||
cfg.commonSettings.maxRuntime | ||
); | ||
maxRuntime = ( | ||
if settings.maxRuntime != null then settings.maxRuntime else cfg.commonSettings.maxRuntime | ||
); | ||
|
||
requires = ( | ||
if settings.requires != null then | ||
settings.requires | ||
else | ||
cfg.commonSettings.requires | ||
); | ||
requires = (if settings.requires != null then settings.requires else cfg.commonSettings.requires); | ||
|
||
in { | ||
in | ||
{ | ||
|
||
name = instanceName; | ||
name = instanceName; | ||
|
||
value = mkIf settings.enable { | ||
Unit = { | ||
Description = "WaTgBridge service for '${instanceName}'"; | ||
Documentation = "https://github.com/akshettrj/watbridge"; | ||
After = [ "network.target" ]; | ||
} // lib.optionalAttrs (requires != null) { | ||
Requires = requires; | ||
}; | ||
value = mkIf settings.enable { | ||
Unit = | ||
{ | ||
Description = "WaTgBridge service for '${instanceName}'"; | ||
Documentation = "https://github.com/akshettrj/watbridge"; | ||
After = [ "network.target" ]; | ||
} | ||
// lib.optionalAttrs (requires != null) { | ||
Requires = requires; | ||
}; | ||
|
||
Service = { | ||
ExecStart = ''${watgbridgePackage}/bin/watbridge'' lib.optionalString (settings.configPath != null) '' "${settings.configPath}"''; | ||
Restart = "on-failure"; | ||
} // lib.optionalAttrs maxRuntime != null { | ||
RuntimeMaxSec = maxRuntime; | ||
}; | ||
Service = | ||
{ | ||
ExecStart = | ||
''${watgbridgePackage}/bin/watbridge'' | ||
+ lib.optionalString (settings.configPath != null) ''"${settings.configPath}"''; | ||
Restart = "on-failure"; | ||
} | ||
// lib.optionalAttrs maxRuntime != null { | ||
RuntimeMaxSec = maxRuntime; | ||
} | ||
// lib.optionalAttrs (settings.workingDirectory != null) { | ||
WorkingDirectory = settings.workingDirectory; | ||
}; | ||
|
||
Install = { WantedBy = ["default.target"]; }; | ||
}; | ||
Install = { | ||
WantedBy = [ "default.target" ]; | ||
}; | ||
}; | ||
|
||
}) cfg.instances; | ||
} | ||
) cfg.instances; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.