diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-12-01 23:56:20 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-12-01 23:56:20 +0100 |
| commit | fecd4bc368de258158fa71edd9bf0645fb457dbb (patch) | |
| tree | d9248951ae510b49d235513950ad146847a7bcd1 /modules/launchd | |
| parent | d82c472ab00f69e17423c7c97bbdec11d87eadd0 (diff) | |
improve launchd activation scripts
Diffstat (limited to 'modules/launchd')
| -rw-r--r-- | modules/launchd/default.nix | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/modules/launchd/default.nix b/modules/launchd/default.nix index 8ff6933..5d1fc69 100644 --- a/modules/launchd/default.nix +++ b/modules/launchd/default.nix @@ -7,17 +7,16 @@ let cfg = config.launchd; + toEnvironmentText = name: value: { + name = "${value.serviceConfig.Label}.plist"; + value.text = toPLIST value.serviceConfig; + }; + launchdConfig = import ./launchd.nix; serviceOptions = { config, name, ... }: { options = { - plist = mkOption { - internal = true; - type = types.path; - description = "The generated plist."; - }; - serviceConfig = mkOption { type = types.submodule launchdConfig; example = @@ -34,12 +33,12 @@ let config = { serviceConfig.Label = mkDefault "org.nixos.${name}"; - - plist = pkgs.writeText "${config.serviceConfig.Label}.plist" (toPLIST config.serviceConfig); }; }; -in { +in + +{ options = { launchd.agents = mkOption { @@ -54,35 +53,12 @@ in { description = "Definition of launchd daemons."; }; - launchd.user.agents = mkOption { - default = {}; - type = types.attrsOf (types.submodule serviceOptions); - description = "Definition of launchd per-user agents."; - }; - }; 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 = '' - # Set up launchd services in /Library/LaunchAgents, /Library/LaunchDaemons and ~/Library/LaunchAgents - echo "setting up launchd services..." - - launchctl unload '/Library/LaunchDaemons/${cfg.daemons.nix-daemon.serviceConfig.Label}.plist' - ln -sfn '${cfg.daemons.nix-daemon.plist}' '/Library/LaunchDaemons/${cfg.daemons.nix-daemon.serviceConfig.Label}.plist' - launchctl load '/Library/LaunchDaemons/${cfg.daemons.nix-daemon.serviceConfig.Label}.plist' - - ''; + environment.launchAgents = mapAttrs' toEnvironmentText cfg.agents; + environment.launchDaemons = mapAttrs' toEnvironmentText cfg.daemons; }; } |
