-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
192 lines (180 loc) · 5.86 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
{ moduleNamespace, homeManager, inputs, ... }:
{ config, pkgs, lib, ... }: let
cfg = config.${moduleNamespace}.i3;
in {
_file = ./default.nix;
imports = [
];
options = {
${moduleNamespace}.i3 = with lib.types; {
enable = lib.mkEnableOption "birdee's i3 configuration";
dmenu = {
terminalStr = lib.mkOption {
default = ''alacritty'';
type = str;
};
};
terminalStr = lib.mkOption {
default = ''alacritty'';
type = str;
};
extraSessionCommands = lib.mkOption {
default = null;
type = nullOr str;
};
updateDbusEnvironment = lib.mkEnableOption "updating of dbus session environment";
tmuxDefault = lib.mkEnableOption "swap tmux default alacritty to mod+enter from mod+shift+enter";
defaultLockerEnabled = lib.mkOption {
default = true;
type = bool;
description = "default locker = i3lock + xss-lock";
};
prependedConfig = lib.mkOption {
default = '''';
type = str;
};
appendedConfig = lib.mkOption {
default = '''';
type = str;
};
background = lib.mkOption {
default = ./misc/rooftophang.png;
type = nullOr path;
};
lockerBackground = lib.mkOption {
default = ./misc/DogAteHomework.png;
type = nullOr path;
};
};
};
config = lib.mkIf cfg.enable (let
i3Config = (let
monMover = (pkgs.writeShellScript "monWkspcCycle.sh" ''
jq() {
${pkgs.jq}/bin/jq "$@"
}
xrandr() {
${pkgs.xorg.xrandr}/bin/xrandr "$@"
}
${builtins.readFile ./monWkspcCycle.sh}
'');
fehBG = (pkgs.writeShellScript "fehBG" (if cfg.background != null then ''
exec ${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${cfg.background} "$@"
'' else "exit 0"));
termCMD = if cfg.tmuxDefault then ''${cfg.terminalStr} -e tx'' else ''${cfg.terminalStr}'';
xtraTermCMD = if cfg.tmuxDefault then ''${cfg.terminalStr}'' else ''${cfg.terminalStr} -e tx'';
in ''
set $monMover ${monMover}
set $fehBG ${fehBG}
set $termCMD ${termCMD}
set $xtraTermCMD ${xtraTermCMD}
set $termSTR ${cfg.terminalStr}
${cfg.prependedConfig}
'' + builtins.readFile ./config + (if cfg.defaultLockerEnabled then ''
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
'' else "") + cfg.appendedConfig);
i3packagesList = (let
dmenu = pkgs.writeShellScriptBin "dmenu_run" (/* bash */''
dmenu() {
${pkgs.dmenu}/bin/dmenu "$@"
}
dmenu_path() {
${pkgs.dmenu}/bin/dmenu_path "$@"
}
TERMINAL=${cfg.dmenu.terminalStr}
'' + (builtins.readFile ./dmenu_recency.sh));
dmenuclr_recent = ''${pkgs.writeShellScriptBin "dmenuclr_recent" (/*bash*/''
cachedir=''${XDG_CACHE_HOME:-"$HOME/.cache"}
cache="$cachedir/dmenu_recent"
rm $cache
'')}'';
i3status = (pkgs.writeShellScriptBin "i3status" ''
exec ${pkgs.i3status}/bin/i3status --config ${pkgs.writeText "i3bar" (pkgs.callPackage ./i3bar.nix {})} "$@"
'');
i3lock = (pkgs.writeShellScriptBin "i3lock" ''
exec ${pkgs.i3lock}/bin/i3lock -t -i ${cfg.lockerBackground} "$@"
'');
in
with pkgs; with pkgs.xfce; (if cfg.defaultLockerEnabled then [
xss-lock
i3lock #default i3 screen locker
] else []) ++ [
i3status #default i3 status bar
libnotify
dmenu #application launcher most people use
dmenuclr_recent
pa_applet
pavucontrol
networkmanagerapplet
xfce4-volumed-pulse
lm_sensors
glib # for gsettings
gtk3.out # gtk-update-icon-cache
desktop-file-utils
shared-mime-info # for update-mime-database
polkit_gnome
xdg-utils
xdg-user-dirs
garcon
libxfce4ui
xfce4-power-manager
xfce4-notifyd
xfce4-screenshooter
xfce4-taskmanager
libsForQt5.qt5.qtquickcontrols2
libsForQt5.qt5.qtgraphicaleffects
# xorg.libXinerama
# dex
# hicolor-icon-theme
# tango-icon-theme
# xfce4-icon-theme
# gnome.gnome-themes-extra
# gnome.adwaita-icon-theme
]);
xresources = pkgs.writeText "Xresources" ''
XTerm*termName: xterm-256color
XTerm*faceName: FiraMono Nerd Font
XTerm*faceSize: 12
XTerm*background: black
XTerm*foreground: white
XTerm*title: XTerm
XTerm*loginShell: true
'';
xtraSesCMDs = ''
${pkgs.xorg.xrdb}/bin/xrdb -merge ${xresources}
${if cfg.extraSessionCommands == null then "" else cfg.extraSessionCommands}
'';
in (if homeManager then {
xsession.enable = true;
xsession.scriptPath = ".xsession";
xsession.initExtra = ''${lib.optionalString cfg.updateDbusEnvironment ''
${lib.getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all || true
''}
${xtraSesCMDs}
'';
xsession.windowManager.i3 = {
enable = true;
config = null;
extraConfig = i3Config;
};
# home.activation = {
# myActivationAction = lib.hm.dag.entryAfter ["writeBoundary"] ''
# run ln -s $VERBOSE_ARG \
# ${builtins.toPath ./link-me-directly} $HOME
# '';
# };
home.packages = i3packagesList;
} else {
# system.activationScripts.something.text = ''
# '';
services.displayManager.defaultSession = lib.mkOverride 1001 "none+i3";
services.xserver.windowManager.i3 = {
enable = true;
updateSessionEnvironment = cfg.updateDbusEnvironment;
configFile = "${ pkgs.writeText "config" i3Config }";
extraSessionCommands = xtraSesCMDs;
};
environment.systemPackages = i3packagesList;
# services.xserver.updateDbusEnvironment = cfg.updateDbusEnvironment;
}));
}