Skip to content

bigolu/system-configurations

Repository files navigation

System Configurations

built with nix

This repository holds the Home Manager and nix-darwin configurations for my machines. I don't expect anyone else to use this, but I figured I'd leave the repo public as a resource for people who want to manage their systems similarly.

Table of Contents

Prerequisites

To apply a configuration, you'll need Nix, a package manager. This section will show you how to install Nix and configure it to use this repository's binary cache to speed up builds.

Installing Nix

I recommend using the Determinate Systems installer over the official installer for the following reasons:

  • It has an uninstaller
  • It enables two experimental features that are used in this readme, flakes and a new commandline interface.

You can find more differences between the two in the "Installation Differences" section of the Determinate Systems Installer README.

When using the installer I suggest adding an extra option, trusted-users, which will add the current user to the list of trusted users. This is helpful since some actions in Nix require that the user be trusted, such as using a binary cache (explained below). Below is the installation command with the extra option:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \
  | sh -s -- install --extra-conf "trusted-users = $(whoami)"

NOTE: Please confirm that everything in the command provided above, besides the extra option, is up-to-date with what is currently listed on the Installer Website.

Using the Binary Cache (optional)

To avoid having to build everything on your machine, you can configure Nix to use this repository's binary cache using the steps below:

  1. Check to see if you are a trusted user. If you aren't, then add yourself to trusted-users.

  2. After running one of the nix commands from the "Applying a Configuration" section or "Running the Home Configuration" section below, reply yes to the prompts to add the cache.

Applying a Configuration

  1. Start a shell with the home config. It comes with direnv, which we'll need in future steps. Check the "Running the Home Configuration" section for instructions. This shell will also be helpful for debugging any problems you encounter while applying the config since you'll have access to all the tools/shortcuts included in the home config.

  2. Clone the repository and go into its directory by running git clone https://github.com/bigolu/system-configurations.git ~/code/system-configurations && cd ~/code/system-configurations

  3. Run direnv allow to set up the development environment.

The next steps depend on the operating system you're using:

Linux

  1. Apply the Home Manager configuration by running just init-home-manager <host_name> where <host_name> is one of the hosts defined in the Home Manager flake module.

  2. Additional Setup

    • Run the following commands from the root of the repository. These commands run scripts that require root privileges and therefore can't be done in Home Manager:

      • ./dotfiles/nix/set-locale-variable.bash

      • ./dotfiles/nix/nix-fix/install-nix-fix.bash

      • ./dotfiles/nix/systemd-garbage-collection/install.bash

      • ./dotfiles/smart_plug/linux/install.bash

macOS

  1. Partially disable System Integrity Protection for yabai. Instructions can be found on the yabai wiki.

  2. I install some Homebrew packages through nix-darwin, but nix-darwin doesn't provide brew so you'll have to install it yourself. Check the site for instructions: brew.sh.

  3. Apply the nix-darwin configuration by running just init-nix-darwin <host_name> where <host_name> is one of the hosts defined in the nix-darwin flake module.

  4. Some settings in nix-darwin only take effect after a logout/restart so restart now.

  5. Additional Setup

    • Keyboard:

      • Set the keyboard input source to 'Others → (No Accent Keys)'.
      • Shortcuts:

        • Disable: "Select the previous input source" ctrl+space, "Application windows" ctrl+↓

        • Change: "Mission Control → Move left/right a space" to cmd+[ and cmd+] respectively, "Mission Control" to cmd+d, "Mission Control → Switch to Desktop 1-9" cmd+[1-9]

    • Open Hammerspoon, Finicky, MonitorControl, UnnaturalScrollWheels, Nightfall, and "Mac Mouse Fix" to configure them.

Running the Home Configuration

You can also run a shell or terminal with the home configuration already loaded in it. This is helpful when you only need to use the configuration temporarily and not apply it, like when you're in a remote host. The executable is a self-extracting archive (SEA) that contains all the command-line programs I use, as well as my config files for them. Just run one of these commands, depending on whether you have wget or curl:

curl -fsSL https://raw.githubusercontent.com/bigolu/system-configurations/master/.github/run.sh | sh -s -- <type>

wget -qO- https://raw.githubusercontent.com/bigolu/system-configurations/master/.github/run.sh | sh -s -- <type>

where <type> can be shell or terminal.

NOTE: While the SEA doesn't depend on any programs on your computer, it does require that you have a /tmp directory. You can read this GitHub issue comment regarding a "rootless Nix" to see why this is needed, as well as learn more about how this works.

Troubleshooting

  • Cache is being ignored: First, check to see if you are a trusted user. If you aren't, then add yourself to trusted-users. Since I don't know of a way to have Nix re-prompt you to add the cache you'll have to do it manually. You can do this by adding the lines below to your config in ~/.config/nix/nix.conf (If you have a multi-user Nix installation, you'll need to restart the Nix daemon afterward to apply the changes.):

    extra-substituters = https://bigolu.cachix.org
    extra-trusted-substituters = https://bigolu.cachix.org
    extra-trusted-public-keys = bigolu.cachix.org-1:AJELdgYsv4CX7rJkuGu5HuVaOHcqlOgR07ZJfihVTIw=
  • apfs.util isn't working: Make sure that /etc/synthetic.conf has the permission 0644.

How-tos

  • Restart the Nix daemon:

    • Linux: Run systemctl restart nix-daemon.service

    • macOS: Run sudo launchctl stop org.nixos.nix-daemon && sudo launchctl start org.nixos.nix-daemon

  • Check if you are a trusted user:

    • single-user Nix installation: The user that installed Nix is always trusted in a single user installation.

    • multi-user Nix installation: Run nix show-config and look for your $USER in the trusted-users key.

  • Add yourself to trusted-users:

    • Run echo "extra-trusted-users = $USER" | sudo tee -a /etc/nix/nix.conf to add yourself as a trusted user in the Nix system configuration. Then restart the Nix daemon to apply the changes.