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 git@github.com:fmoda3/nix-configs.git ~/.nix-configs
Substitute personal-laptop
for current machine's configuration
cd ~/.nix-configs
nix build ".#darwinConfigurations.personal-laptop.system"
./result/sw/bin/darwin-rebuild switch --flake ".#personal-laptop"
cd ~/.nix-configs
nix build ".#nixosConfigurations.personal-laptop.system"
sudo ./result/sw/bin/nixos-rebuild switch --flake ".#personal-laptop"
If the flake.lock needs to be updated:
nix flake update
To rebuild after making changes:
darwin-rebuild build --flake ".#personal-laptop"
darwin-rebuild switch --flake ".#personal-laptop"
sudo nixos-rebuild build --flake ".#personal-laptop"
sudo nixos-rebuild switch --flake ".#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).
Substitute bootable-x86_64-iso
for the image configuration you want to build
nix build ".#images.bootable-x86_64-iso"
This image builds a bootable iso, that boots into a standard NixOS installation, with a script that installs the cicucci-builder
nixos system configuration to the disk.
- Build the iso via
nix build ".#images.cicucci-builder-iso"
- Boot the iso on new machine (either a VM, or burn to usb drive and boot from it on a physical machine)
- After the terminal prompt appears, run
This will partition and mount the drive using the Disko config in the
sudo install-system
cicucci-builder
configuration, and then install thecicucci-builder
configuration itself. - Once complete,
sudo reboot
to boot into the freshly installed system. - To make updates after install, clone this repo, and follow the updating steps above.
This image builds the cicucci-builder
configuration directly into a vmware image. After building, the image can be booted from vmware.
This image builds a bootable sd image, that boots directly into a system with the cicucci-dns
configuration. This configuration is intended to be used on a Raspberry Pi 3.
- Build sd via
nix build ".#images.cicucci-dns-sd"
- Burn sd image to an sd card using a sd burning utility of your choice.
- Boot Raspberry Pi directly from sd. The
cicucci-dns
system will already be installed.
Note that the sd image doesn't have a Disko config and therefore doesn't do any partition or mounting. This is because the base NixOS sd image automatically resizes the base partition to fill the available size of the sd card on first boot.
These images are general purpose installers, that don't target a specific configuration. They do add a few pieces of my config on top of the base installer that are useful to have, like my zsh configs.
I use deploy-rs to deploy the cicucci-dns
configuration remotely to my Raspberry Pi. I do this because running nixos-rebuild
on the Pi itself is very slow. I deploy from a macOS machine, that is also running a NixOS vm, setup with the cicucci-builder
configuration.
- Ensure a
aarch64-linux
machine is available to build. I run anaarch64-linux
NixOS vm with thecicucci-builder
configuration inside vmware on aaarch64-darwin
machine. - If the
aarch64-linux
machine is a remote builder (i.e., not your current machine), ensure that your current machine'sroot
user can ssh into theroot
user of the remote builder, via ssh key authentication (add your computer's public rsa key into theauthorized_keys
file of the remote builder) - Ensure that the user you are going to deploy from on your current machine can ssh into the
root
user of the Raspberry Pi, also via ssh key authentication explained above.
- Simply run
deploy
The templates are for initializing project specific nix flakes into their directories.
Substitute elixir
with the template you want in the commands below.
nix flake init --template "github:fmoda3/nix-configs#elixir"
nix flake new --template "github:fmoda3/nix-configs#elixir" ${NEW_PROJECT_DIRECTORY}
This flake's formatting is set to use nixpkgs-fmt
. Formatting works via
nix fmt
This flake uses the pre-commit-hook project run git hooks on commit. Currently, it verifies that the flake is properly linted and formatted before commit.
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