summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/commandline.nix108
-rw-r--r--common/commandline/dircolors.nix74
-rw-r--r--common/commandline/git.nix58
-rw-r--r--common/commandline/htop.nix44
-rw-r--r--common/commandline/tmux.nix79
-rw-r--r--common/commandline/zsh.nix59
-rw-r--r--common/default.nix11
-rw-r--r--common/theme.nix223
-rw-r--r--common/tinc.nix18
-rw-r--r--common/tinc/.keep0
-rw-r--r--common/vim.nix119
11 files changed, 793 insertions, 0 deletions
diff --git a/common/commandline.nix b/common/commandline.nix
new file mode 100644
index 0000000..36fae26
--- /dev/null
+++ b/common/commandline.nix
@@ -0,0 +1,108 @@
1{ config, pkgs, lib, ... }:
2
3with import ../lib/theme.nix { inherit lib; };
4let
5 dominantEscapeCode = fgEscapeCode config.theme.colors.dominant;
6 bgDominantEscapeCode = bgEscapeCode config.theme.colors.dominant;
7 backgroundEscapeCode = fgEscapeCode config.theme.colors.background;
8in
9{
10 imports = [
11 ./commandline/dircolors.nix
12 ./commandline/git.nix
13 ./commandline/htop.nix
14 ./commandline/tmux.nix
15 ./commandline/zsh.nix
16 ];
17
18 environment.shellAliases = {
19 ll = "ls -l";
20 e = "\${EDITOR}";
21 cpr = "${pkgs.rsync}/bin/rsync -ah --inplace --info=progress2";
22 };
23
24 programs.bash = {
25 enableCompletion = true;
26 interactiveShellInit = ''
27 eval "$(${pkgs.starship}/bin/starship init bash)"
28
29 PATH="${pkgs.pazi}/bin:$PATH"
30 eval "$(pazi init bash)"
31 '';
32 };
33
34 programs.less = {
35 envVariables = {
36 LESS = "-W -z-4 -R -J";
37 LESS_TERMCAP_mb = dominantEscapeCode;
38 LESS_TERMCAP_md = dominantEscapeCode;
39 LESS_TERMCAP_so =
40 bgDominantEscapeCode + backgroundEscapeCode + "$(tput bold)";
41 };
42 };
43
44 security.sudo.extraConfig =
45 let
46 lectureFile = builtins.toFile "sudoers.lecture" ''
47 
48 ${dominantEscapeCode}"Bee" careful __
49 ${dominantEscapeCode}with sudo! // \
50 \\_/ //
51 '''-.._.-'''-.._.. -(||)(')
52 ''''
53
54 '';
55 in
56 ''
57 Defaults lecture = always
58 Defaults lecture_file = "${lectureFile}"
59 '';
60
61 home-manager.users.minijackson = { ... }:
62 {
63 # TODO
64 xdg.configFile."starship.toml".text = ''
65 [directory]
66 fish_style_pwd_dir_length = 2
67 style = "bold blue"
68
69 [git_branch]
70 symbol = "branch "
71
72 [git_status]
73 ahead = "^"
74 behind = "v"
75 deleted = "x"
76
77 [jobs]
78 symbol = "+ "
79
80 [package]
81 symbol = "version "
82 style = "bold green"
83 disabled = true
84
85 [rust]
86 symbol = "rust "
87 style = "bold dimmed yellow"
88
89 [nix_shell]
90 style = "bold blue"
91
92 [character]
93 symbol = ">"
94 '';
95
96 programs.bat = {
97 enable = true;
98 config = {
99 theme = "TwoDark";
100 };
101 };
102 };
103
104 home-manager.users.root = { ... }:
105 {
106 programs.bat = config.home-manager.users.minijackson.programs.bat;
107 };
108}
diff --git a/common/commandline/dircolors.nix b/common/commandline/dircolors.nix
new file mode 100644
index 0000000..7ef3a4d
--- /dev/null
+++ b/common/commandline/dircolors.nix
@@ -0,0 +1,74 @@
1{ config, ... }:
2
3{
4 home-manager.users.minijackson = { ... }:
5 {
6 programs.dircolors = {
7 enable = true;
8 settings = {
9 # Enable on the alacritty terminal
10 TERM = "alacritty*";
11
12 DIR = "01;94";
13 EXEC = "01;92";
14
15 FIFO = "93"; # pipe"
16 BLK = "93;01"; # block device driver"
17 CHR = "93;01"; # character device driver"
18
19 # archives or compressed (yellow)
20 ".tar" = "01;33";
21 ".tgz" = "01;33";
22 ".arc" = "01;33";
23 ".arj" = "01;33";
24 ".taz" = "01;33";
25 ".lha" = "01;33";
26 ".lz4" = "01;33";
27 ".lzh" = "01;33";
28 ".lzma" = "01;33";
29 ".tlz" = "01;33";
30 ".txz" = "01;33";
31 ".tzo" = "01;33";
32 ".t7z" = "01;33";
33 ".zip" = "01;33";
34 ".z" = "01;33";
35 ".dz" = "01;33";
36 ".gz" = "01;33";
37 ".lrz" = "01;33";
38 ".lz" = "01;33";
39 ".lzo" = "01;33";
40 ".xz" = "01;33";
41 ".zst" = "01;33";
42 ".tzst" = "01;33";
43 ".bz2" = "01;33";
44 ".bz" = "01;33";
45 ".tbz" = "01;33";
46 ".tbz2" = "01;33";
47 ".tz" = "01;33";
48 ".deb" = "01;33";
49 ".rpm" = "01;33";
50 ".jar" = "01;33";
51 ".war" = "01;33";
52 ".ear" = "01;33";
53 ".sar" = "01;33";
54 ".rar" = "01;33";
55 ".alz" = "01;33";
56 ".ace" = "01;33";
57 ".zoo" = "01;33";
58 ".cpio" = "01;33";
59 ".7z" = "01;33";
60 ".rz" = "01;33";
61 ".cab" = "01;33";
62 ".wim" = "01;33";
63 ".swm" = "01;33";
64 ".dwm" = "01;33";
65 ".esd" = "01;33";
66 };
67 };
68 };
69
70 home-manager.users.root = { ... }:
71 {
72 programs.dircolors = config.home-manager.users.minijackson.programs.dircolors;
73 };
74}
diff --git a/common/commandline/git.nix b/common/commandline/git.nix
new file mode 100644
index 0000000..597ef64
--- /dev/null
+++ b/common/commandline/git.nix
@@ -0,0 +1,58 @@
1{ config, pkgs, ... }:
2
3{
4 # TODO: add signing
5 home-manager.users.minijackson = { ... }:
6 {
7 programs.git = {
8 enable = true;
9 package = pkgs.gitAndTools.gitFull;
10 userEmail = "minijackson@riseup.net";
11 userName = "Minijackson";
12
13 extraConfig = let
14 deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta";
15 in {
16 core = {
17 whitespace = "trailing-space,space-before-tab";
18 pager = deltaCommand;
19 interactive.diffFilter = "${deltaCommand} --color-only";
20 };
21 merge = { tool = "nvimdiff"; };
22 "mergetool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; };
23
24 delta = with config.theme.colors; {
25 features = "line-numbers decorations";
26 whitespace-error-style = "22 reverse";
27 decorations = {
28 minus-style = "normal red";
29 minus-non-emph-style = "normal red";
30 minus-emph-style = "normal brightred";
31 minus-empty-line-marker-style = "normal red";
32
33 plus-style = "reverse green";
34 plus-non-emph-style = "reverse green";
35 plus-emph-style = "reverse brightgreen";
36 plus-empty-line-marker-style = "reverse green";
37
38 whitespace-error-style = "reverse green";
39
40 line-numbers-minus-style = "brightred";
41 line-numbers-zero-style = "brightblack";
42 line-numbers-plus-style = "brightgreen";
43
44 file-style = "bright${dominantName}";
45 line-numbers-left-style = dominantName;
46 line-numbers-right-style = dominantName;
47 };
48 };
49
50 };
51 };
52 };
53
54 home-manager.users.root = { ... }:
55 {
56 programs.git = config.home-manager.users.minijackson.programs.git;
57 };
58}
diff --git a/common/commandline/htop.nix b/common/commandline/htop.nix
new file mode 100644
index 0000000..f9732a6
--- /dev/null
+++ b/common/commandline/htop.nix
@@ -0,0 +1,44 @@
1{ config, ... }:
2
3{
4 home-manager.users.minijackson = { ... }:
5 {
6 programs.htop = {
7 enable = true;
8
9 fields = [
10 "PID" "USER"
11 "PRIORITY" "NICE"
12 "STATE"
13 "IO_PRIORITY" "IO_READ_RATE" "IO_WRITE_RATE"
14 "PERCENT_CPU" "PERCENT_MEM"
15 "TIME"
16 "COMM"
17 ];
18
19 hideThreads = true;
20 hideUserlandThreads = true;
21 showThreadNames = true;
22 shadowOtherUsers = true;
23
24 highlightBaseName = true;
25
26 # On NixOS? NO.
27 showProgramPath = false;
28
29 treeView = true;
30
31 meters = {
32 left = [ "LeftCPUs2" "Memory" "Swap" "Blank" { kind = "Battery"; mode = 1; } ];
33 right = [ "RightCPUs2" "Blank" "Tasks" "LoadAverage" "Uptime" ];
34 };
35 };
36 };
37
38 home-manager.users.root = { ... }:
39 {
40 programs.htop = config.home-manager.users.minijackson.programs.htop // {
41 shadowOtherUsers = false;
42 };
43 };
44}
diff --git a/common/commandline/tmux.nix b/common/commandline/tmux.nix
new file mode 100644
index 0000000..aa4de9c
--- /dev/null
+++ b/common/commandline/tmux.nix
@@ -0,0 +1,79 @@
1{ config, pkgs, ... } :
2
3let
4 # Thanks: https://github.com/DanielFGray/dotfiles/blob/master/tmux.remote.conf
5 remoteConf = builtins.toFile "tmux.remote.conf" ''
6 unbind C-q
7 unbind q
8 set-option -g prefix C-s
9 bind s send-prefix
10 bind C-s last-window
11 set-option -g status-position top
12 '';
13in {
14 programs.tmux = {
15 enable = true;
16 shortcut = "q";
17 escapeTime = 10;
18 keyMode = "vi";
19 terminal = "tmux-256color";
20 historyLimit = 50000;
21
22 extraConfig = with config.theme; with pkgs.tmuxPlugins;
23 ''
24 # Plugins
25 run-shell '${copycat}/share/tmux-plugins/copycat/copycat.tmux'
26 run-shell '${sensible}/share/tmux-plugins/sensible/sensible.tmux'
27 run-shell '${urlview}/share/tmux-plugins/urlview/urlview.tmux'
28
29 bind-key R run-shell ' \
30 tmux source-file /etc/tmux.conf > /dev/null; \
31 tmux display-message "sourced /etc/tmux.conf"'
32
33 if -F "$SSH_CONNECTION" "source-file '${remoteConf}'"
34
35 set-option -g status-right ' #{prefix_highlight} "#{=21:pane_title}" %H:%M %d-%b-%y'
36 set-option -g status-left-length 20
37 set-option -g @prefix_highlight_fg '${colors.background}'
38 set-option -g @prefix_highlight_bg '${colors.dominant}'
39 run-shell '${prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux'
40
41 # Be faster switching windows
42 bind C-n next-window
43 bind C-p previous-window
44
45 set-option -g set-titles on
46
47 bind C-y run-shell ' \
48 ${pkgs.tmux}/bin/tmux show-buffer > /dev/null 2>&1 \
49 && ${pkgs.tmux}/bin/tmux show-buffer | ${pkgs.xsel}/bin/xsel -ib'
50
51 # Force true colors
52 set-option -ga terminal-overrides ",*:Tc"
53
54 set-option -g mouse on
55 set-option -g focus-events on
56
57 # Stay in same directory when split
58 bind % split-window -h -c "#{pane_current_path}"
59 bind '"' split-window -v -c "#{pane_current_path}"
60
61 # Colorscheme
62 set-option -g status-style 'fg=${colors.dimForeground}, bg=${colors.background}'
63
64 set-option -g window-status-current-style 'fg=${colors.dominant}'
65
66 set-option -g pane-border-style 'fg=${colors.background}'
67 set-option -g pane-active-border-style 'fg=${colors.dominant}'
68
69 set-option -g message-style 'fg=${colors.background}, bg=${colors.dimForeground}'
70
71 set-option -g mode-style 'fg=${colors.background}, bg=${colors.dominant}'
72
73 set-option -g display-panes-active-colour '${colors.dominant}'
74 set-option -g display-panes-colour '${colors.dimForeground}'
75
76 set-option -g clock-mode-colour '${colors.dominant}'
77 '';
78 };
79}
diff --git a/common/commandline/zsh.nix b/common/commandline/zsh.nix
new file mode 100644
index 0000000..3376321
--- /dev/null
+++ b/common/commandline/zsh.nix
@@ -0,0 +1,59 @@
1{ config, lib, pkgs, ... }:
2
3with import ../../lib/theme.nix { inherit lib; };
4let
5 dominantEscapeCode = fgEscapeCode config.theme.colors.dominant;
6in
7{
8 programs.zsh = {
9 enable = true;
10
11 interactiveShellInit = with lib;
12 ''
13 source "${pkgs.grml-zsh-config}/etc/zsh/zshrc"
14 is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack"
15
16 PATH="${pkgs.pazi}/bin:$PATH"
17 eval "$(pazi init zsh)"
18
19 source "${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh"
20
21 function () {
22 local dominant_escape_code="${dominantEscapeCode}"
23 local dim_fg_escape_code="${fgEscapeCode config.theme.colors.dimForeground}"
24
25 ${builtins.readFile ../../dotfiles/zshrc}
26 }
27
28 # Grml's ZSH config overrides less variables
29 export ${concatStringsSep " "
30 (mapAttrsToList
31 (variable: value: "${variable}=\"${value}\"")
32 config.programs.less.envVariables)}
33
34 #eval "$(${pkgs.starship}/bin/starship init zsh)"
35 '';
36
37 # otherwise it'll override the grml prompt
38 promptInit = "";
39 # Grml handles that, and supports cache (faster!!!)
40 enableGlobalCompInit = false;
41
42 syntaxHighlighting = {
43 enable = true;
44 highlighters = [ "main" "brackets" "line" ];
45 };
46
47 shellAliases = {
48 e = "\${(z)EDITOR}";
49 };
50
51 setOptions = [
52 "HIST_IGNORE_DUPS" "SHARE_HISTORY" "HIST_FCNTL_LOCK"
53 "NO_CLOBBER"
54 "NO_CASE_GLOB"
55 ];
56 };
57
58 users.defaultUserShell = pkgs.zsh;
59}
diff --git a/common/default.nix b/common/default.nix
new file mode 100644
index 0000000..fc9086b
--- /dev/null
+++ b/common/default.nix
@@ -0,0 +1,11 @@
1{ ... }:
2
3{
4 imports = [
5 <home-manager/nixos>
6 ./commandline.nix
7 ./theme.nix
8 ./tinc.nix
9 ./vim.nix
10 ];
11}
diff --git a/common/theme.nix b/common/theme.nix
new file mode 100644
index 0000000..675bc33
--- /dev/null
+++ b/common/theme.nix
@@ -0,0 +1,223 @@
1# A facility centralizing theme / colorscheme
2
3# The default colors are based on the Gruvbox theme:
4#
5# - https://github.com/morhetz/gruvbox
6# - https://github.com/morhetz/gruvbox-contrib
7
8{ config, lib, ... }:
9
10with lib;
11
12{
13 options.theme.colors = {
14
15 dominantName = mkOption {
16 type = types.str;
17 default = "green";
18 description = ''
19 The dominant color name of the theme.
20
21 This color should be different on different hosts.
22 '';
23 };
24
25 dominant = mkOption {
26 type = types.str;
27 default = "#b8bb26";
28 description = ''
29 The dominant color of the theme.
30
31 This color should be different on different hosts.
32 '';
33 };
34
35 dimDominant = mkOption {
36 type = types.str;
37 default = "#79740e";
38 description = ''
39 The dominant color of the theme, but dimmed.
40 '';
41 };
42
43 foreground = mkOption {
44 type = types.str;
45 default = "#ebdbb1";
46 description = "The foreground (text) color";
47 };
48
49 dimForeground = mkOption {
50 type = types.str;
51 default = "#928374";
52 description = "Like the foreground color, but one which does not burn the eyes.";
53 };
54
55 background = mkOption {
56 type = types.str;
57 default = "#282828";
58 description = "The background color";
59 };
60
61 softBackground = mkOption {
62 type = types.str;
63 default = "#32302f";
64 description = "Like the background color, but a little bit softer.";
65 };
66
67 lightBackground = mkOption {
68 type = types.str;
69 default = "#504945";
70 description = "Like the background color, but one which burns the eyes a little bit more.";
71 };
72
73 background0 = mkOption {
74 type = types.str;
75 default = "#1d2021";
76 description = "Background level 0";
77 };
78
79 background1 = mkOption {
80 type = types.str;
81 default = "#282828";
82 description = "Background level 1";
83 };
84
85 background2 = mkOption {
86 type = types.str;
87 default = "#3c3836";
88 description = "Background level 2";
89 };
90
91 background3 = mkOption {
92 type = types.str;
93 default = "#504945";
94 description = "Background level 3";
95 };
96
97 background4 = mkOption {
98 type = types.str;
99 default = "#665c54";
100 description = "Background level 4";
101 };
102
103 background5 = mkOption {
104 type = types.str;
105 default = "#7c6f64";
106 description = "Background level 5";
107 };
108
109 background6 = mkOption {
110 type = types.str;
111 default = "#928374";
112 description = "Background level 6";
113 };
114
115 brightRed = mkOption {
116 type = types.str;
117 default = "#fb4934";
118 };
119
120 brightGreen = mkOption {
121 type = types.str;
122 default = "#b8bb26";
123 };
124
125 brightYellow = mkOption {
126 type = types.str;
127 default = "#fabd2f";
128 };
129
130 brightBlue = mkOption {
131 type = types.str;
132 default = "#83a598";
133 };
134
135 brightMagenta = mkOption {
136 type = types.str;
137 default = "#d3869b";
138 };
139
140 brightCyan = mkOption {
141 type = types.str;
142 default = "#8ec07c";
143 };
144
145 brightOrange = mkOption {
146 type = types.str;
147 default = "#fe8019";
148 };
149
150
151 neutralRed = mkOption {
152 type = types.str;
153 default = "#cc241d";
154 };
155
156 neutralGreen = mkOption {
157 type = types.str;
158 default = "#98971a";
159 };
160
161 neutralYellow = mkOption {
162 type = types.str;
163 default = "#d79921";
164 };
165
166 neutralBlue = mkOption {
167 type = types.str;
168 default = "#458588";
169 };
170
171 neutralMagenta = mkOption {
172 type = types.str;
173 default = "#b16286";
174 };
175
176 neutralCyan = mkOption {
177 type = types.str;
178 default = "#689d6a";
179 };
180
181 neutralOrange = mkOption {
182 type = types.str;
183 default = "#d65d0e";
184 };
185
186
187 fadedRed = mkOption {
188 type = types.str;
189 default = "#9d0006";
190 };
191
192 fadedGreen = mkOption {
193 type = types.str;
194 default = "#79740e";
195 };
196
197 fadedYellow = mkOption {
198 type = types.str;
199 default = "#b57614";
200 };
201
202 fadedBlue = mkOption {
203 type = types.str;
204 default = "#076678";
205 };
206
207 fadedMagenta = mkOption {
208 type = types.str;
209 default = "#8f3f71";
210 };
211
212 fadedCyan = mkOption {
213 type = types.str;
214 default = "#427b58";
215 };
216
217 fadedOrange = mkOption {
218 type = types.str;
219 default = "#af3a03";
220 };
221
222 };
223}
diff --git a/common/tinc.nix b/common/tinc.nix
new file mode 100644
index 0000000..1016f42
--- /dev/null
+++ b/common/tinc.nix
@@ -0,0 +1,18 @@
1{ config, lib, ... }:
2
3with lib;
4with builtins;
5let
6 networks = attrNames (readDir ./tinc/private);
7in {
8 imports = map (network: (./tinc/private + "/${network}")) networks;
9
10 services.tinc.networks = genAttrs networks (network: {
11 name = config.networking.hostName;
12
13 hosts = let
14 hosts = attrNames (readDir (./tinc/private + "/${network}/hosts"));
15 config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}");
16 in genAttrs hosts config;
17 });
18}
diff --git a/common/tinc/.keep b/common/tinc/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/tinc/.keep
diff --git a/common/vim.nix b/common/vim.nix
new file mode 100644
index 0000000..ddb901a
--- /dev/null
+++ b/common/vim.nix
@@ -0,0 +1,119 @@
1{ config, pkgs, lib, ... }:
2
3let myNeovim = (pkgs.neovim.override {
4 configure = {
5
6 inherit (config.vim) beforePlugins;
7
8 customRC = with lib;
9 (concatStringsSep
10 "\n"
11 (mapAttrsToList
12 (variable: value: "let g:${variable} = ${value}")
13 config.vim.variables))
14 + "\n"
15 + builtins.readFile ../dotfiles/vimrc.vim + config.vim.extraConfig;
16
17 vam = with pkgs; {
18 pluginDictionaries = [
19 # UI
20 { name = "undotree"; }
21 { name = "gruvbox-community"; }
22 { name = "gitgutter"; }
23 { name = "lightline-vim"; }
24 { name = "vim-dirvish"; }
25
26 # Motions
27 { name = "camelcasemotion"; }
28 { name = "surround"; }
29 { name = "targets-vim"; }
30
31 # Frameworks
32 { name = "deoplete-nvim"; }
33 { name = "neosnippet"; }
34 { name = "neosnippet-snippets"; }
35 { name = "neoformat"; }
36 { name = "ctrlp"; }
37 # Syntax generic completion for deoplete
38 { name = "neco-syntax"; }
39
40 # Languages
41 { name = "vim-polyglot"; }
42 { name = "editorconfig-vim"; }
43 # Vim completion for deoplete
44 { name = "neco-vim"; }
45 { name = "deoplete-zsh"; }
46 { name = "vim-pandoc"; }
47 { name = "vim-pandoc-syntax"; }
48
49 # Languages (but not programming languages)
50 { name = "vim-grammarous"; }
51
52 # Other
53 { name = "tmux-complete-vim"; }
54 { name = "fugitive"; }
55 { name = "rhubarb"; }
56 { name = "repeat"; }
57 { name = "vim-unimpaired"; }
58 { name = "tabular"; }
59 { name = "vimwiki"; }
60 { name = "vim-abolish"; }
61
62 ] ++ config.vim.extraPlugins;
63
64 };
65
66 };
67});
68in {
69 options.vim = with lib; {
70
71 variables = mkOption {
72 type = types.attrsOf types.str;
73 default = {
74 dominant_color = "'${config.theme.colors.dominant}'";
75 ripgrep_path = "'${pkgs.ripgrep}/bin/rg'";
76 fd_path = "'${pkgs.fd}/bin/fd'";
77 };
78 description = ''
79 Extra global variables to add at the beginning of the vim configuration.
80
81 Remember to escape strings with single-quotes.
82 '';
83 };
84
85 extraPlugins = mkOption {
86 type = types.listOf (types.attrsOf types.str);
87 default = [];
88 description = "Names of extra plugins to add";
89 };
90
91 extraRepoPlugins = mkOption {
92 type = types.listOf (types.attrsOf types.str);
93 default = [];
94 description = "Names of extra plugins to add that are present in the local repository";
95 };
96
97 beforePlugins = mkOption {
98 type = types.lines;
99 default = "";
100 description = "Extra lines to add in the vim configuration before loading plugins";
101 };
102
103 extraConfig = mkOption {
104 type = types.lines;
105 default = "";
106 description = "Extra lines to add at the end of the vim configuration";
107 };
108 };
109
110 config = {
111 environment.systemPackages = with pkgs; [
112 myNeovim
113 ];
114
115 environment.sessionVariables = {
116 EDITOR = "nvim";
117 };
118 };
119}