-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add notes on Nix package manager installation and usage
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: | ||
date: 2025-01-02T00:03 | ||
dg-publish: true | ||
dg-permalink: "" | ||
description: "" | ||
tags: | ||
- | ||
--- | ||
> 沒什麼組織、一些倏忽即逝有趣或不有趣的想法 | ||
- Nix 初探 | ||
- Installation - https://nix.dev/install-nix | ||
- `sh <(curl -L https://nixos.org/nix/install)` | ||
- What it does: | ||
- Install Nix package manager | ||
- Create a new profile for the current user | ||
- Add the Nix profile to the user's shell profile | ||
- Based on the installation log, here are the critical changes Nix made to your machine: | ||
- File System Changes: (this is because macOS now (starting in 10.15 Catalina) has a read-only root directory. To support Nix, it will create a volume and configure macOS to mount it at /nix) | ||
Created a dedicated encrypted volume called "Nix Store" mounted at `/nix` | ||
Modified `/etc/synthetic.conf` to create the mount point | ||
Modified `/etc/fstab` to specify volume mount options | ||
- User and Group Creation: | ||
Created a system group called `nixbld` with GID 350 | ||
Created 32 system users (_nixbld1 through _nixbld32) with UIDs 351-382 | ||
All build users are: | ||
Set to have /var/empty as home directory | ||
Disabled from logging in | ||
Added to the nixbld group | ||
Hidden from the system | ||
- Directory Structure: | ||
Created several directories under /nix, including: | ||
`install: mkdir /nix/var` | ||
`install: mkdir /nix/var/log` | ||
`install: mkdir /nix/var/log/nix` | ||
`install: mkdir /nix/var/log/nix/drvs` | ||
`install: mkdir /nix/var/nix` | ||
`install: mkdir /nix/var/nix/db` | ||
`install: mkdir /nix/var/nix/gcroots` | ||
`install: mkdir /nix/var/nix/profiles` | ||
`install: mkdir /nix/var/nix/temproots` | ||
`install: mkdir /nix/var/nix/userpool` | ||
`install: mkdir /nix/var/nix/daemon-socket` | ||
`install: mkdir /nix/var/nix/gcroots/per-user` | ||
`install: mkdir /nix/var/nix/profiles/per-user` | ||
`install: mkdir /nix/store` | ||
`install: mkdir /etc/nix` | ||
- Shell Configuration: | ||
Backed up and modified shell configuration files: | ||
`/etc/bashrc` | ||
`/etc/zshrc` | ||
Added Fish shell configurations | ||
Added Nix environment setup scripts to these files (e.g. execute `. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'`) | ||
- System Services: | ||
Created a LaunchDaemon at /Library/LaunchDaemons/org.nixos.nix-daemon.plist | ||
Set up a service to automatically mount the Nix volume | ||
- Package Management: | ||
Installed Nix package manager under `/nix/store/` | ||
Set up the default profile with basic packages including SSL certificates (nss-cacert) | ||
|
||
These changes make Nix work as a separate package manager on macOS, isolated from the rest of your system in its own volume. | ||
- Usage | ||
- `nix-shell -p <package>`: Start a shell with the specified package available | ||
- `nix-shell -p <package> --command <command>`: Run a command in a shell with the specified package available | ||
- `nix-shell -p <package> --run <command>`: Run a command in a shell with the specified package available and exit | ||
- `nix-store --gc`: Garbage collect the Nix store to remove unused packages |