commit 02f131c9032334395c711738ec8f66f6578309a2575c7a2111e0282d412e5c02 Author: Viktor Varland Date: Thu May 15 13:48:10 2025 +0200 makito: nix setup for mac diff --git a/README.md b/README.md new file mode 100644 index 0000000..78ab592 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ + +# nix + +## macos + +add your user as a trusted-user: + +/etc/nix/nix.conf + +``` +build-users-group = nixbld +trusted-users = varl root +``` + +reload the daemon + +``` +sudo launchctl stop org.nixos.nix-daemon +sudo launchctl start org.nixos.nix-daemon +``` + +``` +mkdir -p ~/.config/nixpkgs +cp macos.config.nix ~/.config/nixpkgs/config.nix +``` + +~/.zlogin + +```sh +cp zlogin ~/.zlogin +``` + +~/.zprofile + +```sh +cp zprofile ~/.zprofile +``` + +~/.zshenv + +```sh +cp zshenv ~/.zshenv +``` + +Logout/login. + +Install mac packages + +``` +nix-env -ir user-macos +``` diff --git a/macos.config.nix b/macos.config.nix new file mode 100644 index 0000000..bf2cf66 --- /dev/null +++ b/macos.config.nix @@ -0,0 +1,57 @@ +pkgs : { + allowUnfree = true; + packageOverrides = pkgs: with pkgs; rec { + nixUserProfile = writeText "nix-user-profile" '' + export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin + export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man + export FPATH=$HOME/.nix-profile/share/zsh/site-functions:$HOME/.nix-profile/share/zsh/$ZSH_VERSION/functions:$FPATH + export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive + ''; + + userBasePkgs = pkgs.buildEnv { + name = "user-base"; + paths = [ + (runCommand "profile" {} '' + mkdir -p $out/etc/profile.d + cp ${nixUserProfile} $out/etc/profile.d/nix-user-profile.sh + '') + ]; + pathsToLink = [ + "/share" + "/bin" + "/etc" + ]; + extraOutputsToInstall = [ "man" "doc" ]; + }; + + userMacOSPkgs = pkgs.buildEnv { + name = "user-macos"; + paths = [ + userBasePkgs + bash + zsh + zsh-completions + podman + podman-compose + rsync + gnupg + curl + wget + alacritty + karabiner-elements + coreutils + direnv + ripgrep + fd + chezmoi + fzf + vim + ]; + pathsToLink = [ + "/Applications" + ] ++ (userBasePkgs.pathsToLink or []); + extraOutputsToInstall = [] + ++ (userBasePkgs.extraOutputsToInstall or []); + }; + }; +} diff --git a/macos.nix.conf b/macos.nix.conf new file mode 100644 index 0000000..fe38ae6 --- /dev/null +++ b/macos.nix.conf @@ -0,0 +1,2 @@ +keep-derivations = true +keep-outputs = true diff --git a/zlogin b/zlogin new file mode 100644 index 0000000..599036a --- /dev/null +++ b/zlogin @@ -0,0 +1,5 @@ +# Nix +if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then + . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' +fi +# End Nix diff --git a/zprofile b/zprofile new file mode 100644 index 0000000..b697c2d --- /dev/null +++ b/zprofile @@ -0,0 +1,12 @@ +# let nix setup the path +if [ -d $HOME/.nix-profile/etc/profile.d ]; then + for i in $HOME/.nix-profile/etc/profile.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done +fi + +if [[ -f '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]]; then + source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' +fi diff --git a/zshenv b/zshenv new file mode 100644 index 0000000..f29df37 --- /dev/null +++ b/zshenv @@ -0,0 +1 @@ +[[ -o login ]] && export PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'