dotfiles/nix
2024-11-09 14:13:11 +07:00
..
lib refactor(nix): Use nixpkgs' vesktop now that it supports darwin 2024-11-07 09:08:52 +07:00
modules refactor(nix/darwin): Swap ESC<->CapsLock with Kanata 2024-11-08 11:11:41 +07:00
overlays refactor(nix/darwin): Swap ESC<->CapsLock with Kanata 2024-11-08 11:11:41 +07:00
systems refactor(nix/darwin): Swap ESC<->CapsLock with Kanata 2024-11-08 11:11:41 +07:00
users chore(nix): Add some firefox addons 2024-11-09 14:13:11 +07:00
.gitignore refactor: Move nix outside of .config dir 2024-11-05 13:53:13 +07:00
flake.lock refactor(nix): Use nixpkgs' vesktop now that it supports darwin 2024-11-07 09:08:52 +07:00
flake.nix chore(nix): Move stuff around 2024-11-06 11:58:09 +07:00
README.md docs(nix): Update documentation 2024-11-06 07:48:47 +07:00

null2264's Nix Setup

Structure

├── flake.lock
├── flake.nix
├── lib/                        # Self-explanatory, it contains helper functions
│   ├── mkCommon.nix
│   └── mkSystem.nix
├── modules/                    # Contains shared configuration across system, across user
│   └── home-manager
│       └── floorp.nix
├── overlays/                   # Nix overlays, self-explanatory
├── systems/                    # Contains configurations depending on what type OS nix is being used in
│   ├── darwin/                 # - macOS
│   │   ├── configuration.nix   # -- There supposed supposed to be a split here just like `nix/`, but I got lazy
│   │   ├── default.nix         # -- Where you register your Mac (based on hostname)
│   ├── nix/                    # - non-NixOS (Linux/BSD/etc..)
│   │   ├── default.nix         # -- Where you register your PC (based on hostname)
│   │   └── <hostname>/
│   │       └── default.nix
│   └── nixos/                  # - NixOS
└── users/                      # Contains configurations for multi-user setup
    ├── default.nix             # - Where you register the user(s)
    └── <user>/                 # - Recommended to split it to several nix files depending on the OS type you're planning to use
        ├── darwin.nix          # -- macOS
        ├── default.nix         # -- Common (works on all OS type)
        └── linux.nix           # -- Linux

Setup

Nix

It is recommended to install nix using Determinate Nix Installer or Nix's Official Installer (with --daemon flag, aka Multi-user installation) instead of whatever provided by your OS' package manager to avoid potential incompatibility.

macOS

Note

If you're using Alfred, to make Applications installed via Nix to appear on Alfred:

  • Open Alfred Preferences
  • General > Default Results > Extras > Click Advanced
  • Add com.apple.alias-file

Caution

This setup is NOT compatible with homebrew, it is designed to completely replaces homebrew. Uninstall homebrew before proceeding.

Nix in macOS is handled by nix-darwin.

Initial

This is done because nix-darwin commands is not yet added to PATH, should be a one-time thing

nix-env -iA nixpkgs.git
# Run `sudo chown $USER /nix/var/nix/profiles/per-user/$USER` if that returns error

nix build .#darwinConfigurations.<host>.system

./result/sw/bin/darwin-rebuild switch --flake .#<host>
# or
nix run nix-darwin -- switch --flake .#<host>

Rebuild

After initial setup, you should now be able to use the command directly:

darwin-rebuild build --flake .  # or you can specify the hostname with `--flake . #<hostname>`

# or if you're feeling lucky

darwin-rebuild switch --flake .

Other

Nix in non-NixOS Linux is handled by system-manager.

Rebuild

Unfortunately, root access is required in order to use system-manager.

sudo -i nix run 'github:numtide/system-manager' --extra-experimental-features "nix-command flakes" -- switch --flake $PWD

Home

This is for per-user setup. Instead of managing the entire system, you're managing one user at a time. This is handled by home-manager

Rebuild

home-manager build --flake .  # or you can specify the user with `--flake . #<username>@<hostname>`

# or if you're feeling lucky

home-manager switch --flake .