diff options
author | Minijackson <minijackson@riseup.net> | 2021-04-18 16:58:23 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2021-04-18 16:58:23 +0200 |
commit | 8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b (patch) | |
tree | cd0de6a4642b76b42002dae5291c307d30727bc6 /common | |
parent | 46ac3d5464712d6b0e0bee4ac62543abcbf2db2c (diff) | |
download | nixos-config-reborn-8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b.tar.gz nixos-config-reborn-8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b.zip |
revamp with nix flakes + desktop config
Diffstat (limited to 'common')
-rw-r--r-- | common/commandline.nix | 116 | ||||
-rw-r--r-- | common/commandline/dircolors.nix | 7 | ||||
-rw-r--r-- | common/commandline/git.nix | 87 | ||||
-rw-r--r-- | common/commandline/htop.nix | 2 | ||||
-rw-r--r-- | common/commandline/tmux.nix | 2 | ||||
-rw-r--r-- | common/commandline/zsh.nix | 21 | ||||
-rw-r--r-- | common/default.nix | 22 | ||||
-rw-r--r-- | common/localization.nix | 11 | ||||
-rw-r--r-- | common/nix.nix | 19 | ||||
-rw-r--r-- | common/ssh.nix | 15 | ||||
-rw-r--r-- | common/theme.nix | 2 | ||||
-rw-r--r-- | common/tinc.nix | 45 | ||||
-rw-r--r-- | common/vim.nix | 2 |
13 files changed, 226 insertions, 125 deletions
diff --git a/common/commandline.nix b/common/commandline.nix index 36fae26..73dbb51 100644 --- a/common/commandline.nix +++ b/common/commandline.nix | |||
@@ -1,3 +1,5 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, pkgs, lib, ... }: | 3 | { config, pkgs, lib, ... }: |
2 | 4 | ||
3 | with import ../lib/theme.nix { inherit lib; }; | 5 | with import ../lib/theme.nix { inherit lib; }; |
@@ -8,11 +10,11 @@ let | |||
8 | in | 10 | in |
9 | { | 11 | { |
10 | imports = [ | 12 | imports = [ |
11 | ./commandline/dircolors.nix | 13 | (import ./commandline/dircolors.nix inputs) |
12 | ./commandline/git.nix | 14 | (import ./commandline/git.nix inputs) |
13 | ./commandline/htop.nix | 15 | (import ./commandline/htop.nix inputs) |
14 | ./commandline/tmux.nix | 16 | (import ./commandline/tmux.nix inputs) |
15 | ./commandline/zsh.nix | 17 | (import ./commandline/zsh.nix inputs) |
16 | ]; | 18 | ]; |
17 | 19 | ||
18 | environment.shellAliases = { | 20 | environment.shellAliases = { |
@@ -24,8 +26,6 @@ in | |||
24 | programs.bash = { | 26 | programs.bash = { |
25 | enableCompletion = true; | 27 | enableCompletion = true; |
26 | interactiveShellInit = '' | 28 | interactiveShellInit = '' |
27 | eval "$(${pkgs.starship}/bin/starship init bash)" | ||
28 | |||
29 | PATH="${pkgs.pazi}/bin:$PATH" | 29 | PATH="${pkgs.pazi}/bin:$PATH" |
30 | eval "$(pazi init bash)" | 30 | eval "$(pazi init bash)" |
31 | ''; | 31 | ''; |
@@ -42,67 +42,67 @@ in | |||
42 | }; | 42 | }; |
43 | 43 | ||
44 | security.sudo.extraConfig = | 44 | security.sudo.extraConfig = |
45 | let | 45 | let |
46 | lectureFile = builtins.toFile "sudoers.lecture" '' | 46 | lectureFile = builtins.toFile "sudoers.lecture" '' |
47 | [1m | 47 | [1m |
48 | ${dominantEscapeCode}"Bee" careful [34m__ | 48 | ${dominantEscapeCode}"Bee" careful [34m__ |
49 | ${dominantEscapeCode}with sudo! [34m// \ | 49 | ${dominantEscapeCode}with sudo! [34m// \ |
50 | \\_/ [33m// | 50 | \\_/ [33m// |
51 | [35m'''-.._.-'''-.._.. [33m-(||)(') | 51 | [35m'''-.._.-'''-.._.. [33m-(||)(') |
52 | ''''[0m | 52 | ''''[0m |
53 | 53 | ||
54 | ''; | 54 | ''; |
55 | in | 55 | in |
56 | '' | 56 | '' |
57 | Defaults lecture = always | 57 | Defaults lecture = always |
58 | Defaults lecture_file = "${lectureFile}" | 58 | Defaults lecture_file = "${lectureFile}" |
59 | ''; | 59 | ''; |
60 | 60 | ||
61 | home-manager.users.minijackson = { ... }: | 61 | home-manager.users.minijackson = { ... }: { |
62 | { | 62 | programs.bash.enable = true; |
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 | 63 | ||
72 | [git_status] | 64 | programs.bat = { |
73 | ahead = "^" | 65 | enable = true; |
74 | behind = "v" | 66 | config = { |
75 | deleted = "x" | 67 | theme = "TwoDark"; |
76 | 68 | }; | |
77 | [jobs] | 69 | }; |
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 | 70 | ||
89 | [nix_shell] | 71 | programs.pazi.enable = true; |
90 | style = "bold blue" | ||
91 | 72 | ||
92 | [character] | 73 | programs.starship = { |
93 | symbol = ">" | 74 | enable = true; |
94 | ''; | 75 | enableZshIntegration = false; |
95 | 76 | ||
96 | programs.bat = { | 77 | settings = { |
97 | enable = true; | 78 | character.symbol = ">"; |
98 | config = { | 79 | directory = { |
99 | theme = "TwoDark"; | 80 | fish_style_pwd_dir_length = 2; |
81 | style = "bold blue"; | ||
82 | }; | ||
83 | git_branch.symbol = "branch "; | ||
84 | git_status = { | ||
85 | ahead = "^"; | ||
86 | behind = "v"; | ||
87 | deleted = "x"; | ||
88 | }; | ||
89 | jobs.symbol = "+ "; | ||
90 | nix_shell.style = "bold blue"; | ||
91 | package = { | ||
92 | disabled = true; | ||
93 | style = "bold green"; | ||
94 | symbol = "version "; | ||
95 | }; | ||
96 | rust = { | ||
97 | style = "bold dimmed yellow"; | ||
98 | symbol = "rust "; | ||
100 | }; | 99 | }; |
101 | }; | 100 | }; |
102 | }; | 101 | }; |
102 | }; | ||
103 | 103 | ||
104 | home-manager.users.root = { ... }: | 104 | home-manager.users.root = { ... }: { |
105 | { | 105 | programs.bash.enable = true; |
106 | programs.bat = config.home-manager.users.minijackson.programs.bat; | 106 | programs.bat = lib.mkDefault config.home-manager.users.minijackson.programs.bat; |
107 | }; | 107 | }; |
108 | } | 108 | } |
diff --git a/common/commandline/dircolors.nix b/common/commandline/dircolors.nix index 7ef3a4d..f7bdae1 100644 --- a/common/commandline/dircolors.nix +++ b/common/commandline/dircolors.nix | |||
@@ -1,4 +1,6 @@ | |||
1 | { config, ... }: | 1 | inputs: |
2 | |||
3 | { config, lib, ... }: | ||
2 | 4 | ||
3 | { | 5 | { |
4 | home-manager.users.minijackson = { ... }: | 6 | home-manager.users.minijackson = { ... }: |
@@ -69,6 +71,7 @@ | |||
69 | 71 | ||
70 | home-manager.users.root = { ... }: | 72 | home-manager.users.root = { ... }: |
71 | { | 73 | { |
72 | programs.dircolors = config.home-manager.users.minijackson.programs.dircolors; | 74 | programs.dircolors = |
75 | lib.mkDefault config.home-manager.users.minijackson.programs.dircolors; | ||
73 | }; | 76 | }; |
74 | } | 77 | } |
diff --git a/common/commandline/git.nix b/common/commandline/git.nix index 597ef64..e231356 100644 --- a/common/commandline/git.nix +++ b/common/commandline/git.nix | |||
@@ -1,58 +1,61 @@ | |||
1 | { config, pkgs, ... }: | 1 | inputs: |
2 | |||
3 | { config, pkgs, lib, ... }: | ||
2 | 4 | ||
3 | { | 5 | { |
4 | # TODO: add signing | 6 | # TODO: add signing |
5 | home-manager.users.minijackson = { ... }: | 7 | home-manager.users.minijackson = { ... }: { |
6 | { | ||
7 | programs.git = { | 8 | programs.git = { |
8 | enable = true; | 9 | enable = true; |
9 | package = pkgs.gitAndTools.gitFull; | 10 | package = pkgs.gitAndTools.gitFull; |
10 | userEmail = "minijackson@riseup.net"; | 11 | userEmail = "minijackson@riseup.net"; |
11 | userName = "Minijackson"; | 12 | userName = "Minijackson"; |
12 | 13 | ||
13 | extraConfig = let | 14 | extraConfig = |
14 | deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta"; | 15 | let |
15 | in { | 16 | deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta"; |
16 | core = { | 17 | in |
17 | whitespace = "trailing-space,space-before-tab"; | 18 | { |
18 | pager = deltaCommand; | 19 | core = { |
19 | interactive.diffFilter = "${deltaCommand} --color-only"; | 20 | whitespace = "trailing-space,space-before-tab"; |
20 | }; | 21 | pager = deltaCommand; |
21 | merge = { tool = "nvimdiff"; }; | 22 | interactive.diffFilter = "${deltaCommand} --color-only"; |
22 | "mergetool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; }; | 23 | }; |
23 | 24 | merge = { tool = "nvimdiff"; }; | |
24 | delta = with config.theme.colors; { | 25 | "mergetool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; }; |
25 | features = "line-numbers decorations"; | 26 | |
26 | whitespace-error-style = "22 reverse"; | 27 | delta = with config.theme.colors; { |
27 | decorations = { | 28 | features = "line-numbers decorations"; |
28 | minus-style = "normal red"; | 29 | whitespace-error-style = "22 reverse"; |
29 | minus-non-emph-style = "normal red"; | 30 | decorations = { |
30 | minus-emph-style = "normal brightred"; | 31 | minus-style = "normal red"; |
31 | minus-empty-line-marker-style = "normal red"; | 32 | minus-non-emph-style = "normal red"; |
32 | 33 | minus-emph-style = "normal brightred"; | |
33 | plus-style = "reverse green"; | 34 | minus-empty-line-marker-style = "normal red"; |
34 | plus-non-emph-style = "reverse green"; | 35 | |
35 | plus-emph-style = "reverse brightgreen"; | 36 | plus-style = "reverse green"; |
36 | plus-empty-line-marker-style = "reverse green"; | 37 | plus-non-emph-style = "reverse green"; |
37 | 38 | plus-emph-style = "reverse brightgreen"; | |
38 | whitespace-error-style = "reverse green"; | 39 | plus-empty-line-marker-style = "reverse green"; |
39 | 40 | ||
40 | line-numbers-minus-style = "brightred"; | 41 | whitespace-error-style = "reverse green"; |
41 | line-numbers-zero-style = "brightblack"; | 42 | |
42 | line-numbers-plus-style = "brightgreen"; | 43 | line-numbers-minus-style = "brightred"; |
43 | 44 | line-numbers-zero-style = "brightblack"; | |
44 | file-style = "bright${dominantName}"; | 45 | line-numbers-plus-style = "brightgreen"; |
45 | line-numbers-left-style = dominantName; | 46 | |
46 | line-numbers-right-style = dominantName; | 47 | file-style = "bright${dominantName}"; |
48 | line-numbers-left-style = dominantName; | ||
49 | line-numbers-right-style = dominantName; | ||
50 | }; | ||
47 | }; | 51 | }; |
48 | }; | ||
49 | 52 | ||
50 | }; | 53 | }; |
51 | }; | 54 | }; |
52 | }; | 55 | }; |
53 | 56 | ||
54 | home-manager.users.root = { ... }: | 57 | home-manager.users.root = { ... }: { |
55 | { | 58 | programs.git = |
56 | programs.git = config.home-manager.users.minijackson.programs.git; | 59 | lib.mkDefault config.home-manager.users.minijackson.programs.git; |
57 | }; | 60 | }; |
58 | } | 61 | } |
diff --git a/common/commandline/htop.nix b/common/commandline/htop.nix index f9732a6..95763a0 100644 --- a/common/commandline/htop.nix +++ b/common/commandline/htop.nix | |||
@@ -1,3 +1,5 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, ... }: | 3 | { config, ... }: |
2 | 4 | ||
3 | { | 5 | { |
diff --git a/common/commandline/tmux.nix b/common/commandline/tmux.nix index aa4de9c..84d2cc8 100644 --- a/common/commandline/tmux.nix +++ b/common/commandline/tmux.nix | |||
@@ -1,3 +1,5 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, pkgs, ... } : | 3 | { config, pkgs, ... } : |
2 | 4 | ||
3 | let | 5 | let |
diff --git a/common/commandline/zsh.nix b/common/commandline/zsh.nix index 3376321..28899b1 100644 --- a/common/commandline/zsh.nix +++ b/common/commandline/zsh.nix | |||
@@ -1,3 +1,5 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, lib, pkgs, ... }: | 3 | { config, lib, pkgs, ... }: |
2 | 4 | ||
3 | with import ../../lib/theme.nix { inherit lib; }; | 5 | with import ../../lib/theme.nix { inherit lib; }; |
@@ -13,9 +15,6 @@ in | |||
13 | source "${pkgs.grml-zsh-config}/etc/zsh/zshrc" | 15 | source "${pkgs.grml-zsh-config}/etc/zsh/zshrc" |
14 | is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack" | 16 | is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack" |
15 | 17 | ||
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" | 18 | source "${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh" |
20 | 19 | ||
21 | function () { | 20 | function () { |
@@ -30,8 +29,6 @@ in | |||
30 | (mapAttrsToList | 29 | (mapAttrsToList |
31 | (variable: value: "${variable}=\"${value}\"") | 30 | (variable: value: "${variable}=\"${value}\"") |
32 | config.programs.less.envVariables)} | 31 | config.programs.less.envVariables)} |
33 | |||
34 | #eval "$(${pkgs.starship}/bin/starship init zsh)" | ||
35 | ''; | 32 | ''; |
36 | 33 | ||
37 | # otherwise it'll override the grml prompt | 34 | # otherwise it'll override the grml prompt |
@@ -56,4 +53,18 @@ in | |||
56 | }; | 53 | }; |
57 | 54 | ||
58 | users.defaultUserShell = pkgs.zsh; | 55 | users.defaultUserShell = pkgs.zsh; |
56 | |||
57 | home-manager.users.minijackson = { ... }: { | ||
58 | # Allows zsh config from home-manager | ||
59 | programs.zsh = { | ||
60 | enable = true; | ||
61 | # Completion is already handled by the GRML conf | ||
62 | enableCompletion = false; | ||
63 | }; | ||
64 | }; | ||
65 | |||
66 | home-manager.users.root = { ... }: { | ||
67 | programs.zsh = | ||
68 | lib.mkDefault config.home-manager.users.minijackson.programs.zsh; | ||
69 | }; | ||
59 | } | 70 | } |
diff --git a/common/default.nix b/common/default.nix index fc9086b..d4e2e39 100644 --- a/common/default.nix +++ b/common/default.nix | |||
@@ -1,11 +1,21 @@ | |||
1 | { ... }: | 1 | inputs: |
2 | |||
3 | { config, ... }: | ||
2 | 4 | ||
3 | { | 5 | { |
4 | imports = [ | 6 | imports = [ |
5 | <home-manager/nixos> | 7 | (import ./commandline.nix inputs) |
6 | ./commandline.nix | 8 | (import ./localization.nix inputs) |
7 | ./theme.nix | 9 | (import ./nix.nix inputs) |
8 | ./tinc.nix | 10 | (import ./ssh.nix inputs) |
9 | ./vim.nix | 11 | (import ./theme.nix inputs) |
12 | (import ./tinc.nix inputs) | ||
13 | (import ./vim.nix inputs) | ||
14 | ]; | ||
15 | |||
16 | nixpkgs.overlays = [ | ||
17 | (final: prev: { | ||
18 | unstable = inputs.nixpkgs-unstable.legacyPackages.${config.nixpkgs.system}; | ||
19 | }) | ||
10 | ]; | 20 | ]; |
11 | } | 21 | } |
diff --git a/common/localization.nix b/common/localization.nix new file mode 100644 index 0000000..958b36e --- /dev/null +++ b/common/localization.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | inputs: | ||
2 | |||
3 | { ... }: | ||
4 | |||
5 | { | ||
6 | time.timeZone = "Europe/Paris"; | ||
7 | i18n = { | ||
8 | defaultLocale = "en_US.UTF-8"; | ||
9 | extraLocaleSettings = { LC_TIME = "en_DK.UTF-8"; }; | ||
10 | }; | ||
11 | } | ||
diff --git a/common/nix.nix b/common/nix.nix new file mode 100644 index 0000000..f16e1d9 --- /dev/null +++ b/common/nix.nix | |||
@@ -0,0 +1,19 @@ | |||
1 | inputs: | ||
2 | |||
3 | { pkgs, ... }: | ||
4 | |||
5 | { | ||
6 | nix = { | ||
7 | autoOptimiseStore = true; | ||
8 | gc = { | ||
9 | automatic = true; | ||
10 | dates = "03:15"; | ||
11 | options = "--delete-older-than 30d"; | ||
12 | }; | ||
13 | |||
14 | package = pkgs.nixFlakes; | ||
15 | extraOptions = '' | ||
16 | experimental-features = nix-command flakes | ||
17 | ''; | ||
18 | }; | ||
19 | } | ||
diff --git a/common/ssh.nix b/common/ssh.nix new file mode 100644 index 0000000..8bdabc2 --- /dev/null +++ b/common/ssh.nix | |||
@@ -0,0 +1,15 @@ | |||
1 | inputs: | ||
2 | |||
3 | { config, pkgs, modulesPath, lib, ... }: | ||
4 | |||
5 | { | ||
6 | programs.gnupg.agent = { | ||
7 | enable = true; | ||
8 | enableSSHSupport = true; | ||
9 | }; | ||
10 | |||
11 | services.openssh = { | ||
12 | enable = true; | ||
13 | passwordAuthentication = false; | ||
14 | }; | ||
15 | } | ||
diff --git a/common/theme.nix b/common/theme.nix index 675bc33..cadd65d 100644 --- a/common/theme.nix +++ b/common/theme.nix | |||
@@ -5,6 +5,8 @@ | |||
5 | # - https://github.com/morhetz/gruvbox | 5 | # - https://github.com/morhetz/gruvbox |
6 | # - https://github.com/morhetz/gruvbox-contrib | 6 | # - https://github.com/morhetz/gruvbox-contrib |
7 | 7 | ||
8 | inputs: | ||
9 | |||
8 | { config, lib, ... }: | 10 | { config, lib, ... }: |
9 | 11 | ||
10 | with lib; | 12 | with lib; |
diff --git a/common/tinc.nix b/common/tinc.nix index d86b19c..e06bd27 100644 --- a/common/tinc.nix +++ b/common/tinc.nix | |||
@@ -1,11 +1,15 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, lib, ... }: | 3 | { config, lib, ... }: |
2 | 4 | ||
3 | with lib; | 5 | with lib; |
4 | with builtins; | 6 | with builtins; |
5 | let | 7 | { |
6 | networks = attrNames (readDir ./tinc/private); | 8 | imports = [ |
7 | in { | 9 | (inputs.nixpkgs-unstable.outPath + "/nixos/modules/services/networking/tinc.nix") |
8 | imports = map (network: (./tinc/private + "/${network}")) networks; | 10 | ]; |
11 | |||
12 | disabledModules = [ "services/networking/tinc.nix" ]; | ||
9 | 13 | ||
10 | options.topology = { | 14 | options.topology = { |
11 | mainVpn = { | 15 | mainVpn = { |
@@ -27,16 +31,33 @@ in { | |||
27 | }; | 31 | }; |
28 | 32 | ||
29 | config = { | 33 | config = { |
30 | services.tinc.networks = genAttrs networks (network: { | 34 | # Tinc configuration is in downstream repo |
31 | name = config.networking.hostName; | ||
32 | |||
33 | hosts = let | ||
34 | hosts = attrNames (readDir (./tinc/private + "/${network}/hosts")); | ||
35 | config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}"); | ||
36 | in genAttrs hosts config; | ||
37 | }); | ||
38 | 35 | ||
39 | networking.firewall.allowedUDPPorts = [ 655 ]; | 36 | networking.firewall.allowedUDPPorts = [ 655 ]; |
40 | networking.firewall.allowedTCPPorts = [ 655 ]; | 37 | networking.firewall.allowedTCPPorts = [ 655 ]; |
38 | |||
39 | networking.hosts = | ||
40 | with builtins; | ||
41 | with lib; | ||
42 | let | ||
43 | networks = config.services.tinc.networks; | ||
44 | hosts = (flatten | ||
45 | (mapAttrsToList | ||
46 | (name: network: mapAttrsToList | ||
47 | (host: settings: { | ||
48 | host = "${host}.${name}.vpn"; | ||
49 | addresses = map (subnet: subnet.address) settings.subnets; | ||
50 | }) | ||
51 | network.hostSettings) | ||
52 | networks)); | ||
53 | |||
54 | addresses = | ||
55 | zipAttrs | ||
56 | (flatten | ||
57 | (forEach hosts ({ host, addresses }: | ||
58 | (forEach addresses (address: | ||
59 | { "${address}" = host; }))))); | ||
60 | in | ||
61 | addresses; | ||
41 | }; | 62 | }; |
42 | } | 63 | } |
diff --git a/common/vim.nix b/common/vim.nix index 821d43b..aa74a39 100644 --- a/common/vim.nix +++ b/common/vim.nix | |||
@@ -1,3 +1,5 @@ | |||
1 | inputs: | ||
2 | |||
1 | { config, pkgs, lib, ... }: | 3 | { config, pkgs, lib, ... }: |
2 | 4 | ||
3 | let myNeovim = (pkgs.neovim.override { | 5 | let myNeovim = (pkgs.neovim.override { |