diff options
author | Minijackson <minijackson@riseup.net> | 2020-12-03 16:45:06 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-12-03 16:45:06 +0100 |
commit | 3f0e83cb4816e637d8c916fb77217e1c5824dbe5 (patch) | |
tree | 65b48ffe6e82459cde97b8ee61a597402ba2617b | |
download | nixos-config-reborn-3f0e83cb4816e637d8c916fb77217e1c5824dbe5.tar.gz nixos-config-reborn-3f0e83cb4816e637d8c916fb77217e1c5824dbe5.zip |
initial commit: most of previous configuration reworked
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | common/commandline.nix | 108 | ||||
-rw-r--r-- | common/commandline/dircolors.nix | 74 | ||||
-rw-r--r-- | common/commandline/git.nix | 58 | ||||
-rw-r--r-- | common/commandline/htop.nix | 44 | ||||
-rw-r--r-- | common/commandline/tmux.nix | 79 | ||||
-rw-r--r-- | common/commandline/zsh.nix | 59 | ||||
-rw-r--r-- | common/default.nix | 11 | ||||
-rw-r--r-- | common/theme.nix | 223 | ||||
-rw-r--r-- | common/tinc.nix | 18 | ||||
-rw-r--r-- | common/tinc/.keep | 0 | ||||
-rw-r--r-- | common/vim.nix | 119 | ||||
-rw-r--r-- | configuration.nix | 72 | ||||
-rw-r--r-- | dotfiles/vimrc.vim | 139 | ||||
-rw-r--r-- | dotfiles/zshrc | 242 | ||||
-rw-r--r-- | lib/theme.nix | 35 | ||||
-rw-r--r-- | profiles/server.nix | 9 |
17 files changed, 1294 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f47876 --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | result | ||
2 | *secret.nix | ||
3 | private | ||
4 | /hardware-configuration.nix | ||
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 | |||
3 | with import ../lib/theme.nix { inherit lib; }; | ||
4 | let | ||
5 | dominantEscapeCode = fgEscapeCode config.theme.colors.dominant; | ||
6 | bgDominantEscapeCode = bgEscapeCode config.theme.colors.dominant; | ||
7 | backgroundEscapeCode = fgEscapeCode config.theme.colors.background; | ||
8 | in | ||
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 | [1m | ||
48 | ${dominantEscapeCode}"Bee" careful [34m__ | ||
49 | ${dominantEscapeCode}with sudo! [34m// \ | ||
50 | \\_/ [33m// | ||
51 | [35m'''-.._.-'''-.._.. [33m-(||)(') | ||
52 | ''''[0m | ||
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 | |||
3 | let | ||
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 | ''; | ||
13 | in { | ||
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 | |||
3 | with import ../../lib/theme.nix { inherit lib; }; | ||
4 | let | ||
5 | dominantEscapeCode = fgEscapeCode config.theme.colors.dominant; | ||
6 | in | ||
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 | |||
10 | with 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 | |||
3 | with lib; | ||
4 | with builtins; | ||
5 | let | ||
6 | networks = attrNames (readDir ./tinc/private); | ||
7 | in { | ||
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 | |||
3 | let 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 | }); | ||
68 | in { | ||
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 | } | ||
diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..1a5530f --- /dev/null +++ b/configuration.nix | |||
@@ -0,0 +1,72 @@ | |||
1 | # Edit this configuration file to define what should be installed on | ||
2 | # your system. Help is available in the configuration.nix(5) man page | ||
3 | # and in the NixOS manual (accessible by running ‘nixos-help’). | ||
4 | |||
5 | { config, pkgs, modulesPath, ... }: | ||
6 | |||
7 | { | ||
8 | imports = [ | ||
9 | ./hardware-configuration.nix | ||
10 | ./host-secret.nix | ||
11 | ./common/default.nix | ||
12 | ]; | ||
13 | |||
14 | # Set your time zone. | ||
15 | time.timeZone = "Europe/Paris"; | ||
16 | |||
17 | # Select internationalisation properties. | ||
18 | i18n.defaultLocale = "en_US.UTF-8"; | ||
19 | # console = { | ||
20 | # font = "Lat2-Terminus16"; | ||
21 | # keyMap = "us"; | ||
22 | # }; | ||
23 | |||
24 | # List packages installed in system profile. To search, run: | ||
25 | # $ nix search wget | ||
26 | environment.systemPackages = with pkgs; [ | ||
27 | wget | ||
28 | vim tmux | ||
29 | ripgrep file progress psmisc lsof nethogs | ||
30 | fd tree ncdu | ||
31 | lm_sensors hddtemp smartmontools | ||
32 | elinks | ||
33 | wipe | ||
34 | gnupg | ||
35 | nix-prefetch-scripts | ||
36 | shellcheck | ||
37 | ]; | ||
38 | |||
39 | # Some programs need SUID wrappers, can be configured further or are | ||
40 | # started in user sessions. | ||
41 | # programs.mtr.enable = true; | ||
42 | # programs.gnupg.agent = { | ||
43 | # enable = true; | ||
44 | # enableSSHSupport = true; | ||
45 | # }; | ||
46 | |||
47 | # List services that you want to enable: | ||
48 | |||
49 | # Enable the OpenSSH daemon. | ||
50 | services.openssh = { | ||
51 | enable = true; | ||
52 | passwordAuthentication = false; | ||
53 | }; | ||
54 | |||
55 | # Define a user account. Don't forget to set a password with ‘passwd’. | ||
56 | users.extraUsers.minijackson = { | ||
57 | isNormalUser = true; | ||
58 | extraGroups = [ "users" "wheel" ]; | ||
59 | openssh.authorizedKeys.keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCmyjB5yuU8GK3ZVFznELVEwXN7zzjQJcPYZ89YCGTANjPHpHxZv5R9/kgjTtIKrqqHdTvfr8V8sao9Nr7PhtcV9UywrFn+kplyGf9WDl2oDF9eZprX3beR9zwDj/YIcFRx3wXk4JK/ioZJjcVZ3+xWPixiFplvHIyMsTjKfgRplntHpvoyLM8vURjLOCdPr6SRPReVXuSR2DRlVO7q7y+4FwA1FKAndg9YACoM1g2bEJ6eGyCPp2kFde+GvMv1y6FlBS1OFddGmBpUJzJ4mQ4ebqDVFsKQMx1xCkiz0l7tfVpXqXToHF+baTESEKbC4654PunD99BC0J4otHKrerdmX0HdTgHKtAnslSwRD5NZVAojk/CR3DiSQYFSO9OhFVjHNQsc1zpoKPtJYMe1ax3pcvc+XLCrKLUdHH8x9rVGefZXwIyLrrGrB7fVlyIyX7j04dNALQZiuFOKCInaYypVLHLy0k+buhQlVqKCS6N1xP5O6JiWUKXFYYyoRmSoX9+bfPiwsMrPL+rYXkee0K67BI1NiFAYPmdFFM0jtdFaYuvgEAWw7b9WyWyO/JAdHRwtlqfAqraPBrb4sldvQfLBm8RdORBYMaVbg4EUKMOJjIeAAK+7xWPtg2XeJNnsje/IsWaVXIBx2IAC50uAnIZ/ksw5lyAZP+HyGIHhCAQChQ== minijackson@riseup.net"]; | ||
60 | }; | ||
61 | |||
62 | nix = { | ||
63 | autoOptimiseStore = true; | ||
64 | gc = { | ||
65 | automatic = true; | ||
66 | dates = "03:15"; | ||
67 | options = "--delete-older-than 30d"; | ||
68 | }; | ||
69 | }; | ||
70 | |||
71 | system.autoUpgrade.enable = true; | ||
72 | } | ||
diff --git a/dotfiles/vimrc.vim b/dotfiles/vimrc.vim new file mode 100644 index 0000000..a0451c6 --- /dev/null +++ b/dotfiles/vimrc.vim | |||
@@ -0,0 +1,139 @@ | |||
1 | " Some global variables are defined in ../vim.nix | ||
2 | |||
3 | " Better default options {{{ | ||
4 | |||
5 | set undofile | ||
6 | set backup | ||
7 | set backupdir-=. | ||
8 | |||
9 | set mouse=a | ||
10 | |||
11 | set ignorecase | ||
12 | set smartcase | ||
13 | |||
14 | set smartindent | ||
15 | set tabstop=4 | ||
16 | set shiftwidth=4 | ||
17 | |||
18 | set inccommand=split | ||
19 | |||
20 | set scrolloff=1 | ||
21 | set sidescrolloff=5 | ||
22 | |||
23 | set colorcolumn=80 | ||
24 | set cursorline | ||
25 | |||
26 | set modeline | ||
27 | |||
28 | set title | ||
29 | |||
30 | set wildmode=longest:full,full | ||
31 | |||
32 | let g:maplocalleader = ',' | ||
33 | let g:mapleader = ';' | ||
34 | |||
35 | " If previously opened jump to the last position in the file | ||
36 | au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | ||
37 | |||
38 | let &grepprg = g:ripgrep_path . ' --vimgrep $*' | ||
39 | let &grepformat = '%f:%l:%c:%m,' . &grepformat | ||
40 | |||
41 | let g:tex_flavor = 'latex' | ||
42 | |||
43 | " }}} | ||
44 | |||
45 | " Colors, Statusline, Tabline, Code display {{{ | ||
46 | |||
47 | set termguicolors | ||
48 | let g:gruvbox_contrast_dark = 'soft' | ||
49 | let g:gruvbox_italic = 1 | ||
50 | set background=dark | ||
51 | colorscheme gruvbox | ||
52 | |||
53 | " Doesn't do anything because the tabline gets overwritten by lightline | ||
54 | "exe 'hi! TabLineSel guifg=' . g:dominant_color | ||
55 | |||
56 | let g:lightline = { | ||
57 | \ 'colorscheme': 'gruvbox', | ||
58 | \ 'subseparator': { 'left': '|', 'right': '|' }, | ||
59 | \ 'tab_linesubseparator': { 'left': '|', 'right': '|' }, | ||
60 | \ } | ||
61 | |||
62 | set noshowmode | ||
63 | |||
64 | " Do not set "trail:-" because it messes up the highlighting | ||
65 | set listchars=tab:│\ ,extends:>,precedes:<,nbsp:+ | ||
66 | set list | ||
67 | |||
68 | set fillchars=fold:─,vert:│ | ||
69 | |||
70 | highlight ExtraWhitespace term=inverse cterm=inverse gui=inverse | ||
71 | " Show trailing whitespace and spaces before tabs: | ||
72 | autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL | ||
73 | |||
74 | " }}} | ||
75 | |||
76 | " Mappings {{{ | ||
77 | |||
78 | call camelcasemotion#CreateMotionMappings(g:maplocalleader) | ||
79 | |||
80 | nmap =of :set <C-R>=(&formatoptions =~ "a") ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR> | ||
81 | |||
82 | " }}} | ||
83 | |||
84 | set completefunc=syntaxcomplete#Complete | ||
85 | set completeopt+=noinsert,noselect | ||
86 | |||
87 | " Deoplete {{{ | ||
88 | |||
89 | let g:deoplete#enable_at_startup = 1 | ||
90 | |||
91 | " }}} | ||
92 | |||
93 | " Neosnippets {{{ | ||
94 | |||
95 | imap <C-k> <Plug>(neosnippet_expand_or_jump) | ||
96 | smap <C-k> <Plug>(neosnippet_expand_or_jump) | ||
97 | xmap <C-k> <Plug>(neosnippet_expand_target) | ||
98 | |||
99 | set conceallevel=2 | ||
100 | set concealcursor=nv | ||
101 | |||
102 | " }}} | ||
103 | |||
104 | " CtrlP {{{ | ||
105 | let g:ctrlp_user_command = g:fd_path . ' --type f --color never "" %s' | ||
106 | let g:ctrlp_use_caching = 0 | ||
107 | " }}} | ||
108 | |||
109 | " LanguageClient {{{ | ||
110 | let g:LanguageClient_loggingFile = stdpath('data') . '/LanguageClient.log' | ||
111 | let g:LanguageClient_serverStderr = stdpath('data') . '/LanguageServer.log' | ||
112 | " }}} | ||
113 | |||
114 | " VimWiki {{{ | ||
115 | " {'path': '~/Documents/Wiki', 'path_html': '~/Documents/Wiki/html'} \ | ||
116 | let g:vimwiki_list = [ | ||
117 | \ {'path': '~/Documents/Wiki/personal', | ||
118 | \ 'path_html': '~/Documents/Wiki/personal/html', | ||
119 | \ 'auto_tags': 1}, | ||
120 | \ {'path': '~/Documents/Wiki/science', 'path_html': '~/Documents/Wiki/science/html', 'auto_tags': 1}, | ||
121 | \ {'path': '~/Documents/Wiki/work', 'path_html': '~/Documents/Wiki/work/html', 'auto_tags': 1}, | ||
122 | \ ] | ||
123 | |||
124 | let g:vimwiki_global_ext = 0 | ||
125 | |||
126 | let g:vimwiki_auto_header = 1 | ||
127 | let g:vimwiki_hl_headers = 1 | ||
128 | let g:vimwiki_hl_cb_checked = 1 | ||
129 | let g:vimwiki_html_header_numbering = 2 | ||
130 | let g:vimwiki_html_header_numbering_sym = '.' | ||
131 | |||
132 | let g:vimwiki_links_header_level = 2 | ||
133 | let g:vimwiki_tags_header_level = 2 | ||
134 | let g:vimwiki_toc_header_level = 2 | ||
135 | |||
136 | call deoplete#custom#var('omni', 'input_patterns', { 'vimwiki': '\[\[\w*|\:\w+' }) | ||
137 | " }}} | ||
138 | |||
139 | " vim: fdm=marker | ||
diff --git a/dotfiles/zshrc b/dotfiles/zshrc new file mode 100644 index 0000000..1263eeb --- /dev/null +++ b/dotfiles/zshrc | |||
@@ -0,0 +1,242 @@ | |||
1 | # Some variables are defined in ../commandline.nix | ||
2 | |||
3 | # For users using home-manager | ||
4 | if [ -f "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then | ||
5 | . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" | ||
6 | fi | ||
7 | |||
8 | # Grml Zsh configuration {{{ | ||
9 | # ========================== | ||
10 | |||
11 | # With prompt specific sequences | ||
12 | local dominated="%{${dominant_escape_code}%}" | ||
13 | local dimmed="%{${dim_fg_escape_code}%}" | ||
14 | |||
15 | # Use the dominant color in the prompt | ||
16 | # In the username item for non-root, in the host item for root | ||
17 | if [ "$EUID" -ne 0 ]; then | ||
18 | zstyle ':prompt:grml:left:items:user' pre "${dominated}%B" | ||
19 | else | ||
20 | zstyle ':prompt:grml:left:items:host' pre "${dominated}" | ||
21 | zstyle ':prompt:grml:left:items:host' post "%f" | ||
22 | fi | ||
23 | |||
24 | # Change the style of VCS prompt info | ||
25 | zstyle ':vcs_info:*' check-for-changes true | ||
26 | zstyle ':vcs_info:*' stagedstr "s" | ||
27 | zstyle ':vcs_info:*' unstagedstr "u" | ||
28 | zstyle ':vcs_info:*' formats "${dimmed}(%f%s${dimmed})-[${dominated}%b${dimmed}]-{%f%c%u${dimmed}}%f " "zsh: %r" | ||
29 | zstyle ':vcs_info:*' actionformats "${dimmed}(%f%s${dimmed})-[${dominated}%b${dimmed}|%F{yellow}%a${dimmed}]-{%f%c%u${dimmed}}%f " "zsh: %r" | ||
30 | |||
31 | # }}} | ||
32 | |||
33 | # Completion system {{{ | ||
34 | # ===================== | ||
35 | |||
36 | # Change completion messages | ||
37 | zstyle ':completion:*:corrections' format "${dominated}%BFTFY: %b${dominated}(errors: %e)%f" | ||
38 | zstyle ':completion:*:descriptions' format "${dominated} -- So you want a %B%d%b${dominated}? --%f" | ||
39 | zstyle ':completion:*:messages' format "${dominated}You got mail: %f%d" | ||
40 | zstyle ':completion:*:warnings' format "%F{red}I'm sorry Dave, but I cannot allow you to find%f %d" | ||
41 | |||
42 | # Always activate selection in completion | ||
43 | zstyle ':completion:*' menu select | ||
44 | |||
45 | # Case insensitive completion and substring completion | ||
46 | zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' | ||
47 | |||
48 | # Increase the number of errors based on the length of the typed word. But make | ||
49 | # sure to cap (at 7) the max-errors to avoid hanging. | ||
50 | zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)' | ||
51 | |||
52 | # Tmux Completion {{{ | ||
53 | # ------------------- | ||
54 | |||
55 | # From: https://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html | ||
56 | # And: https://gist.github.com/blueyed/6856354 | ||
57 | |||
58 | _tmux_pane_words() { | ||
59 | local expl | ||
60 | local -a w | ||
61 | if [[ -z "$TMUX_PANE" ]]; then | ||
62 | _message "not running inside tmux!" | ||
63 | return 1 | ||
64 | fi | ||
65 | |||
66 | # Based on vim-tmuxcomplete's splitwords function. | ||
67 | # https://github.com/wellle/tmux-complete.vim/blob/master/sh/tmuxcomplete | ||
68 | _tmux_capture_pane() { | ||
69 | tmux capture-pane -J -p -S -100 $@ | | ||
70 | # Remove "^C". | ||
71 | sed 's/\^C\S*/ /g' | | ||
72 | # copy lines and split words | ||
73 | sed -e 'p;s/[^a-zA-Z0-9_]/ /g' | | ||
74 | # split on spaces | ||
75 | tr -s '[:space:]' '\n' | | ||
76 | # remove surrounding non-word characters | ||
77 | =grep -o "\w.*\w" | ||
78 | } | ||
79 | # Capture current pane first. | ||
80 | w=( ${(u)=$(_tmux_capture_pane)} ) | ||
81 | echo $w > /tmp/w1 | ||
82 | local i | ||
83 | for i in $(tmux list-panes -F '#D'); do | ||
84 | # Skip current pane (handled before). | ||
85 | [[ "$TMUX_PANE" = "$i" ]] && continue | ||
86 | w+=( ${(u)=$(_tmux_capture_pane -t $i)} ) | ||
87 | done | ||
88 | _wanted values expl 'word from current tmux pane' compadd -a w | ||
89 | } | ||
90 | |||
91 | zle -C tmux-pane-words-prefix complete-word _generic | ||
92 | zle -C tmux-pane-words-anywhere complete-word _generic | ||
93 | |||
94 | zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words | ||
95 | zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current | ||
96 | # Display the menu on first execution of the hotkey. | ||
97 | zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' menu yes select | ||
98 | zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}' | ||
99 | |||
100 | # }}} | ||
101 | |||
102 | # }}} | ||
103 | |||
104 | # Bindkeys {{{ | ||
105 | # ============ | ||
106 | |||
107 | bindkey -v | ||
108 | |||
109 | bindkey '^X^T' tmux-pane-words-prefix | ||
110 | |||
111 | bindkey '^[[A' history-substring-search-up | ||
112 | bindkey '^[[B' history-substring-search-down | ||
113 | bindkey '^[OA' history-substring-search-up | ||
114 | bindkey '^[OB' history-substring-search-down | ||
115 | |||
116 | # }}} | ||
117 | |||
118 | # Aliases {{{ | ||
119 | # =========== | ||
120 | |||
121 | # Some aliases taken from the Prezo zsh configuration framework: | ||
122 | # https://github.com/sorin-ionescu/prezto | ||
123 | |||
124 | # Git {{{ | ||
125 | # ------- | ||
126 | |||
127 | alias g='git' | ||
128 | |||
129 | # Branch (b) | ||
130 | alias gb='git branch' | ||
131 | |||
132 | # Commit (c) | ||
133 | alias gc='git commit --verbose' | ||
134 | alias gca='git commit --verbose --all' | ||
135 | alias gcf='git commit --amend --reuse-message HEAD' | ||
136 | alias gcs='git show' | ||
137 | |||
138 | alias gco='git checkout' | ||
139 | alias gcO='git checkout --patch' | ||
140 | |||
141 | # Fetch (f) | ||
142 | alias gf='git fetch' | ||
143 | alias gfm='git pull' | ||
144 | alias gfc='git clone' | ||
145 | alias gfcr='git clone --recurse-submodules' | ||
146 | |||
147 | # Index (i) | ||
148 | alias gia='git add' | ||
149 | alias giA='git add --patch' | ||
150 | alias gid='git diff --cached' | ||
151 | alias giD='git diff --cached --word-diff' | ||
152 | |||
153 | # Log (l) | ||
154 | logMediumFormat='%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B' | ||
155 | logBriefFormat='%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n' | ||
156 | logOnelineFormat='%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n' | ||
157 | |||
158 | alias gl='git log --topo-order --pretty=format:"${logMediumFormat}"' | ||
159 | alias gls='git log --topo-order --stat --pretty=format:"${logMediumFormat}"' | ||
160 | alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${logMediumFormat}"' | ||
161 | alias glg='git log --topo-order --all --graph --pretty=format:"${logOnelineFormat}"' | ||
162 | alias glo='git log --topo-order --pretty=format:"${logOnelineFormat}"' | ||
163 | alias glb='git log --topo-order --pretty=format:"${logBriefFormat}"' | ||
164 | alias glc='git shortlog --summary --numbered' | ||
165 | |||
166 | # Merge (m) | ||
167 | alias gm='git merge' | ||
168 | alias gmt='git mergetool' | ||
169 | |||
170 | # Push (p) | ||
171 | alias gp='git push' | ||
172 | alias gpf='git push --force-with-lease' | ||
173 | alias gpt='git push --tags' | ||
174 | |||
175 | # Rebase (r) | ||
176 | alias gr='git rebase' | ||
177 | |||
178 | # Stash (s) | ||
179 | alias gs='git stash' | ||
180 | |||
181 | # Working Copy (w) | ||
182 | alias gws='git status --ignore-submodules=none' | ||
183 | alias gwd='git diff' | ||
184 | alias gwD='git diff --word-diff' | ||
185 | |||
186 | # }}} | ||
187 | |||
188 | # Prevents some mistakes | ||
189 | alias cp='cp -i' | ||
190 | alias mv='mv -i' | ||
191 | alias rm='rm -i' | ||
192 | |||
193 | # }}} | ||
194 | |||
195 | # Helpful functions {{{ | ||
196 | # ===================== | ||
197 | |||
198 | function ssht | ||
199 | { | ||
200 | /usr/bin/env ssh -t "$@" "tmux new-session -A -s 'ssh-$HOST'" | ||
201 | } | ||
202 | |||
203 | compdef ssht=ssh | ||
204 | |||
205 | # }}} | ||
206 | |||
207 | # Abbreviations {{{ | ||
208 | # ================= | ||
209 | |||
210 | # Abbreviation system provided by the grml config | ||
211 | # More info here: | ||
212 | # http://www.zshwiki.org/home/examples/zleiab | ||
213 | |||
214 | abk=( | ||
215 | 'P' '|& ${(z)PAGER}' | ||
216 | 'L' '|& ${(z)PAGER}' | ||
217 | |||
218 | 'HL' ' --help |& ${(z)PAGER}' | ||
219 | |||
220 | 'G' '|& rg' | ||
221 | 'FG' '|& rg -F' | ||
222 | |||
223 | 'H' '| head' | ||
224 | 'T' '| tail' | ||
225 | 'C' '| wc -l' | ||
226 | ) | ||
227 | |||
228 | # }}} | ||
229 | |||
230 | # GPG / SSH agents {{{ | ||
231 | # ==================== | ||
232 | |||
233 | #function _gpg-agent-update-tty | ||
234 | #{ | ||
235 | # gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null | ||
236 | #} | ||
237 | # | ||
238 | #add-zsh-hook preexec _gpg-agent-update-tty | ||
239 | |||
240 | # }}} | ||
241 | |||
242 | # vim: fdm=marker | ||
diff --git a/lib/theme.nix b/lib/theme.nix new file mode 100644 index 0000000..72e43bc --- /dev/null +++ b/lib/theme.nix | |||
@@ -0,0 +1,35 @@ | |||
1 | { lib, ... }: | ||
2 | |||
3 | with lib; | ||
4 | let | ||
5 | # Convert 2 consecutive characters from a string from hexadecimal to decimal | ||
6 | hex2dec = str: start: | ||
7 | let | ||
8 | conversionTable = { | ||
9 | "0" = 0; "1" = 1; "2" = 2; "3" = 3; "4" = 4; | ||
10 | "5" = 5; "6" = 6; "7" = 7; "8" = 8; "9" = 9; | ||
11 | "a" = 10; "b" = 11; "c" = 12; | ||
12 | "d" = 13; "e" = 14; "f" = 15; | ||
13 | }; | ||
14 | firstHexDigit = toLower (elemAt (stringToCharacters str) start); | ||
15 | secondHexDigit = toLower (elemAt (stringToCharacters str) (start + 1)); | ||
16 | in conversionTable.${firstHexDigit} * 16 + conversionTable.${secondHexDigit}; | ||
17 | |||
18 | makeColorCode = color: | ||
19 | let genComponent = hex2dec color; | ||
20 | in "${toString (genComponent 1)};${toString (genComponent 3)};${toString (genComponent 5)}"; | ||
21 | |||
22 | hex2RGB = color: | ||
23 | let genComponent = hex2dec color; | ||
24 | in { | ||
25 | red = genComponent 1; | ||
26 | green = genComponent 3; | ||
27 | blue = genComponent 5; | ||
28 | }; | ||
29 | |||
30 | fgEscapeCode = hexCode: "[38;2;${makeColorCode hexCode}m"; | ||
31 | bgEscapeCode = hexCode: "[48;2;${makeColorCode hexCode}m"; | ||
32 | in | ||
33 | { | ||
34 | inherit fgEscapeCode bgEscapeCode hex2RGB; | ||
35 | } | ||
diff --git a/profiles/server.nix b/profiles/server.nix new file mode 100644 index 0000000..3084d26 --- /dev/null +++ b/profiles/server.nix | |||
@@ -0,0 +1,9 @@ | |||
1 | { modulesPath, ... }: | ||
2 | |||
3 | { | ||
4 | imports = [ | ||
5 | (modulesPath + "/profiles/headless.nix") | ||
6 | (modulesPath + "/profiles/hardened.nix") | ||
7 | ]; | ||
8 | |||
9 | } | ||