diff --git a/roles/darwin.nix b/roles/darwin.nix index a5ce232..fb7a479 100644 --- a/roles/darwin.nix +++ b/roles/darwin.nix @@ -1,9 +1,47 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: with lib; +let + # Extract the set-environment path that nix-darwin generates + setEnvironmentPath = "${config.system.build.setEnvironment}"; +in { config = { + # Salt manages /etc/bashrc, /etc/zshrc, /etc/zshenv + # nix-darwin writes to .local variants for nix-specific configuration + + # Disable nix-darwin from managing the main shell files + environment.etc."bashrc".enable = false; + environment.etc."zshrc".enable = false; + environment.etc."zshenv".enable = false; + + # Create .local files with nix environment setup + environment.etc."bash.local".text = '' + # Nix environment setup + if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then + . ${setEnvironmentPath} + fi + ''; + + environment.etc."zshrc.local".text = '' + # Nix environment setup (already done in zshenv.local) + ''; + + environment.etc."zshenv.local".text = '' + # Nix environment setup + if [[ -o rcs ]]; then + if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then + . ${setEnvironmentPath} + fi + + # Tell zsh how to find installed completions + for p in ''${(z)NIX_PROFILES}; do + fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath) + done + fi + ''; + time.timeZone = "America/Los_Angeles"; environment.systemPackages = with pkgs; [