mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-16 05:18:17 +00:00
add /Library/LaunchDaemons to system
This commit is contained in:
parent
f651372252
commit
81b8a44e40
3 changed files with 59 additions and 45 deletions
|
@ -86,7 +86,7 @@ let
|
||||||
|
|
||||||
nixdarwin-rebuild () {
|
nixdarwin-rebuild () {
|
||||||
case $1 in
|
case $1 in
|
||||||
'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel ;;
|
'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel --show-trace ;;
|
||||||
'repl') nix-repl "$HOME/.nixpkgs/config.nix" ;;
|
'repl') nix-repl "$HOME/.nixpkgs/config.nix" ;;
|
||||||
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run "${pkgs.lnl.zsh}/bin/zsh -l" ;;
|
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run "${pkgs.lnl.zsh}/bin/zsh -l" ;;
|
||||||
'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;;
|
'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;;
|
||||||
|
|
|
@ -13,8 +13,8 @@ let
|
||||||
{ config, name, ... }:
|
{ config, name, ... }:
|
||||||
{ options = {
|
{ options = {
|
||||||
plist = mkOption {
|
plist = mkOption {
|
||||||
type = types.path;
|
|
||||||
internal = true;
|
internal = true;
|
||||||
|
type = types.path;
|
||||||
description = "The generated plist.";
|
description = "The generated plist.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,55 +35,56 @@ let
|
||||||
config = {
|
config = {
|
||||||
serviceConfig.Label = mkDefault "org.nixos.${name}";
|
serviceConfig.Label = mkDefault "org.nixos.${name}";
|
||||||
|
|
||||||
plist = pkgs.writeText "${config.serviceConfig.Label}.plist" ''
|
plist = pkgs.writeText "${config.serviceConfig.Label}.plist" (''
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
${xmlMapAttr xmlString "Label" config.serviceConfig.Label}
|
'' + xmlMapAttr xmlString "Label" config.serviceConfig.Label
|
||||||
${xmlMapAttr xmlBool "Disabled" config.serviceConfig.Disabled}
|
+ xmlMapAttr xmlBool "Disabled" config.serviceConfig.Disabled
|
||||||
${xmlMapAttr xmlString "UserName" config.serviceConfig.UserName}
|
+ xmlMapAttr xmlString "UserName" config.serviceConfig.UserName
|
||||||
${xmlMapAttr xmlString "GroupName" config.serviceConfig.GroupName}
|
+ xmlMapAttr xmlString "GroupName" config.serviceConfig.GroupName
|
||||||
${xmlMapAttr (xmlMapAttrs xmlBool) "inetdCompatibility" config.serviceConfig.inetdCompatibility}
|
+ xmlMapAttr (xmlMapAttrs xmlBool) "inetdCompatibility" config.serviceConfig.inetdCompatibility
|
||||||
${xmlMapAttr (xmlMap xmlString) "LimitLoadToHosts" config.serviceConfig.LimitLoadToHosts}
|
+ xmlMapAttr (xmlMap xmlString) "LimitLoadToHosts" config.serviceConfig.LimitLoadToHosts
|
||||||
${xmlMapAttr (xmlMap xmlString) "LimitLoadFromHosts" config.serviceConfig.LimitLoadFromHosts}
|
+ xmlMapAttr (xmlMap xmlString) "LimitLoadFromHosts" config.serviceConfig.LimitLoadFromHosts
|
||||||
${xmlMapAttr xmlString "LimitLoadToSessionType" config.serviceConfig.LimitLoadToSessionType}
|
+ xmlMapAttr xmlString "LimitLoadToSessionType" config.serviceConfig.LimitLoadToSessionType
|
||||||
${xmlMapAttr xmlString "Program" config.serviceConfig.Program}
|
+ xmlMapAttr xmlString "Program" config.serviceConfig.Program
|
||||||
${xmlMapAttr (xmlMap xmlString) "ProgramArguments" config.serviceConfig.ProgramArguments}
|
+ xmlMapAttr (xmlMap xmlString) "ProgramArguments" config.serviceConfig.ProgramArguments
|
||||||
${xmlMapAttr xmlBool "EnableGlobbing" config.serviceConfig.EnableGlobbing}
|
+ xmlMapAttr xmlBool "EnableGlobbing" config.serviceConfig.EnableGlobbing
|
||||||
${xmlMapAttr xmlBool "EnableTransactions" config.serviceConfig.EnableTransactions}
|
+ xmlMapAttr xmlBool "EnableTransactions" config.serviceConfig.EnableTransactions
|
||||||
${xmlMapAttr xmlBool "OnDemand" config.serviceConfig.OnDemand}
|
+ xmlMapAttr xmlBool "OnDemand" config.serviceConfig.OnDemand
|
||||||
${xmlMapAttr xmlBool "KeepAlive" config.serviceConfig.KeepAlive}
|
+ xmlMapAttr xmlBool "KeepAlive" config.serviceConfig.KeepAlive
|
||||||
${xmlMapAttr xmlBool "RunAtLoad" config.serviceConfig.RunAtLoad}
|
+ xmlMapAttr xmlBool "RunAtLoad" config.serviceConfig.RunAtLoad
|
||||||
${xmlMapAttr xmlString "RootDirectory" config.serviceConfig.RootDirectory}
|
+ xmlMapAttr xmlString "RootDirectory" config.serviceConfig.RootDirectory
|
||||||
${xmlMapAttr xmlString "WorkingDirectory" config.serviceConfig.WorkingDirectory}
|
+ xmlMapAttr xmlString "WorkingDirectory" config.serviceConfig.WorkingDirectory
|
||||||
${xmlMapAttr (xmlMapAttrs xmlString) "EnvironmentVariables" config.serviceConfig.EnvironmentVariables}
|
+ xmlMapAttr (xmlMapAttrs xmlString) "EnvironmentVariables" config.serviceConfig.EnvironmentVariables
|
||||||
${xmlMapAttr xmlInt "Umask" config.serviceConfig.Umask}
|
+ xmlMapAttr xmlInt "Umask" config.serviceConfig.Umask
|
||||||
${xmlMapAttr xmlInt "TimeOut" config.serviceConfig.TimeOut}
|
+ xmlMapAttr xmlInt "TimeOut" config.serviceConfig.TimeOut
|
||||||
${xmlMapAttr xmlInt "ExitTimeOut" config.serviceConfig.ExitTimeOut}
|
+ xmlMapAttr xmlInt "ExitTimeOut" config.serviceConfig.ExitTimeOut
|
||||||
${xmlMapAttr xmlInt "ThrottleInterval" config.serviceConfig.ThrottleInterval}
|
+ xmlMapAttr xmlInt "ThrottleInterval" config.serviceConfig.ThrottleInterval
|
||||||
${xmlMapAttr xmlBool "InitGroups" config.serviceConfig.InitGroups}
|
+ xmlMapAttr xmlBool "InitGroups" config.serviceConfig.InitGroups
|
||||||
${xmlMapAttr (xmlMap xmlString) "WatchPaths" config.serviceConfig.WatchPaths}
|
+ xmlMapAttr (xmlMap xmlString) "WatchPaths" config.serviceConfig.WatchPaths
|
||||||
${xmlMapAttr (xmlMap xmlString) "QueueDirectories" config.serviceConfig.QueueDirectories}
|
+ xmlMapAttr (xmlMap xmlString) "QueueDirectories" config.serviceConfig.QueueDirectories
|
||||||
${xmlMapAttr xmlBool "StartOnMount" config.serviceConfig.StartOnMount}
|
+ xmlMapAttr xmlBool "StartOnMount" config.serviceConfig.StartOnMount
|
||||||
${xmlMapAttr xmlInt "StartInterval" config.serviceConfig.StartInterval}
|
+ xmlMapAttr xmlInt "StartInterval" config.serviceConfig.StartInterval
|
||||||
${xmlMapAttr (xmlMapAttrs xmlInt) "StartCalendarInterval" config.serviceConfig.StartCalendarInterval}
|
+ xmlMapAttr (xmlMapAttrs xmlInt) "StartCalendarInterval" config.serviceConfig.StartCalendarInterval
|
||||||
${xmlMapAttr xmlString "StandardInPath" config.serviceConfig.StandardInPath}
|
+ xmlMapAttr xmlString "StandardInPath" config.serviceConfig.StandardInPath
|
||||||
${xmlMapAttr xmlString "StandardOutPath" config.serviceConfig.StandardOutPath}
|
+ xmlMapAttr xmlString "StandardOutPath" config.serviceConfig.StandardOutPath
|
||||||
${xmlMapAttr xmlString "StandardErrorPath" config.serviceConfig.StandardErrorPath}
|
+ xmlMapAttr xmlString "StandardErrorPath" config.serviceConfig.StandardErrorPath
|
||||||
${xmlMapAttr xmlBool "Debug" config.serviceConfig.Debug}
|
+ xmlMapAttr xmlBool "Debug" config.serviceConfig.Debug
|
||||||
${xmlMapAttr xmlBool "WaitForDebugger" config.serviceConfig.WaitForDebugger}
|
+ xmlMapAttr xmlBool "WaitForDebugger" config.serviceConfig.WaitForDebugger
|
||||||
${xmlMapAttr (xmlMapAttrs xmlInt) "SoftResourceLimits" config.serviceConfig.SoftResourceLimits}
|
+ xmlMapAttr (xmlMapAttrs xmlInt) "SoftResourceLimits" config.serviceConfig.SoftResourceLimits
|
||||||
${xmlMapAttr (xmlMapAttrs xmlInt) "HardResourceLimits" config.serviceConfig.HardResourceLimits}
|
+ xmlMapAttr (xmlMapAttrs xmlInt) "HardResourceLimits" config.serviceConfig.HardResourceLimits
|
||||||
${xmlMapAttr xmlInt "Nice" config.serviceConfig.Nice}
|
+ xmlMapAttr xmlInt "Nice" config.serviceConfig.Nice
|
||||||
${xmlMapAttr xmlString "ProcessType" config.serviceConfig.ProcessType}
|
+ xmlMapAttr xmlString "ProcessType" config.serviceConfig.ProcessType
|
||||||
${xmlMapAttr xmlBool "AbandonProcessGroup" config.serviceConfig.AbandonProcessGroup}
|
+ xmlMapAttr xmlBool "AbandonProcessGroup" config.serviceConfig.AbandonProcessGroup
|
||||||
${xmlMapAttr xmlBool "LowPriorityIO" config.serviceConfig.LowPriorityIO}
|
+ xmlMapAttr xmlBool "LowPriorityIO" config.serviceConfig.LowPriorityIO
|
||||||
${xmlMapAttr xmlBool "LaunchOnlyOnce" config.serviceConfig.LaunchOnlyOnce}
|
+ xmlMapAttr xmlBool "LaunchOnlyOnce" config.serviceConfig.LaunchOnlyOnce
|
||||||
${xmlMapAttr (xmlMapAttrs xmlBool) "MachServices" config.serviceConfig.MachServices}
|
+ xmlMapAttr (xmlMapAttrs xmlBool) "MachServices" config.serviceConfig.MachServices
|
||||||
|
+ ''
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
'';
|
'');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,6 +113,16 @@ in {
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
|
system.build.launchd = pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
name = "launchd-library";
|
||||||
|
preferLocalBuild = true;
|
||||||
|
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p $out/Library/LaunchDaemons
|
||||||
|
ln -s ${cfg.daemons.nix-daemon.plist} $out/Library/LaunchDaemons/${cfg.daemons.nix-daemon.serviceConfig.Label}.plist
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
system.activationScripts.launchd.text = ''
|
system.activationScripts.launchd.text = ''
|
||||||
# Set up launchd services in /Library/LaunchAgents, /Library/LaunchDaemons and ~/Library/LaunchAgents
|
# Set up launchd services in /Library/LaunchAgents, /Library/LaunchDaemons and ~/Library/LaunchAgents
|
||||||
echo "setting up launchd services..."
|
echo "setting up launchd services..."
|
||||||
|
|
|
@ -49,6 +49,9 @@ in
|
||||||
ln -s ${cfg.build.etc}/etc $out/etc
|
ln -s ${cfg.build.etc}/etc $out/etc
|
||||||
ln -s ${cfg.path} $out/sw
|
ln -s ${cfg.path} $out/sw
|
||||||
|
|
||||||
|
mkdir -p $out/Library
|
||||||
|
ln -s ${cfg.build.launchd}/Library/LaunchDaemons $out/Library/LaunchDaemons
|
||||||
|
|
||||||
echo "$activationScript" > $out/activate
|
echo "$activationScript" > $out/activate
|
||||||
substituteInPlace $out/activate --subst-var out
|
substituteInPlace $out/activate --subst-var out
|
||||||
chmod u+x $out/activate
|
chmod u+x $out/activate
|
||||||
|
|
Loading…
Add table
Reference in a new issue