The following will install single-user on Linux and multi-user on macOS:
sh <(curl -L https://nixos.org/nix/install)
To install multi-user on Linux:
sh <(curl -L https://nixos.org/nix/install) --daemon
Enable Flakes by creating a file in ~/.config/nix/nix.conf
and adding the following:
experimental-features = nix-command flakes
The following will install Nix on either Linux or macOS:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Flakes should already be enabled after install with this method
nix-shell -P git # If you need access to git
git clone [email protected]:tlein/nix-configs.git ~/.nix-configs
Substitute macos-personal-laptop
for current machine's configuration
cd ~/.nix-configs
nix build ".#darwinConfigurations.macos-personal-laptop.system"
./result/sw/bin/darwin-rebuild switch --flake ".#macos-personal-laptop"
cd ~/.nix-configs
nix build ".#nixosConfigurations.macos-personal-laptop.system"
sudo ./result/sw/bin/nixos-rebuild switch --flake ".#mac-ospersonal-laptop"
If the flake.lock needs to be updated:
nix flake update
To rebuild after making changes:
darwin-rebuild build --flake ".#macos-personal-laptop"
darwin-rebuild switch --flake ".#macos-personal-laptop"
sudo nixos-rebuild build --flake ".#macos-personal-laptop"
sudo nixos-rebuild switch --flake ".#macos-personal-laptop"
- Create a new folder in the
hosts
folder with the name of the configuration. - Inside that folder, create a
configuration.nix
with a NixOS or Darwin config, and ahome.nix
with a home manager config. - Add a new configuration to either the
nixosConfigurations
ordarwinConfigurations
block of theflake.nix
, specifying the system type, host (the name of the folder from step 1), and user (to install the home manager config to).
This flake uses the devshell project to easily setup a dev environment when in this project's directory. It adds a few packages to the environment, as well as aliases to format, lint, and build various images.
To enter the devshell without direnv
, run
nix develop
If you use direnv
, it should become available anytime you are in the directory after running
direnv allow