Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 2.03 KB

nix-getting-started.md

File metadata and controls

60 lines (40 loc) · 2.03 KB

NixOS Getting Started

For information about NFS, where to place your projects. see this README. TL;DR: Your home directory is a NFS share, which is backed up. Do not place VM images/projects/... there. Use /scratch/$USER if you need fast, local disk access. This directory is not backed up.

Packages

  • Where to look for packages: https://search.nixos.org
  • Find packages by filename: nix-locate someheader.h (nix-locate is installed on our servers).
  • Temporary vs. Global: If you temporarily need a package, use nix-shell -p package. If you need permanently installed packages for your user, consider home-manager.

Development Environment

Flakes or Nix Shells: Choose either format to define your project dependencies.

Flakes (recommended)

If you're inside a git project, git add flake.nix, as nix cannot find it otherwise.

For templates, see ../templates/README.md.

  • Enter the dev shell: Run nix develop or use direnv (see later section).
  • Check-in the lockfile: Commit the flake.lock generated by nix develop to guarantee reproducibility.

Nix Shells

Legacy option, still suitable for certain uses. Example:

with import <nixpkgs> { };
pkgs.llvmPackages_latest.stdenv.mkDerivation {
  name = "llvm-debug-env";
  nativeBuildInputs = [
    pkgs.clang
  ];
  MY_VAR = "Hello";
}

Enter the dev shell: Run nix-shell shell.nix or use direnv (see later section).

Direnv

Automatic Setup: Add use flakes or use nix to your .envrc. This will automatically load/unload your development environment when you enter the directory containing it. Add .direnv to your .gitignore.

Home Manager

Installation

nix-shell '<home-manager>' -A install

Installing home manager should create a .config/home-manager/home.nix. Alternatively, you can also check ../templates/README.md.

  • Apply Changes: Run home-manager switch to update your configuration.