Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
configuration.nix file for NixOS on my macbook pro
{ config, pkgs, ... }:
let
hostname = "luz3";
in {
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
# I use VirtualBox to connect to Windows and Linux guests
<nixos/modules/programs/virtualbox.nix>
];
boot = {
cleanTmpDir = true;
loader = {
# I'm on an EFI-only system (mac book pro 9.2)
gummiboot.enable = true;
gummiboot.timeout = 4;
efi.canTouchEfiVariables = true;
grub.device = "/dev/sda";
};
};
fileSystems."/home" =
{ device = "/dev/disk/by-label/HOME";
fsType = "ext4";
};
fileSystems."/media/cassou/BACKUP" =
{ device = "/dev/disk/by-label/BACKUP";
fsType = "ext4";
};
fileSystems."/media/cassou/MACOS" =
{ device = "/dev/disk/by-label/MACOS";
fsType = "hfsplus";
options = "uid=1000";
};
networking.hostName = hostname;
# I use a desktop manager with NetworkManager
networking.networkmanager.enable = true;
i18n = {
consoleKeyMap = "us-acentos";
defaultLocale = "en_US.UTF-8";
};
environment.systemPackages = with pkgs; [
ack
ant
aspell
aspellDicts.fr
aspellDicts.en
backintime-common
backintime
bashCompletion
bindfs
boinc
chromium
coreutils
cryptsetup
gnome3.dconf
docker
dropbox
eclipses.eclipse_sdk_44
elfutils
emacs # see below for my own definition of Emacs
empathy
ffmpeg
file
filezilla
firefoxWrapper
ghostscript # to manipulate pdf files
gimp
gitAndTools.gitFull
glib # for gsettings
gmpc # MPD client
gnome3_12.pomodoro
gnumake
gnupg
gparted
haskellPackages.pandoc
haskellPackages.ShellCheck
htop
inetutils
inkscape
keymon
libreoffice
oraclejdk
oraclejdk7
maven
networkmanager_openvpn
offlineimap
openvpn
pdftk # to manipulate pdf files
(pidginWrapper.override { plugins = [ pidginotr ]; }) # pidgin + pidgin-otr
plantuml
pharo-launcher
pharo-vm
python # for Cask
pythonPackages.screenkey # to screencast my keys
pythonPackages.weboob
skype
telepathy_haze # jabber
texLiveFull
unetbootin
unison
unrar
utillinux # for dmesg, kill,...
vlc
subversion
wget
which
xlibs.xev
xorg.xkill
xvidcore
xpdf # for pdfinfo
yafc
zip
];
services = {
openssh.enable = true;
# Locate will update its database everyday at lunch time
locate.enable = true;
locate.period = "00 12 * * *";
# Music player daemon
mpd = {
enable = true;
musicDirectory = "/home/cassou/Musique/son/";
};
# Cups
printing = {
enable = true;
cupsdConf = ''
BrowsePoll cups.lille.inria.fr:631
BrowsePoll prserv.lifl.rf
'';
};
gnome3 = {
tracker.enable = false; # I don't use tracker
gnome-keyring.enable = true;
};
xserver = {
enable = true;
# Gnome 3 works better with GDM
displayManager.gdm.enable = true;
# https://github.com/NixOS/nixpkgs/issues/4416
displayManager.desktopManagerHandlesLidAndPower = false;
# I want Gnome 3
desktopManager.gnome3.enable = true;
# This is the way to activate some Gnome 3 modules
desktopManager.gnome3.sessionPath = with pkgs.gnome3_12; [ gpaste pomodoro ];
xkbOptions = "ctrl:nocaps"; # overriden by gnome (must be set using gnome tweak tool)
# Configure the macbook's touchpad
synaptics = {
enable = true;
# http://who-t.blogspot.fr/2010/11/how-to-ignore-configuration-errors.html
dev = "/dev/input/event*";
twoFingerScroll = true;
accelFactor = "0.001";
buttonsMap = [ 1 3 2 ];
};
config =
''
# Configure the Kensington trackball
# http://yjpark.blogspot.fr/2010/04/using-trackball-on-linux.html
Section "InputClass"
Identifier "Trackball Wheel Emulation"
MatchProduct "Kensington Kensington Slimblade Trackball"
MatchDevicePath "/dev/input/event*"
# Enable the mouse wheel emulation (similar to the navigation mode)
Option "EmulateWheel" "true"
# Upper-right button to trigger the navigation mode
Option "EmulateWheelButton" "8"
# Make it work for both vertical and horizontal scroll
Option "XAxisMapping" "6 7"
Option "YAxisMapping" "4 5"
# Remap the buttons a little bit, since firefox will use
# button 8 as back button and that's not what I want
Option "ButtonMapping" "1 8 3 4 5 6 7 10 9 2 11 12"
EndSection
'';
};
openvpn.enable = true;
# Launch backintime regularly
cron.systemCronJobs = [
"*/15 * * * * cassou ${pkgs.coreutils}/bin/nice -n 19 ${pkgs.utillinux}/bin/ionice -c2 -n7 ${pkgs.backintime-common}/bin/backintime --profile-id 2 --backup-job"
"0 * * * * cassou ${pkgs.coreutils}/bin/nice -n 19 ${pkgs.utillinux}/bin/ionice -c2 -n7 ${pkgs.backintime-common}/bin/backintime --backup-job"
];
};
# Use Gnome 3.12
environment.gnome3.packageSet = pkgs.gnome3_12;
nixpkgs.config = {
allowUnfree = true;
firefox = {
enableGoogleTalkPlugin = true;
enableAdobeFlash = true;
};
pidgin = {
openssl = true;
gnutls = true;
};
# Enable USB in guest OS
virtualbox.enableExtensionPack = true;
packageOverrides = pkgs: {
# Define my own Emacs
emacs = pkgs.lib.overrideDerivation (pkgs.emacs.override {
# Use gtk3 instead of the default gtk2
gtk = pkgs.gtk3;
# Make sure imagemgick is a dependency because I regularly
# look at pictures from Emasc
imagemagick = pkgs.imagemagickBig;
}) (attrs: {
# I don't want emacs.desktop file because I only use
# emacsclient.
postInstall = attrs.postInstall + ''
rm $out/share/applications/emacs.desktop
'';
});
};
};
# The wifi broadcom driver
networking.enableB43Firmware = true;
# Make sure the only way to add users/groups is to change this file
users.mutableUsers = false;
# Add myself as a super user
users.extraUsers.cassou = {
createHome = true;
home = "/home/cassou";
description = "Damien Cassou";
extraGroups = [ "wheel" "networkmanager" "vboxusers" "docker" ];
useDefaultShell = true;
uid = 1000;
hashedPassword = "<not shown in this gist>";
};
# Add fonts
fonts = {
enableFontDir = true;
enableGhostscriptFonts = true;
fonts = with pkgs; [
corefonts # Microsoft free fonts
inconsolata # monospaced
ubuntu_font_family
dejavu_fonts
];
};
# Fix problem with Emacs tramp (https://github.com/NixOS/nixpkgs/issues/3368)
programs.bash = {
promptInit = "PS1=\"# \"";
enableCompletion = true;
};
# Make sure I can use "openvpn" without entering my password
security.sudo.configFile =
''
cassou ${hostname} = (root) NOPASSWD: /run/current-system/sw/sbin/openvpn
'';
# Not sure what this is about anymore (nor if it's useful)
environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.gnome3.dconf}/lib/gio/modules" ];
# Create a systemd user service for emacs daemon. This is useful because
# systemd will take care of launching emacs in the background and I
# will just have to connect to it through emacs-client. This is a
# user service. This means I have to pass the "--user" option to
# systemd when I want to control the service.
systemd.user.services.emacs = {
description = "Emacs: the extensible, self-documenting text editor";
serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.emacs}/bin/emacs --daemon";
ExecStop = "${pkgs.emacs}/bin/emacsclient --eval (kill-emacs)";
Restart = "always";
};
# I want the emacs service to be started with the rest of the user services
wantedBy = [ "default.target" ];
# Annoyingly, systemd doesn't pass any environment variable to its
# services. Below, I set some variables that I missed.
environment = {
# Give Emacs a chance to use gnome keyring for the ssh-agent
SSH_AUTH_SOCK = "%t/keyring/ssh";
# Some variables for GTK applications I will launch from Emacs
# (typically evince and the gnome-terminal)
GTK_DATA_PREFIX = config.system.path;
GTK_PATH = "${config.system.path}/lib/gtk-3.0:${config.system.path}/lib/gtk-2.0";
# Make sure aspell will find its dictionaries
ASPELL_CONF = "dict-dir /run/current-system/sw/lib/aspell";
# Make sure locate will find its database
LOCATE_PATH = "/var/cache/locatedb";
};
};
}
@tjg1

This comment has been minimized.

Copy link

commented Apr 2, 2017

You'd most likely be better off using the libinput driver instead of synaptics with the Macbook's touchpad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.