Note
The general structure of this configuration is based on Misterio77/nix-starter-configs.
If you plan on setting this up on macOS or another non-NixOS Linux distribution, you can skip ahead here.
Install NixOS on a new host by following the installation instructions in the NixOS manual. After successfully installing NixOS, proceed to the next section.
Clone this repository (preferrably, under $HOME/my-nix-config
).
After that, from within the root folder of the repository, you can:
First, locate the hardware-configuration.nix
that was generated
during the installation under /etc/nixos/hardware-configuration.nix
,
and copy it into the nixos folder of this repository.
Rename it as desired, it will be referenced within the configuration.nix
that you create for your current system.
After that, create a new host in the nixosConfigurations
attribute
in flake.nix. This host will be used from now on
as an entrypoint to rebuild your current system with the specified
configuration files.
Finally, you can run the following command to rebuild NixOS from the config specified for your host in flake.nix:
sudo nixos-rebuild switch --flake ".#<host>"
First, create a new user@host in the homeConfigurations
attribute
in flake.nix. This user@host will be used from now on
as an entrypoint to rebuild your current home with the specified home-manager
configuration files.
After that, you can build the home configuration with the following command:
home-manager switch --flake ".#<user>@<host>"
Enabling dotfiles for iTerm2 on macOS
If you are on macOS and want to use iTerm2, you will need to configure it to get the configuration from the dotfiles. To do that, enable the "Load settings from a custom folder or URL" checkbox, introduce the path to the iTerm2 dotfiles folder in there, and select "Save changes > Automatically" (if you want to save any changes you do in the configuration).
To play around with the flake and the attribute sets, you can open a REPL by running the following command from within the repository root folder:
nix repl --expr "builtins.getFlake \"$PWD\""
Then, load the attributes provided by nixpkgs:
:l <nixpkgs>
Finally, you can import any of the modules by passing it the necessary arguments:
common = import ./home-manager/common.nix {inherit config outputs; pkgs = homeConfigurations."david@yorha".pkgs;}
This can happen if you have created a new file and tried to perform
a nixos-rebuild
or home-manager
command without first staging that file in Git.
Always remember to stage files before rebuilding!