/
default.nix
219 lines (182 loc) · 5.84 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{ config, pkgs, expr, ... }:
with builtins; with pkgs.lib; {
imports = [
./desktop.nix
./services.nix
./accounts.nix
];
# Available packages
environment.systemPackages = with pkgs;
[ # Version control / archiving
git gitAndTools.hub mercurial bazaar subversion
unzip zip unrar p7zip dtrx
# Debugging / monitoring / analyzing
htop iotop powertop
ltrace strace linuxPackages.perf
pciutils lshw smartmontools usbutils
# Networking
inetutils wireshark wget nix-prefetch-scripts
# Linux shell utils
pmutils psmisc which file binutils bc utillinuxCurses exfat dosfstools
patchutils moreutils
# Desktop utils
scrot xsel xlibs.xbacklight arandr wpa_supplicant_gui expr.lock pavucontrol paprefs
# Command line programs
k2pdfopt ncmpcpp mpc_cli beets wpa_supplicant mp3gain mpv
fish haskellPackages.themplate abcde vorbisgain dfc ripgrep
aspell weechat
# Man pages
man man-pages posix_man_pages stdman
# Development tools
nix-repl llvm haskellPackages.ghc
# Desktop applications
xfce.thunar gimp skype libreoffice calibre emacs
keepassx2 zathura rxvt_unicode chromium steam vlc
# Games
expr.armagetronad steam
];
boot.cleanTmpDir = true;
boot.kernel.sysctl = {
"kernel.dmesg_restrict" = true;
"kernel.yama.ptrace_scope" = 1;
};
hardware.pulseaudio.enable = true;
hardware.pulseaudio.support32Bit = true;
hardware.pulseaudio.package = pkgs.pulseaudioFull;
hardware.bluetooth.enable = true;
hardware.opengl.driSupport32Bit = true;
services.udev.packages = with pkgs; [
# Enable Android udev rules
# This is needed so that the android device nodes in /dev have
# the correct access levels (they will be managed by systemd-logind/udevd)
android-udev-rules
];
services.udev.extraRules = ''
# AREXX USB-IR-Transceiver. For flashing ASURO robot
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ENV{ID_REMOTE_CONTROL}="1"
# Wiko android devices
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# set deadline scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
'';
# Environment variables
environment.variables = {
BROWSER ="${pkgs.chromium}/bin/chromium";
EDITOR="${pkgs.emacs}/bin/emacsclient -c";
SHELL = "${pkgs.fish}/bin/fish";
};
# Ugh, the default 'extraInit' has code to override ASPELL_DICTS, so we need
# to set our ASPELL_DICT environment variable after that code has executed.
# shellInit is executed after extraInit.
environment.shellInit =
let
allDicts = pkgs.buildEnv {
name = "all-dictionaries";
paths = builtins.attrValues pkgs.aspellDicts;
pathsToLink = ["/lib"];
};
in ''export ASPELL_CONF="dict-dir ${allDicts}/lib/aspell"'';
# Make SSL root certificates used by Mozilla Firefox available
environment.etc."ssl/certs/mozilla.crt" = {
source = pkgs.fetchurl {
url = "http://curl.haxx.se/ca/cacert.pem";
sha256 = "1l4xzr16vjdxcpj1fl3qrn8srh7ni3cl5fabwrkd8as3njvqm377";
};
mode = "444";
};
environment.etc."sync" = {
source = expr.nixos-sync (config.system.build.nixos-rebuild);
mode = "500";
};
environment.etc."wpa_supplicant.conf" = {
mode = "symlink";
source = "/etc/local/wpa_supplicant.conf";
};
# Setup /home
system.activationScripts.homeUser = stringAfter [ "users" ] ''
chown bennofs:users /home
'';
# Make sure /run/media/bennofs exists
system.activationScripts.mediaMountPoint = ''
mkdir -p /run/media/bennofs
chown bennofs:users /run/media/bennofs
'';
# Extra environment variables
environment.extraInit = ''
export PATH="$HOME/.local/bin:$PATH"
'';
environment.loginShellInit = ''
if [ ! -d /home/.git ]; then
(
cd /home
git=${pkgs.git}/bin/git
$git init &> /tmp/git-init
$git remote add origin https://github.com/bennofs/dotfiles &> /tmp/git-remote
$git fetch &> /tmp/git-fetch
$git checkout -t origin/master &> /tmp/git-checkout
) || rm /home/.git -rf
# Setup nix-env
rm /home/.nix-defexpr/*
ln -s /run/current-system/nixpkgs /home/.nix-defexpr
fi
'';
# Add nixpkgs link to system
system.copySystemNixpkgs = true;
# Select internationalisation properties.
i18n = {
consoleKeyMap = "de-latin1";
defaultLocale = "en_US.UTF-8";
};
time.timeZone = "Europe/Berlin";
# All the fonts!
fonts.fonts = with pkgs; [
source-code-pro dejavu_fonts liberation_ttf vistafonts corefonts
cantarell_fonts fira fira-mono fira-code hasklig
];
networking = {
wireless.enable = true;
wireless.userControlled.enable = true;
};
# Tell systemd that we want to suspend even if an additional
# monitor is connected.
services.logind.extraConfig = ''
HandleLidSwitchDocked=suspend
'';
# Allow normal users to mount devices
security.polkit.enable = true;
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
var YES = polkit.Result.YES;
var permission = {
"org.freedesktop.udisks2.filesystem-mount": YES,
"org.freedesktop.udisks2.filesystem-mount-system": YES,
"org.freedesktop.udisks2.eject-media": YES
};
return permission[action.id];
});
'';
nix = {
useSandbox = "relaxed";
extraOptions = ''
auto-optimise-store = true
'';
binaryCaches = [ https://cache.nixos.org ];
binaryCachePublicKeys = [ "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" ];
trustedBinaryCaches = [
http://cache.nixos.org
http://hydra.nixos.org
http://hydra.cryp.to
https://ryantrinkle.com:5443
];
daemonNiceLevel = 1;
daemonIONiceLevel = 1;
nixPath = [
"nixpkgs=/run/current-system/nixpkgs"
"/run/current-system/nixpkgs"
"nixos-config=/etc/nixos/configuration.nix"
];
buildMachines = [
{ hostName = "localhost"; system = builtins.currentSystem; inherit (config.nix) maxJobs; }
];
};
}