mirror of
https://github.com/nix-community/home-manager
synced 2025-01-25 18:35:01 +01:00
syncthing: add Darwin support
This commit is contained in:
parent
2f8d24b7f5
commit
885a504f80
10 changed files with 85 additions and 27 deletions
|
@ -964,6 +964,14 @@ in
|
||||||
A new module is available: 'services.copyq'.
|
A new module is available: 'services.copyq'.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2023-03-25T11:03:24+00:00";
|
||||||
|
condition = hostPlatform.isDarwin;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'services.syncthing'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,15 @@ let
|
||||||
|
|
||||||
cfg = config.services.syncthing;
|
cfg = config.services.syncthing;
|
||||||
|
|
||||||
|
defaultSyncthingArgs = [
|
||||||
|
"${pkgs.syncthing}/bin/syncthing"
|
||||||
|
"-no-browser"
|
||||||
|
"-no-restart"
|
||||||
|
"-logflags=0"
|
||||||
|
];
|
||||||
|
|
||||||
|
syncthingArgs = defaultSyncthingArgs ++ cfg.extraOptions;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.rycee ];
|
meta.maintainers = [ maintainers.rycee ];
|
||||||
|
|
||||||
|
@ -57,11 +66,6 @@ in {
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(mkIf cfg.enable {
|
(mkIf cfg.enable {
|
||||||
assertions = [
|
|
||||||
(lib.hm.assertions.assertPlatform "services.syncthing" pkgs
|
|
||||||
lib.platforms.linux)
|
|
||||||
];
|
|
||||||
|
|
||||||
home.packages = [ (getOutput "man" pkgs.syncthing) ];
|
home.packages = [ (getOutput "man" pkgs.syncthing) ];
|
||||||
|
|
||||||
systemd.user.services = {
|
systemd.user.services = {
|
||||||
|
@ -74,10 +78,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart =
|
ExecStart = escapeShellArgs syncthingArgs;
|
||||||
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"
|
|
||||||
+ optionalString (cfg.extraOptions != [ ])
|
|
||||||
(" " + escapeShellArgs cfg.extraOptions);
|
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
SuccessExitStatus = [ 3 4 ];
|
SuccessExitStatus = [ 3 4 ];
|
||||||
RestartForceExitStatus = [ 3 4 ];
|
RestartForceExitStatus = [ 3 4 ];
|
||||||
|
@ -95,6 +96,18 @@ in {
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
launchd.agents.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
ProgramArguments = syncthingArgs;
|
||||||
|
KeepAlive = {
|
||||||
|
Crashed = true;
|
||||||
|
SuccessfulExit = false;
|
||||||
|
};
|
||||||
|
ProcessType = "Background";
|
||||||
|
};
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (isAttrs cfg.tray && cfg.tray.enable) {
|
(mkIf (isAttrs cfg.tray && cfg.tray.enable) {
|
||||||
|
|
|
@ -118,6 +118,7 @@ import nmt {
|
||||||
./modules/programs/sm64ex
|
./modules/programs/sm64ex
|
||||||
./modules/programs/ssh
|
./modules/programs/ssh
|
||||||
./modules/programs/starship
|
./modules/programs/starship
|
||||||
|
./modules/services/syncthing/common
|
||||||
./modules/programs/taskwarrior
|
./modules/programs/taskwarrior
|
||||||
./modules/programs/texlive
|
./modules/programs/texlive
|
||||||
./modules/programs/tmate
|
./modules/programs/tmate
|
||||||
|
@ -202,7 +203,7 @@ import nmt {
|
||||||
./modules/services/screen-locker
|
./modules/services/screen-locker
|
||||||
./modules/services/swayidle
|
./modules/services/swayidle
|
||||||
./modules/services/sxhkd
|
./modules/services/sxhkd
|
||||||
./modules/services/syncthing
|
./modules/services/syncthing/linux
|
||||||
./modules/services/trayer
|
./modules/services/trayer
|
||||||
./modules/services/twmn
|
./modules/services/twmn
|
||||||
./modules/services/udiskie
|
./modules/services/udiskie
|
||||||
|
|
1
tests/modules/services/syncthing/common/default.nix
Normal file
1
tests/modules/services/syncthing/common/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ syncthing-extra-options = ./extra-options.nix; }
|
26
tests/modules/services/syncthing/common/expected-agent.plist
Normal file
26
tests/modules/services/syncthing/common/expected-agent.plist
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<dict>
|
||||||
|
<key>Crashed</key>
|
||||||
|
<true/>
|
||||||
|
<key>SuccessfulExit</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.nix-community.home.syncthing</string>
|
||||||
|
<key>ProcessType</key>
|
||||||
|
<string>Background</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>@syncthing@/bin/syncthing</string>
|
||||||
|
<string>-no-browser</string>
|
||||||
|
<string>-no-restart</string>
|
||||||
|
<string>-logflags=0</string>
|
||||||
|
<string>-foo</string>
|
||||||
|
<string>-bar "baz"</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
26
tests/modules/services/syncthing/common/extra-options.nix
Normal file
26
tests/modules/services/syncthing/common/extra-options.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
lib.mkMerge [
|
||||||
|
{
|
||||||
|
services.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
extraOptions = [ "-foo" ''-bar "baz"'' ];
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.syncthing = { };
|
||||||
|
}
|
||||||
|
(lib.mkIf pkgs.stdenv.isLinux {
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/systemd/user/syncthing.service
|
||||||
|
assertFileContains home-files/.config/systemd/user/syncthing.service \
|
||||||
|
"ExecStart='@syncthing@/bin/syncthing' '-no-browser' '-no-restart' '-logflags=0' '-foo' '-bar \"baz\"'"
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
(lib.mkIf pkgs.stdenv.isDarwin {
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=LaunchAgents/org.nix-community.home.syncthing.plist
|
||||||
|
assertFileExists "$serviceFile"
|
||||||
|
assertFileContent "$serviceFile" ${./expected-agent.plist}
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
]
|
|
@ -1,16 +0,0 @@
|
||||||
{ config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
services.syncthing = {
|
|
||||||
enable = true;
|
|
||||||
extraOptions = [ "-foo" ''-bar "baz"'' ];
|
|
||||||
};
|
|
||||||
|
|
||||||
test.stubs.syncthing = { };
|
|
||||||
|
|
||||||
nmt.script = ''
|
|
||||||
assertFileExists home-files/.config/systemd/user/syncthing.service
|
|
||||||
assertFileContains home-files/.config/systemd/user/syncthing.service \
|
|
||||||
"ExecStart=@syncthing@/bin/syncthing -no-browser -no-restart -logflags=0 '-foo' '-bar \"baz\"'"
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
syncthing-extra-options = ./extra-options.nix;
|
|
||||||
syncthing-tray = ./tray.nix;
|
syncthing-tray = ./tray.nix;
|
||||||
syncthing-tray-as-bool-triggers-warning = ./tray-as-bool-triggers-warning.nix;
|
syncthing-tray-as-bool-triggers-warning = ./tray-as-bool-triggers-warning.nix;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue