My messy dotfiles for GNU/Linux and macOS. WIP :)
Some files or configuration parts are for GNU/Linux (Archlinux and NixOS) and some others are for macOS.
WIP++ I'm converting this repository from using nix and home-manager to chezmoi.
Using NixOS and Homemanager on macOS was fun and quite efficient, but remained too complex on some aspects, thus I decided to move to something simpler. In addition to this, there were recently some issues in the nix community and various points from those people made sense to me:
chezmoi init gwarf
chezmoi diff
chezmoi apply
# Pull changes and review them
chezmoi git pull -- --autostash --rebase && chezmoi diff
# Apply them
chezmoi apply
# Pull and apply all at once
chezmoi update
chezmoi cd
git status
git commit -a
git push
The nix setup got converted from yadm to using nix and home-manager.
# Using new "experimental" nix search command
nix search nixpkgs firefox
# If experimental features are not enabled
nix --extra-experimental-features "nix-command flakes" search nixpkgs firefox
# Using legacy slow nix-env
nix-env -qaP firefox
It is also possible to use different online services to search in the browser:
- NixOS Wiki: Searching packages
- Home Manager Manual
- Home Manager Options
- Home Manager Options Search
- Nix packages search
- Nix options seardch
To refresh the information about all flakes inputs, it's possible to use two commands:
nix flake update --commit-lock-file
updates ALL inputs and commit the changes to the lock file.
Beware as if you are using some nighlyt or unstable inputs it could break, and commit the change, making reverting a bit less easier (but still doable).
nix flake lock
allows to specify one more multiple inputs to update and then you will have to manually commit the changes to the lock file.
# Checking satus of inputs
nix flake info
# Update all flake inputs and commit lock file
nix flake update --commit-lock-file
# Update main inputs
nix flake lock --update-input nixpkgs \
--update-input nixpkgs-unstable \
--update-input nixpkgs-darwin-stable \
--update-input home-manager
# Update neovim inputs
nix flake lock --update-input neovim-nightly-overlay --update-input nix2lua
# Update nix user repository input
nix flake lock --update-input nur
# Update home-manager input
nix flake lock --update-input home-manager
- Read release notes for nix, nixos and home-manager
- Update channels definition (replace existing ones, with most recent ones)
- Update channels
- Rebuild the system
NixOS version: using the stable NixOS release, and allowing to explicitly select packages from unstable.
Manage NixOS configuration in ~/repo/dotfiles
.
home-manager examples are available in the test modules.
# Download flake locally
gh repo clone gwarf/dotfiles
cd ~/repos/dotfiles/
# Rebuild all system conf
# Used to make test, not changing conf available at boot
nix build ".#nixosConfigurations.brutal.config.system.build.toplevel"
sudo result/bin/switch-to-configuration switch
# Build and siwtch to the new conf, updating boot menu
sudo nixos-rebuild switch --flake .
# On macOS
nix flake update --commit-lock-file
darwin-rebuild switch --flake .
# In case the hostname changed (like on a VPN), it can be specified like this
./result/sw/bin/darwin-rebuild switch --flake . -p 'darwinConfigurations.Baptistes-MBP.system'
The first thing is to update the nix flake inputs, then rebuilding the system using those inputs.
# Rebuilding system
sudo nixos-rebuild switch --flake .
# upgrade nixpkgs **only** and rebuild flake-managed system
sudo nixos-rebuild switch --upgrade --update-input nixpkgs \
--commit-lock-file --flake ~/repos/dotfiles
# On macOS
nix flake update --commit-lock-file
darwin-rebuild switch --flake .
# List generations
nix-env -p /nix/var/nix/profiles/system --list-generations
# Delete all generations
nix-env --delete-generations old
# Delete generations older than 14d
nix-env --delete-generations 14d
# Delete specific generations
nix-env --delete-generations 10 11 14
# Collect garbage
sudo nix-collect-garbage -d
Using nix-darwin
, initially based on the video and gist from @jmatsushita:
- https://gist.github.com/jmatsushita/5c50ef14b4b96cb24ae5268dab613050
- https://youtu.be/KJgN0lnA5mk
- https://discourse.nixos.org/t/simple-workable-config-for-m1-macbook-pro-monterey-12-0-1-with-nix-flakes-nix-darwin-and-home-manager/16834
The flake can be updated as for other nix anf flake-based systems.
# Rebuild all system conf
nix build ".#darwinConfigurations.Baptistes-MBP.system"
# Switch to the new conf
./result/sw/bin/darwin-rebuild switch --flake .
See:
- NixOS Wiki: Python
- NixOS Wiki: Packaging Python
- mach-nix, to be replaced by dream2nix
Using a Nix flake templates for easy dev envs:
nix flake init --template github:the-nix-way/dev-templates#python
direnv allow
# Edit flake.nix as needed, adding packages or python packages.
Interesting approach to look into: reddit post allowing to use requirements.txt
- Practical Nix Flakes
- https://discourse.nixos.org/t/system-config-flake-with-darwin-and-linux-system-definitions/22343
- https://nixos.wiki/wiki/Home_Manager
- https://nix-community.github.io/home-manager/
- https://ghedam.at/24353/tutorial-getting-started-with-home-manager-for-nix
- Conf using unstable, nixos and nix darwin
- https://github.com/MatthiasBenaets/nixos-config
- https://github.com/water-sucks/nixed/blob/main/home/profiles/apps/kitty/default.nix
- https://github.com/Baitinq/nixos-config
- https://github.com/jonringer/nixpkgs-config
- https://github.com/fmoda3/nix-configs/blob/3d640ab43d676a8aad555bcd29527345554252d0/flake.nix#L70
- https://github.com/vhsconnect/nixos-config/blob/08f47336b280e21fe360567bfd9c663bd5f1844c/flake.nix#L3
- https://github.com/Thrimbda/charles/blob/08bb883cff19b01c66bbe25c62c06545ccf40a1c/flake.nix
- https://github.com/ttak0422/ENV/blob/1478ba70e1a3eddd4dab1b65c191cc320e5b6cf1/flake.nix
- https://github.com/voidcontext/nix-config/blob/695668066e358be43298eab796f16232a09ba24e/flake.nix
- https://discourse.nixos.