• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    Nix
  • Created over 9 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Instructions and scripts related to getting NixOS running on a newer generation MBP

NixOS on MBP

This is a repo that will house notes and scripts related to getting NixOS running on a newer generation (late 2013+) MacBook Pro laptop (Retina).

Preparing Installation Media

Contrary to other reports on the internet (in the wild) you do not need to prerpare your bootable USB installer on another Linux distro.

You should be using 16.03 or 16.09 images at this point!

As of 2016-10-15 here are the latest nixos image download locations:

Download the minimal ISO from the link above.

The command I used on my NixOS box was the following, though on OSX you should be able to use /dev/disk2 or similar after unmounting the USB drive in OSX.

When preparing your USB install drive on Linux run:

sudo dd bs=4M if=path/to/nixos-minimal-16.09-x86_64-linux.iso of=/dev/sdc

When preparing your USB install drive on OS X or BSD-based distributions run:

sudo dd bs=4m if=path/to/nixos-minimal-16.09-x86_64-linux.iso of=/dev/disk2

Before Installing

You will need to resize your OSX partition. I did this by booting into the OSX Recovery partition and using the Disk Utility from there.

To boot into the Recovery partition you hold down the Cmd+R keys on boot startup until you see it enter Recovery mode.

Boot USB Drive

Boot from the USB drive by holding down the Option key during the boot startup tone until you see options of devices to boot from.

You will likely need to choose the second option called 'EFI Boot'.

Preparing Partitions in Stage2

If you are unsure on how to configure your partitions consult the man gdisk. I suggest the following basic setup (this is what I did):

$ sudo gdisk -l /dev/sda

GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 490234752 sectors, 233.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): XXXXXXXXXXXXXXXXXXXXXXXX
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 490234718
Partitions will be aligned on 8-sector boundaries
Total free space is 6 sectors (3.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640        98957655   47.0 GiB    AF05  Customer
   3        XXXXXXXX       XXXXXXXXX   620.0 MiB   AB00  Recovery HD
   4       XXXXXXXXX       XXXXXXXXX   170.0 GiB   8300  nixosroot
   5       XXXXXXXXX       XXXXXXXXX   16.0 GiB    8200  nixosswap

I did this with the following commands after stage2 loaded in the NixOS installer:

# cryptsetup luksFormat /dev/sda4
# cryptsetup luksOpen /dev/sda4 nixosroot
# mkfs.ext4 /dev/mapper/nixosroot
# mkswap -L nixosswap /dev/sda5

If you do not already have a vfat filesystem for boot images you will need to run the following command (I didn’t need to do this):

# mkfs.vfat /dev/sda1

Now we need to mount the new or existing filesystems:

# mount /dev/mapper/nixosroot /mnt
# mkdir /mnt/boot
# mount /dev/sda1 /mnt/boot
# swapon /dev/disk/by-label/nixosswap

Make sure you mount /dev/sda1 under /mnt/boot.

After that run: nixos-generate-config --root /mnt

After this you may want to modify the configuration.nix to include gummiboot.

Then run: nixos-install

Configuration Post-Install

My /etc/nixos/configuration.nix for the MBP can be found at etc/nixos/configuration.nix.

Some parts of note that are required for the MBP are:

Boot Options

Use gummiboot. I got gummiboot working straight away.

{
  # Other stuff up here....

  boot.loader.grub.enable = false;
  boot.loader.systemd-boot.enable = true;
  # Whether or not the installation process should modify EFI boot variables
  boot.loader.efi.canTouchEfiVariables = true;
  # If you rely on a dirty /tmp dir you are doing it wrong. Your laptop will
  # never be cattle.
  boot.cleanTmpDir = true;
  # This gets your audio output and input (mic) working
  boot.extraModprobeConfig = ''
    options libata.force=noncq
    options resume=/dev/sda5
    options snd_hda_intel index=0 model=intel-mac-auto id=PCH
    options snd_hda_intel index=1 model=intel-mac-auto id=HDMI
    options snd_hda_intel model=mbp101
    options hid_apple fnmode=2
  '';

  # some other stuff below here
}

See the full base configuration at configuration.nix.

Tidbit: Audio

If you use xmonad and you want to attach your Fn keys to the appropriate audio behaviors you are accustomed to on OSX/Darwin then you can take a look at my xmonad.hs file.

For those just interested in the raw commands here they are below:

$ amixer -q set Master toggle # mute/unmute
$ amixer -q set Master 5%- # decrease volume by 5%
$ amixer -q set Master 5%+ # increase volume by 5%

Tidbit: Brightness / Visual Tempurature

Some of you may be familiar with OSX apps that changes your brightness and screen tone based on the time of day.

On Linux the best one I could find was redshift which is configurable in NixOS via the builtin module.

Here is an excerpt from my latest /etc/nixos/configuration.nix file for redshift configs:

  services.redshift.enable = true;
  services.redshift.brightness.day = "0.8";
  services.redshift.brightness.night = "0.4";
  services.redshift.latitude = "0.0000";
  services.redshift.longitude = "0.0000";

For the raw commands to use to increase or decrease brightness see below:

$ cat /sys/class/backlight/acpi_video0/brightness # echos current brightness level
10
$ cat /sys/class/backlight/acpi_video0/max_brightness # echos max brightness level
100
$ echo 25 | sudo tee /sys/class/backlight/acpi_video0/brightness # sets brightness to 25/100
$ cat /sys/class/backlight/acpi_video0/brightness
25

HTH!

More Repositories

1

styleguides

A repository with a coding standard/style guide and conventions document for each of the languages I care about
Shell
100
star
2

twitter4r

OLD repository: Please see http://github.com/twitter4r/twitter4r-core for latest official repository for project.Twitter4R: The most Ruby-like bindings for the Twitter.com REST API by a long way. (Anyone want to take over? I don't have time for Ruby OSS projects any more)
Ruby
89
star
3

rebar-templates

Rebar Erlang, OTP and other project templates. Use rebar3 for rebar3 templates and updates.
Erlang
68
star
4

7languages7weeks

Repository for my journey through the #7languages7weeks challenge, plus blog.
Ruby
32
star
5

cabal-heroku-buildpack

ANCIENT REPO. ARCHIVED. A Heroku buildpack for Haskell/Cabal applications
Shell
20
star
6

carson

Carson is the butler from Downton Abbey. A fine butler indeed. Jenkins and Hudson suck arse. Carson will replace them for software projects requiring true continuous +delivery+ tooling.
Erlang
17
star
7

sinatra-on-nix

An example Sinatra project using Nix to configure the development environment
Nix
14
star
8

welltypedfp

Curriculum, and materials including exercises for an internal course on typed pure functional programming
10
star
9

lambda-purescript-starter

Starter template project for building AWS Lambdas with PureScript
PureScript
9
star
10

vim-rebar

Rebar Vim plugin
Vim Script
5
star
11

vim-bundler

Bundler standalone Vim plugin taken from my contribution to the Rails Vim plugin
5
star
12

effpee

Learning material
Haskell
5
star
13

funalgebra

Slides and code examples from 'Functional Algebra By Example' talk at CodeMesh 2013
Scala
5
star
14

remarkable2-custom-templates

Custom templates and scripts for my reMarkable2 tablet
Shell
4
star
15

puppet-nix

Using Puppet now but would rather get to using Nix and NixOS? Then use this Puppet module to get Nix installed on all your infrastructure. Then who can argue? As forgiveness not permission. Subvert the system. And do it now.
4
star
16

deno-cli-fp-ts-sample

Example of a Deno command-line program skeleton using fp-ts library
TypeScript
3
star
17

rails-skeleton

Ruby
3
star
18

bash-http-server

For the lolz
Shell
3
star
19

amnesia

A fork of the amnesia project on sourceforge.net to be usable in rebar projects
Erlang
3
star
20

ruby-procinfo

A very simple Ruby/C extension to (at the moment) retrieve getrusage information about current process
Ruby
3
star
21

dsmigrator

Migration tool to define, manage, and run migrations against non-RDBMS datastores, search engines, message brokers, and similar pieces of infrastructure with basic schema and structure.
Scala
3
star
22

metafusion

Set of convenience libraries for use in various applications from cryptography to configuration
Ruby
3
star
23

amnesia_core

Amnesia core Erlang/OTP project for RDBMS access (needs database driver, e.g. amnesia_mysql)
Erlang
2
star
24

servant-intro

Servant introductory HTTP API and walk through
Haskell
2
star
25

amnesia_mysql

Amnesia MySQL driver Erlang/OTP project for RDBMS access (depends on amnesia_core)
Erlang
2
star
26

ammonia

Provides more project conventions for Nitrogen web applications in Erlang
2
star
27

fin_util

Utility and helper Erlang modules used in Finsignia projects. Anything from generating pseudo-random passphrases, generating code from templates, etc.
Erlang
2
star
28

seckey-workshop

Security (hardware) key workshop and play area
Nix
2
star
29

lerna-yarn-purescript

ARCHIVED. DO NOT USE.
PureScript
2
star
30

rebar

Mirror and fork of basho's rebar project, mirrored directly from the official Mercurial repository on bitbucket rather than from the unmerged GitHub basho/rebar repo.
Erlang
2
star
31

vim-rvm

RVM Vim plugin written in Vim Script
1
star
32

katas

Random material to show progression of abstraction for katas
1
star
33

susanpotter.net

Output of susanpotter.net site
HTML
1
star
34

hspark

Haskell implementation of the spark shell script by @holman
1
star
35

unfiltered-api.g8

Giter8 (g8) template repository for an Unfiltered (Scala) based HTTP API
1
star
36

chef-cookbooks

Chef Cookbooks for a variety of environments, servers and stacks
Ruby
1
star
37

adventures-in-purescript

Repository to go along with a series of PureScript talks
PureScript
1
star
38

notjusthelloworld.com

HTML
1
star
39

buildoku

An old idea from summer 2011 (before buildpacks) for building binaries on a "Heroku" VM and checking in the binaries to Git
Ruby
1
star
40

functionalprogramming.rocks

1
star
41

purescript-cards

Simple PureScript starter project with client and server (WIP); for educational purposes only
PureScript
1
star
42

scalaz-usages

Scalaz usage
1
star
43

rebar_subdirs_output

Rebar plugin/extension to print output with full paths for errors.
1
star
44

IoGit2

Io bindings for the libgit2 linkable library
1
star
45

basic-security-hygiene

A developer's guide to securing their OSX laptop
HTML
1
star
46

defresourceful

Clojure DSL for defining REST APIs to ultimately generate client libraries automatically like so: https://gist.github.com/1102201
1
star
47

heroku-buildpack-nanoc

A Heroku buildpack for static sites generated from Nanoc
1
star
48

rainbow_unicorns

Sample riak_core application
1
star
49

httpgener8

Generators for Scalacheck useful in the HTTP protocol domain
Scala
1
star
50

sslmon

Simple monitoring agent for SSL/TLS certificates
Haskell
1
star
51

euler

Project Euler solutions for Haskell, Erlang and Scala
Haskell
1
star
52

lucycross.com

Lucy Cross' basic portfolio site
HTML
1
star
53

scala-git

Git repository library in Scala - used as a learning tool for both understanding the Git repository formats and concepts and learning Scala standard libraries better
1
star
54

js-signer

A signing Javascript library. Could be used for authenticating application calls to the Flickr REST API or proprietary APIs that use a similar signing scheme.
JavaScript
1
star
55

goos

Repository to subvert Java examples in the GOOS book to Scala and aim to evolve them into more FP code and tests because growing an OO codebase should involve making it more functional :P
Scala
1
star