C.W.K.
Stream
Lesson 04 of 05 · published

Store, Generations, Flakes, nix-darwin

~13 min · nix, concepts, internals

Level 0초심자
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

4개 개념이 대부분의 Nix 출력과 대부분의 Nix flake 읽기에 충분. 그 4개 너머는 필요할 때 키워.

Nix Store (/nix/store). 모든 패키지, 모든 버전, 모든 variant 가 /nix/store/<hash>-<name>/ 에 살아. hash 는 전체 빌드 레시피에서 계산 — 모든 입력, 모든 의존성, 모든 flag. 그래서 두 빌드가 절대 충돌 안 하는 이유: 다른 입력 = 다른 hash, 다른 path.

Generations 와 rollback. 모든 install 또는 업그레이드가 사용자 프로필의 새 번호 'generation' 만들어. nix-env --rollback 가 active pointer 한 generation 뒤로 — 즉시, atomic, 되돌릴 수 있음. nix-env --list-generations 로 generation 목록; nix-env --switch-generation <n> 로 특정 generation 점프.

Flakes 는 Nix 프로젝트 구조의 단위. flake.nixinputs (의존하는 nixpkgs 버전, 사용하는 다른 flake) 와 outputs (dev shell, 패키지, NixOS 모듈, 앱) 선언. flake.lock 가 옆에 앉아 모든 input 의 정확한 버전 핀 — package-lock.json 이나 uv.lock 와 같은 재현성 보장, 단 전체 dev 환경에 대해.

nix-darwin 는 macOS 용 Nix 모듈 set. nix-darwin 으로 Mac 전체 선언적으로 관리 — 깐 패키지, Dock 배열, Finder 환경설정, Homebrew casks, services, 로그인 항목 — 다 버전 관리되는 Nix 코드로. darwin-rebuild switch 로 변경 적용. 상상할 수 있는 가장 야심찬 dotfiles 셋업, Mac 들 사이에 재현 가능.

Code

Nix store 와 generations 들여다보기·bash
# store 봐
ls /nix/store/ | head
# 각 항목은 <hash>-<name>-<version>

# active 사용자 프로필
ls -la ~/.nix-profile
# -> /nix/var/nix/profiles/per-user/$USER/profile

# generations 목록
nix-env --list-generations
#   1   2026-04-01 ...
#   2   2026-04-15 ... (current)
#   3   2026-05-03 ... (current)

# 이전 generation 으로 rollback
nix-env --rollback

# 또는 특정으로 점프
nix-env --switch-generation 2
flake.lock — 재현성 봉인·json
// 'nix flake update' 가 자동 생성. 정확한 commit 에 핀.
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1714389366,
        "rev": "6a5b8...",
        "type": "github",
        "owner": "NixOS",
        "repo": "nixpkgs"
      }
    }
  },
  "root": { "inputs": { "nixpkgs": "nixpkgs" } },
  "version": 7
}

External links

Exercise

'nix-env --list-generations' 돌려 (적어도 하나 있을 거). Nix 거의 안 써도 'generations' 개념이 자기 목록 보면 클릭됨. 타임스탬프 읽어 — 각각이 돌아갈 수 있는 스냅샷.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.