Using nix for my dotfiles and programs
[x] setup oh-my-zsh. use ZSH_CUSTOM for custom theme:
- https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
- https://nix-community.github.io/home-manager/options.html#opt-programs.zsh.oh-my-zsh.custom [x] setup ssh so I don't have to keep typing passphrase
Main reference: https://gist.github.com/mandrean/65108e0898629e20afe1002d8bf4f223
symlink repo into ~/.config/nixpkgs
ln -s /Users/dsyang/nixfiles /Users/dsyang/.config/nixpkgs
setup nix path stuff in ~/.zshrc:
- point to your nix-darwin config file in the symlinked location.
export NIX_PATH=darwin-config=$HOME/.config/nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH - Include for home-manager from the main reference.
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
source: https://nix.dev/tutorials/install-nix#macos
sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
This installs nix in multi-user mode which will create users like _nixbld[1..32]. Important to note should you choose to uninstall nix.
nix-shell -p nix-info --run "nix-info -m"
nix-shellstarts a shell with a particular config-p nix-infoconfig is anix-infopackage.--run ...run the following prompt. Without this.nix-shelldrops you into a repl with the package installed.
source: https://ghedam.at/24353/tutorial-getting-started-with-home-manager-for-nix
home-manager is something that lets you use nix setup user-specific configs like dotfiles.
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-managernix-channel --updatenix-shell '<home-manager>' -A installhome-manager switchmust call this to rebuild the system (until nix-darwin installed)
If/when there's a problem with $NIX_PATH not being found:
follow comment : nix-community/home-manager#2564 (comment) in appending to ~/.zshenv
$ echo 'export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels\n' >> ~/.zshenv
- calling
home-managerdoes something.
NOTE: as of now, home-manager isn't used to configure anything anymore. See the commit tagged separate-home-manager for when home manager was still used separately.
home-manager switchto rebuild envhome-manager generationsto see rebuild history<path to old generation>/activateto rollback
source: https://opensourcelibs.com/lib/nix-darwin
nix-darwin lets you configure your macos system let changing preferences in finder & more. It includes modules for configuring other nix things like home-manager
- Use from-source install to get additional finder options until they are upstreamed: https://github.com/dsyang/nix-darwin#manual-install
darwin-rebuild switch
if you hit error: not linking environment.etc."nix/nix.conf" because /etc/nix/nix.conf already exists, skipping..., remove the existing nix.conf created by the nix install in favor of the one created by nix-darwin:
sudo cp /etc/nix/nix.conf /etc/nix/nix.conf-before-nix-darwin; sudo rm /etc/nix/nix.conf
darwin-rebuild switchto rebuild envdarwin-rebuild --list-generationsto see build historydarwin-rebuild --rollbackto go to previous generationsudo nix-collect-garbage -dDeleting old generations. (https://github.com/LnL7/nix-darwin/wiki/Deleting-old-generations#for-multi-user-installation)
enabled = truedownloads app but doesn't put it anywhere accessible. Will still need to download manually- Installing extensions is hard(er). Need to follow something like https://github.com/BenDHarvey/configuration/blob/092195ee496c184fefebca1706199732d2385bdc/nix/modules/home/shared/vscode.nix#L12-L25
- Find extension in VSCode marketplace
- Get name, publisher, version.
- unique identifier is
publisher.name
- unique identifier is
- For sha256, leave it blank for now, running
darwin-rebuild switchwill error out and show you the sha256 it found.
https://iohk.zendesk.com/hc/en-us/articles/4415830650265-Uninstall-nix-on-MacOS
https://cuddly-octo-palm-tree.com/posts/2021-12-19-tyska-nix-shell/