NixOS Notes: November 3, 2012

Michael Stone, November 3, 2012, , (src), (all posts)

For the last few months, I’ve been using what one might call an “impressively functional” Linux distro named NixOS.

Today, I finally learned how to install tweaked package expressions:

git clone git://github.com/NixOS/nixpkgs.git
cd ~/nixpkgs
# tweak pkgs/development/interpreters/r-lang/default.nix
nix-env --dry-run -f ./default.nix -iA rLang

To give you an idea of what I like about NixOS, here’s the (lightly customized) config-file that I used to install my laptop:

{config, pkgs, ...}:

{
  require = [
    # Include the configuration for part of your system which have been
    # detected automatically.
    ./hardware-configuration.nix
  ];

  hardware.enableAllFirmware = true;

  boot.initrd.kernelModules = [
    # Specify all kernel modules that are necessary for mounting the root
    # file system.
    #
    # "ext4" "ata_piix"
    "dm_crypt" "sha256_generic" "sha1_generic" "cbc" "aes_x86_64" "aes_generic" "xts" "aesni_intel" "cryptd" "gf128mul"
  ];

  boot.initrd.luks.enable = true;
  boot.initrd.luks.devices = [ { name = "luksroot"; device = "/dev/sda2"; } ];

  boot.loader.grub = {
    # Use grub 2 as boot loader.
    enable = true;
    version = 2;

    # Define on which hard drive you want to install Grub.
    device = "/dev/sda";
  };

  boot.blacklistedKernelModules = [ "pcspkr" ];

  environment.systemPackages = [
    pkgs.firefox
    pkgs.gnupg
    pkgs.xlockmore
    pkgs.acpi
    pkgs.psmisc
    pkgs.vim
    pkgs.xpdf
    pkgs.haskellPackages_ghc741.pandoc
    pkgs.pythonFull
    pkgs.unzip
  ];

  networking = {
    hostName = "iron"; # Define your hostname.
    wireless.enable = true;  # Enables Wireless.
    firewall.enable = true;
    enableIPv6 = false;
  };

  # Add file system entries for each partition that you want to see mounted
  # at boot time.  You can add filesystems which are not mounted at boot by
  # adding the noauto option.
  fileSystems = [
    # Mount the root file system
    #
    # { mountPoint = "/";
    #   device = "/dev/sda2";
    # }

    { mountPoint = "/";
      device = "/dev/mapper/vg0-lv0";
    } {
      mountPoint = "/boot";
      device = "/dev/sda1";
    }

    # Copy & Paste & Uncomment & Modify to add any other file system.
    #
    # { mountPoint = "/data"; # where you want to mount the device
    #   device = "/dev/sdb"; # the device or the label of the device
    #   # label = "data";
    #   fsType = "ext3";      # the type of the partition.
    #   options = "data=journal";
    # }
  ];

  swapDevices = [
    # List swap partitions that are mounted at boot time.
    #
    # { device = "/dev/sda1"; }
  ];

  # Select internationalisation properties.
  # i18n = {
  #   consoleFont = "lat9w-16";
  #   consoleKeyMap = "us";
  #   defaultLocale = "en_US.UTF-8";
  # };

  # List services that you want to enable:

  # Add an OpenSSH daemon.
  # services.openssh.enable = true;

  # Add CUPS to print documents.
  # services.printing.enable = true;

  # Add XServer (default if you have used a graphical iso)
  services.xserver = {
    enable = true;
    layout = "us";
    xkbOptions = "grp:caps_toggle, terminate:ctrl_alt_bksp";
    windowManager.xmonad.enable = true;
    windowManager.default = "xmonad";
  };

  # Add the NixOS Manual on virtual console 8
  services.nixosManual.showManual = true;

  time = {
    timeZone = "US/Eastern";
  };

  nixpkgs.config.firefox = {
    enableAdobeFlash = false;
    enableGnash = false;
    jre = false;
  };
}