Skip to content

Repository files navigation

Nix Configuration

Overview

This is my NixOS + MacOS Nix shared configuration. It is based on merging two configurations:

  • nixos-config: This facilitates sharing packages between computers, I strongly recommend it as a base configuration to use as a base.
  • neusis: This is the config used for multiple servers in at the Broad Institute’s Imaging Platform. I use it to support multiple users on NixOS alongside Darwin.

Set up

I haven’t set it up from scratch in a new set of computers, but I will update it once I do.

Usage

Update home (Linux and Darwin)

The standalone home-manager entrypoint works the same on both platforms. It re-activates the user-level bits (dotfiles, user packages, fish/git/atuin config, user services / launchd agents) without touching system defaults, Homebrew, or /etc/nix/nix.custom.conf, and does not need sudo.

home-manager switch --flake .#your-username@your-hostname

Available entrypoints:

  • amunoz@moby (Linux)
  • alan@darwin001 (Darwin)
  • amunozgo@darwin002 (Darwin)

System rebuild

System-level changes (kernel/services on NixOS; Homebrew/dock/macOS defaults/launchd on Darwin) still go through the platform-specific rebuild.

NixOS

sudo nixos-rebuild switch --flake .#moby

Darwin

Requires sudo for Homebrew and system defaults. The flake exposes two Darwin configurations that share machines/darwin and only differ in user:

  • darwin001 → user alan
  • darwin002 → user amunozgo
nix --extra-experimental-features 'nix-command flakes' build .#darwinConfigurations.darwin001.system &&
  sudo ./result/sw/bin/darwin-rebuild switch --flake .#darwin001

Swap darwin001 for darwin002 on the other Mac.

Where should I add packages?

Relative to the root folder of the repo.

Applies toSystem-wide packagesHome Manager packages
Linux onlymodules/nixos/packages.nixhomes/$USER/packages_linux.nix
Darwin onlyNot supported yetmodules/darwin/packages.nix; packages_darwin.nix planned
Bothmodules/shared/packages.nixhomes/$USER/packages.nix

The platform-specific packages_* files contain package attribute names rather than pinned package derivations. For example:

[
  "racket"
  "haskellPackages.some-package"
]

packages.nix resolves these names against the active Home Manager pkgs. Consequently, Neusis chooses package versions when it consumes this home module, while standalone configurations use this flake’s package set. Dotted attribute paths are supported.

File structure

├── flake.lock
├── flake.nix
├── homes
│   ├── amunoz
│   │   ├── home.nix
│   │   ├── id_ed25519.pub
│   │   ├── moby.nix
│   │   ├── packages.nix
│   │   └── packages_linux.nix
│   ├── $USER # per-user specific config
│   │   ├── home.nix
│   │   ├── id_rsa.pub
│   │   ├── moby.nix
│   │   └── packages.nix
│   ├── darwin001
│   │   └── default.nix
│   └── moby # per-server specific config
│       ├── default.nix
│       ├── disko.nix
│       ├── filesystem.nix
│       └── hardware-configuration.nix
├── modules # Shared packages and config files
│   ├── darwin
│   │   └── packages.nix
│   ├── home-manager
│   │   └── default.nix
│   ├── nixos
│   │   ├── default.nix
│   │   └── packages.nix
│   └── shared
│       ├── config
│       │   └── emacs
│       │       ├── config.org
│       │       ├── init.el
│       ├── home-manager.nix
│       └── packages.nix
└── shell.nix
  

Current work

  • Trimming the fat
  • Isolate GPU packages and services
  • Getting a deeper understanding of the system
  • Add secrets
  • Manage firefox from nix

About

Reproducible OS for both Linux and MacOS

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages