Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.71 KB

why-nix.md

File metadata and controls

50 lines (35 loc) · 1.71 KB

Why use Nix and NixOS

There any many many reasons to use nix and NixOS. Far more than one person can likely describe in a markdown file. The primary appeal for me is the managment aspect that it allows. Having a fully reproducible development/server environment across several machines is a hard bargain to turn down.

Reproducibility

Nix ensures that software builds are reproducible. This means that it will build the same way on my machine as it does on yours, eliminating the "works on my machine" problem.

Configuration as Code

With NixOS, the entire system configuration can be declared in a single repository. This approach not only simplifies management but also enhances portability and version control.

# Sample system configuration snippet
{ config, pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    vim
    git
  ];
}

Control with Flakes

Flakes in Nix provide a more controlled and manageable way to handle inputs and outputs. They offer a declarative and reproducible package management system. Flakes are used to build system configurations, development shells, packages and the nixpkgs monorepo itself. They provide a common interface and entry-point to any .nix code.

# Example of a flake
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };

  outputs = { self, nixpkgs }: {
    nixosConfigurations.my-config = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ ./configuration.nix ];
    };
  };
}

Conclusion

This is by no means an exhaustive list of the reasons to explore the nixpkgs ecosystem as well as .nix and NixOS but it might help to give you an idea.