Skip to content

danilevy1212/nixos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dan’s nix config

Introduction

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.

Installation

  1. 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
        
  2. Create the folder in hosts/<name-of-host>, and move the backed-up configuration-hardware.nix there.
  3. Add a minimal default.nix that imports configuration-hardware.nix, common.nix and home.nix.
  4. 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;
          });
        };
      }
    ...
        
  5. Build that NixOS. Set the path to the host configuration.
    sudo nixos-rebuild switch --flake '/etc/nixos/.#<name-of-host>'
        
  6. Make dlevym the owner of all the files and folders of /etc/nixos.
    sudo chown -R dlevym:users /etc/nixos
        
  7. Install my doom emacs configuration, for maximum enjoyment!
    doom env && doom tangle && doom install
        

Updating flake dependencies

To update all inputs:

sudo nix flake update

To update a specific input:

sudo nix flake lock --update-input <input-name>

Checking Configuration Values

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.

NixOS Configuration Values

To inspect NixOS configuration values, follow these steps:

  1. Open a terminal.
  2. 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.

  3. Load your NixOS configuration:
    nix-repl> :lf /etc/nixos
        

    This loads your NixOS configuration into the REPL.

  4. 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.

Home-Manager Configuration Values

If you want to check home-manager-specific values within your NixOS configuration, use these steps:

  1. Open a terminal.
  2. Start a Nix REPL by entering the following command:
    $ nix repl
        
  3. 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.

Reference