Giter VIP home page Giter VIP logo

configs's Introduction

Configs

This repo contains the nix based system configurations used across my different devices.

Installation

This installation follows along with the nix manual installation chapter until we get to the “Cloning the configs” step. I’ve kept the full steps here as a reminder to myself of exactly how I set things up in case I need to debug issues.

I do use some shell variables throughout the different snippets. Here’s a starter that will make copy and paste easier:

export EDITOR=nano
export HOSTNAME=fixme
export PATH_TO_CONFIGS=$HOME/Code/configs

The installation steps are pretty different between NixOS and MacOSX so I’ve kept them totally separate here.

MacOSX

OSX configuration is a special kind of hell. This setup uses the wonderful nix-darwin for a NixOS like system configuration.

Installing nix

Nix needs to use /nix as the directory for it’s store. OSX post Catalina has a read-only system volume. See this nix github issue for more details.

The point is we need to create a synthetic volume for /nix that looks like a system directory but is writable. This can be accomplished via the installer.

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

Security Note: This assumes that you’re using FileVault to encrypt the whole disk at rest

Installing nix-darwin

nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer

Installing home-manager

I use home-manager for a lot of the dirty work of changing dotfiles.

The install process for this is dead simple, just add the channel.

nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager
nix-channel --update

Cloning the Configs

You’ll want to git clone this repo somewhere.

git clone https://github.com/a4wc6n/configs.git $PATH_TO_CONFIGS

Telling Secrets

There are a fair number of things that I don’t want out in public, passwords, private keys, etc.

For this I use git-crypt

Creating a New Host

All you need to do to create a new host is copy the template to a host and fill it out.

mkdir $PATH_TO_CONFIGS/hosts/$HOSTNAME
cp $PATH_TO_CONFIGS/templates/hosts/darwin/configuration.nix $PATH_TO_CONFIGS/hosts/$HOSTNAME
$EDITOR $PATH_TO_CONFIGS/hosts/$HOSTNAME

Installing the Configs

By default darwin-rebuild will look in \~/.nixpkgs/darwin-configuration.nix. In order to get it to look in the right place we’ll need to run like:

darwin-rebuild switch -I darwin-config=$PATH_TO_CONFIGS/hosts/$HOSTNAME/configuration.nix

After the first time you should be able to run it without the -I argument as long as you don’t move the configs directory.

Extra Steps

are there other steps I’m missing?

NixOS

You’ll need some secrets that shouldn’t be published on the internet. First create `/etc/nixos/secrets.nix`. You can start with copying the template `./nix/secrets.template.nix`

“`sh cp ./nix/secrets.template.nix /etc/nixos/secrets.nix chown root:root /etc/nixos/secrets.nix sudo $EDITOR /etc/nixos/secrets.nix “`

Actually, I’m now doing it via symlinks.

“`sh ln -s $CONFIG_REPO_PATH/nix/devices/$DEVICE/configuration.nix /mnt/etc/nixos/configuration.nix “`

Organization & Structure

The repo is broken out into the following directories:

hosts

The hosts directory contains the entry point for the configuration of different hosts based on their host name.

profiles

The profiles directory contains groups of configuration and packages based on the different roles that a machine might play. For example, my development machines should include emacs, web servers shouldn’t.

config

The config directory contains isolated configuration for packages and services.

TODO: more?

  • modules
  • secrets

Acknowledgements

  • nix-darwin
  • nixos
  • home-manager

-

configs's People

Contributors

andrewclarkson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.