all repos — nixfiles @ f882cacd9b46335169efab7928e3f4a2da0f142c

System and user configuration, managed by nix and home-manager

user/settings/darwin.nix (view raw)

{
  config,
  pkgs,
  ...
}:
{
  home.packages = with pkgs; [
    darwin.trash
    less
  ];
  targets.darwin.linkApps.enable = false;
  targets.darwin.copyApps = {
    enable = true;
  };

  home.file.".hushlogin".text = "";

  launchd.agents = {
    home-manager-expire-generations = {
      enable = true;

      config = {
        ProgramArguments = [
          "${pkgs.home-manager}/bin/home-manager"
          "expire-generations"
          "-14 days"
        ];
        KeepAlive = false;
        RunAtLoad = false;
        StartCalendarInterval = [
          {
            Hour = 12;
            Minute = 0;
            Weekday = 6; # Saturday
          }
        ];
        ProcessType = "Background";
        LowPriorityBackgroundIO = true;
      };
    };
    setenv = {
      enable = true;

      config = {
        ProgramArguments = [
          "/bin/launchctl"
          "setenv"
          "XDG_CACHE_HOME"
          config.xdg.cacheHome
          "SSH_AUTH_SOCK"
          config.home.sessionVariables.SSH_AUTH_SOCK
        ];
        RunAtLoad = true;
        StandardErrorPath = "/dev/null";
        StandardOutputPath = "/dev/null";
      };
    };
    dark-light-mode = {
      enable = true;
      config = {
        WatchPaths = [ "${config.home.homeDirectory}/Library/Preferences/.GlobalPreferences.plist" ];
        StandardOutputPath = "/dev/null";
        StandardErrorPath = "/dev/null";
        RunAtLoad = true;
        KeepAlive = false;
        ProgramArguments = [
          "/bin/sh"
          (toString (
            pkgs.writeShellScript "toggle-dark-light-mode" ''
              wait4path /nix
              if defaults read -g AppleInterfaceStyle &>/dev/null ; then
                MODE="dark"
              else
                MODE="light"
              fi
              emacsclient="${config.programs.emacs.finalPackage}/bin/emacsclient"
              if pgrep -q Emacs; then
                $emacsclient --eval "(my/switch-theme-variant '$MODE)"
              fi
            ''
          ))
        ];
      };
    };
  };

  home.shellAliases = {
    rb = "darwin-rebuild";
    srb = "sudo darwin-rebuild";
    rbs = "sudo darwin-rebuild switch --flake '.?submodules=1'";

    dig = "dig +noall +answer";

    stat = "stat -x";
  };

  home.sessionVariables = {
    SSH_AUTH_SOCK = "${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
  };
  programs.ssh.extraConfig = ''
    IdentityAgent ~/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh
  '';
}