From 96a6a21ecb28251c44c4f1bb9e1fbb401fd5ec30 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Fri, 17 Jun 2022 18:38:11 -0400 Subject: [PATCH] Clean up home manager stuff --- home-manager/bat.nix | 19 ++++++-- home-manager/fish.nix | 102 ++++++++++++++++++++++------------------ home-manager/ssh.nix | 99 ++++++++++++++++++++------------------ machines/levitation.nix | 1 + modules/docker.nix | 7 +++ modules/sway.nix | 4 ++ 6 files changed, 135 insertions(+), 97 deletions(-) diff --git a/home-manager/bat.nix b/home-manager/bat.nix index 0e0270a..30e99c2 100644 --- a/home-manager/bat.nix +++ b/home-manager/bat.nix @@ -1,11 +1,20 @@ { config, lib, pkgs, ... }: { - programs.bat = { - enable = true; - config = { - theme = "zenburn"; - style = "header,rule,snip,changes"; + + options.nathans-home.bat = with lib; { + enable = mkOption { + type = types.bool; + default = true; + }; + }; + config = lib.mkIf config.nathans-home.bat.enable { + programs.bat = { + enable = true; + config = { + theme = "zenburn"; + style = "header,rule,snip,changes"; + }; }; }; } diff --git a/home-manager/fish.nix b/home-manager/fish.nix index bf97970..b7126ea 100644 --- a/home-manager/fish.nix +++ b/home-manager/fish.nix @@ -1,56 +1,64 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { - ## Shell - # Shell proper - programs.fish = { - enable = true; - # Setup our aliases - shellAliases = { - ls = "exa --icons"; - la = "exa --icons -a"; - lg = "exa --icons --git"; - cat = "bat"; - dig = "dog"; - df = "duf"; - }; - # Custom configuration - interactiveShellInit = '' - # Setup any-nix-shell - any-nix-shell fish --info-right | source - # Load logger function - source ~/.config/fish/functions/cmdlogger.fish - ''; - functions = { - # Setup command logging to ~/.logs - cmdlogger = { - onEvent = "fish_preexec"; - body = '' - mkdir -p ~/.logs - echo (date -u +"%Y-%m-%dT%H:%M:%SZ")" "(echo %self)" "(pwd)": "$argv >> ~/.logs/(hostname)-(date "+%Y-%m-%d").log - ''; - }; + options.nathans-home.fish = with lib; { + enable = mkOption { + type = types.bool; + default = true; }; }; - # Starship, for the prompt - programs.starship = { - enable = true; - settings = { - directory = { - truncation_length = 3; - fish_style_pwd_dir_length = 1; + config = lib.mkIf config.nathans-home.fish.enable { + ## Shell + # Shell proper + programs.fish = { + enable = true; + # Setup our aliases + shellAliases = { + ls = "exa --icons"; + la = "exa --icons -a"; + lg = "exa --icons --git"; + cat = "bat"; + dig = "dog"; + df = "duf"; }; - git_commit = { - commit_hash_length = 6; - only_detached = false; + # Custom configuration + interactiveShellInit = '' + # Setup any-nix-shell + any-nix-shell fish --info-right | source + # Load logger function + source ~/.config/fish/functions/cmdlogger.fish + ''; + functions = { + # Setup command logging to ~/.logs + cmdlogger = { + onEvent = "fish_preexec"; + body = '' + mkdir -p ~/.logs + echo (date -u +"%Y-%m-%dT%H:%M:%SZ")" "(echo %self)" "(pwd)": "$argv >> ~/.logs/(hostname)-(date "+%Y-%m-%d").log + ''; + }; }; - package = { - symbol = ""; - }; - time = { - disabled = false; - format = "[$time]($style)"; - time_format = "%I:%M %p"; + }; + # Starship, for the prompt + programs.starship = { + enable = true; + settings = { + directory = { + truncation_length = 3; + fish_style_pwd_dir_length = 1; + }; + git_commit = { + commit_hash_length = 6; + only_detached = false; + }; + package = { + symbol = ""; + }; + time = { + disabled = false; + format = "[$time]($style)"; + time_format = "%I:%M %p"; + }; }; }; }; diff --git a/home-manager/ssh.nix b/home-manager/ssh.nix index f71ad8b..b0e70b1 100644 --- a/home-manager/ssh.nix +++ b/home-manager/ssh.nix @@ -1,51 +1,60 @@ { config, lib, pkgs, ... }: { - programs.ssh = { - # SSH configuration - enable = true; - # extra config to set the ciphers - extraConfig = '' - Ciphers aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr - ''; - # enable session reuse - controlMaster = "auto"; - controlPersist = "10m"; - # Configure known hosts - matchBlocks = { - "levitation" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.12.134"; - }; - "perception" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.55.145"; - }; - "oracles" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.108.12"; - }; - "tounge" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.98.121"; - }; - "shadowchild" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.217.149"; - }; - "matrix.community.rs" = { - forwardAgent = true; - user = "nathan"; - hostname = "172.23.129.209"; - }; - "de1955" = { - user = "de1955"; - hostname = "de1955.rsync.net"; + options.nathans-home.ssh = with lib; { + enable = mkOption { + type = types.bool; + default = true; + }; + }; + + config = lib.mkIf config.nathans-home.ssh.enable { + programs.ssh = { + # SSH configuration + enable = true; + # extra config to set the ciphers + extraConfig = '' + Ciphers aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr + ''; + # enable session reuse + controlMaster = "auto"; + controlPersist = "10m"; + # Configure known hosts + matchBlocks = { + "levitation" = { + forwardAgent = true; + user = "nathan"; + hostname = "100.95.223.6"; + }; + "perception" = { + forwardAgent = true; + user = "nathan"; + hostname = "100.67.146.101"; + }; + "oracles" = { + forwardAgent = true; + user = "nathan"; + hostname = "100.66.15.34"; + }; + "tounge" = { + forwardAgent = true; + user = "nathan"; + hostname = "172.23.98.121"; + }; + "shadowchild" = { + forwardAgent = true; + user = "nathan"; + hostname = "172.23.217.149"; + }; + "matrix.community.rs" = { + forwardAgent = true; + user = "nathan"; + hostname = "100.113.74.107"; + }; + "de1955" = { + user = "de1955"; + hostname = "de1955.rsync.net"; + }; }; }; }; diff --git a/machines/levitation.nix b/machines/levitation.nix index 6e0258b..008340f 100644 --- a/machines/levitation.nix +++ b/machines/levitation.nix @@ -8,6 +8,7 @@ domain = "mccarty.io"; useDHCP = false; interfaces.enp5s0.useDHCP = true; + nat.externalInterface = "enp5s0"; }; ### ## Enable programs we don't want on every machine diff --git a/modules/docker.nix b/modules/docker.nix index 1980d11..2403651 100644 --- a/modules/docker.nix +++ b/modules/docker.nix @@ -7,4 +7,11 @@ # Automatically prune to keep things lean autoPrune.enable = true; }; + # Setup networking for nixos containers + networking = { + nat = { + enable = true; + internalInterfaces = [ "ve-+" ]; + }; + }; } diff --git a/modules/sway.nix b/modules/sway.nix index 940539d..9fffa58 100644 --- a/modules/sway.nix +++ b/modules/sway.nix @@ -183,6 +183,10 @@ groupBy = "app-name"; # Bottom right corner anchor = "bottom-right"; + # Maximum visible notifications + maxVisible = 10; + # Sort by time in descending order (newest first) + sort = "-time"; }; # Swayidle for automatic screen locking services.swayidle = {