Skip to content

Instantly share code, notes, and snippets.

@antifuchs
Created October 28, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antifuchs/160e25259067bfcb89b47eb67110130c to your computer and use it in GitHub Desktop.
Save antifuchs/160e25259067bfcb89b47eb67110130c to your computer and use it in GitHub Desktop.
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.local.startup-items;
stdenv = pkgs.stdenv;
in
{
options = {
local.startup-items = mkOption {
description = "List of app bundle names to start at login";
type = types.attrsOf types.str;
};
};
config = {
environment.userLaunchAgents = mkIf (stdenv.isDarwin)
(
(mapAttrs'
(name: bundleName:
let
label = "net.boinkor.nix-startup-item.${name}";
in
nameValuePair ("${label}.plist")
{
text = ''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>${label}</string>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-gjWa</string>
<string>${bundleName}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
'';
}
)
cfg)
);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment