nix
is a functional DSL (Domain Specific Language) for creating stable,
reproducible builds. It can be installed as a standalone program in any linux
distro and MacOS or on top of it’s own distro, NixOS
.
After some months of experimenting with nix
, I’ve come to see it as the ‘missing
glue’ of the unix philosophy. In the unix philosophy, the operating system is
composed of programs that do ‘one thing’ and do it well. While this facilitates
that new programs can be easily made by rearranging already existing tools,
there is a big hole when it comes to how one should obtain these tools and set
them up to be ready for use.
Package managers in other linux distributions try to fill in this hole. However,
Nix
is one of a handful that offer guarantees of reproducibility and near
endless customization through it’s DSL, making it ideal for developers.
- Clone this repository in
/etc/nixos
.Back up all the files there before-hand, specially
configuration-hardware.nix
.git clone [email protected]:danilevy1212/nixos.git /etc/nixos
- Create the folder in
hosts/<name-of-host>
, and move the backed-upconfiguration-hardware.nix
there. - Add a minimal
default.nix
that importsconfiguration-hardware.nix
,common.nix
andhome.nix
. - Add a your host configuration in
flake.nix
:... nixosConfigurations.<name-of-host> = nixpkgs.lib.nixosSystem { inherit system; modules = [ home-manager.nixosModules.home-manager ./common ./hosts/<name-of-host> ]; specialArgs = { unstable = (import nixpkgs-unstable { inherit system; config.allowUnfree = true; }); }; } ...
- Build that
NixOS
. Set the path to the host configuration.sudo nixos-rebuild switch --flake '/etc/nixos/.#<name-of-host>'
- Make
dlevym
the owner of all the files and folders of/etc/nixos
.sudo chown -R dlevym:users /etc/nixos
- Install my doom emacs configuration, for maximum enjoyment!
doom env && doom tangle && doom install
To update all inputs:
sudo nix flake update
To update a specific input:
sudo nix flake lock --update-input <input-name>
You can use `nix repl` to check the values of your NixOS and home-manager configurations. This can be incredibly useful for debugging and understanding how your system is configured.
To inspect NixOS configuration values, follow these steps:
- Open a terminal.
- Start a Nix REPL by entering the following command:
$ nix repl
You will see a welcome message indicating that you are in the Nix REPL.
- Load your NixOS configuration:
nix-repl> :lf /etc/nixos
This loads your NixOS configuration into the REPL.
- You can then access specific configuration values using the following format:
nix-repl> nixos.<system>.config.<...>
Replace `<system>` and `<…>` with the specific components of your NixOS configuration you want to inspect.
If you want to check home-manager-specific values within your NixOS configuration, use these steps:
- Open a terminal.
- Start a Nix REPL by entering the following command:
$ nix repl
- You can access home-manager configuration values within your NixOS configuration using the following format:
nix-repl> nixosConfigurations.<system>.config.home-manager.users.<username>.<...>
Replace `<system>`, `<username>`, and `<…>` with the specific components of your home-manager configuration you want to inspect.