diff --git a/configuration.nix b/configuration.nix index a3a376f..8588d9e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -41,6 +41,8 @@ networking.useNetworkd = true; networking.dhcpcd.enable = false; + # Should remain enabled since nscd from glibc is kinda ass + services.nscd.enableNsncd = true; systemd.network.wait-online.anyInterface = true; services.resolved = { enable = true; @@ -60,8 +62,6 @@ packages = with pkgs; [terminus_font]; useXkbConfig = true; # use xkbOptions in tty. }; - # fix for Editor = nano - programs.zsh.enable = true; # Configure keymap in X11 services.xserver = { @@ -98,8 +98,8 @@ createHome = true; extraGroups = ["wheel" "audio" "video" "input"]; group = "patrick"; - shell = pkgs.zsh; - passwordFile = config.rekey.secrets.patrick.path; + shell = pkgs.fish; + passwordFile = config.rekey.secrets.patrick.path; }; users.groups.patrick.gid = 1000; @@ -109,8 +109,8 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDZixkix0KfKuq7Q19whS5FQQg51/AJGB5BiNF/7h/LM" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxD4GOrwrBTG4/qQhm5hoSB2CP7W9g1LPWP11oLGOjQ" ]; - shell = pkgs.zsh; - passwordFile = config.rekey.secrets.root.path; + shell = pkgs.fish; + passwordFile = config.rekey.secrets.root.path; }; security.sudo.enable = false; @@ -124,6 +124,7 @@ tree age-plugin-yubikey rage + file ]; # List services that you want to enable: diff --git a/data/zsh/zshrc b/data/zsh/zshrc index 0526958..df9cbdf 100644 --- a/data/zsh/zshrc +++ b/data/zsh/zshrc @@ -427,89 +427,7 @@ function zshaddhistory() { [[ ! $1 =~ "$HISTORY_IGNORE_REGEX" ]] } -# Start ssh-agent if not already running -# if ! pgrep -c -u "$USER" ssh-agent &>/dev/null; then -# ssh-agent -t 4h -s | grep -Fv 'echo' > ~/.ssh/ssh-agent-env \ -# && source ~/.ssh/ssh-agent-env -# elif [[ -e ~/.ssh/ssh-agent-env ]]; then -# source ~/.ssh/ssh-agent-env -# else -# echo "error: could not start 'ssh-agent'" >&2 -# fi - -# Aliases -alias l="ls -lahF --group-directories-first --show-control-chars --quoting-style=escape --color=auto" -alias ll="ls -lahF --group-directories-first --show-control-chars --quoting-style=escape --color=auto" -alias t="tree -F --dirsfirst -L 2" -alias tt="tree -F --dirsfirst -L 3 --filelimit 16" -alias ttt="tree -F --dirsfirst -L 6 --filelimit 16" - -alias md="mkdir" -alias rmd="rm -d" - -#because 2 less keys is still only half the work -alias ta="task" -alias tat="taskwarrior-tui" - -#what the fuck is going on here???? -alias cpr="rsync -axHAWXS --numeric-ids --info=progress2" - -alias cp="cp -vi" -alias mv="mv -vi" -alias rm="rm -I" -alias chmod="chmod -c --preserve-root" -alias chown="chown -c --preserve-root" -alias -s {md,txt,cpp,hpp,h,c}=vim - -alias ip="ip --color" -alias tmux="tmux -2" -alias rg="rg -S" - -#tar any number of given filen and compress them -alias comptar="tar -c -f archive.tar.xz -v -I 'pixz -9'" - -#random functions -#compress all files in current directory excluding folders and already compressed files -function compressAll() { - for i in $(ls -p | grep -E -v "/|(.xz|.gz|.zip)") - do - echo "compressing: " $i - pixz -9 $i - done -} - -#extract random file -function ex () { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xjf $1 ;; - *.tar.gz) tar xzf $1 ;; - *.tar.xz) tar xfJ $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xf $1 ;; - *.tbz2) tar xjf $1 ;; - *.tgz) tar xzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via ex()" ;; - esac - else - echo "'$1' is not a valid file" - fi -} - - -# Aliases when X is running -if xset q &>/dev/null; then - alias zf="zathura --fork" #pdf viewer -fi -alias vi="nvim" -alias vim="nvim" # Set umask umask 077 -alias luamake=/home/patrick/.local/share/nvim/lua-language-server/3rd/luamake/luamake diff --git a/flake.lock b/flake.lock index 20c33c8..2b2d279 100644 --- a/flake.lock +++ b/flake.lock @@ -81,11 +81,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1675545634, - "narHash": "sha256-TbQeQcM5TA/wIho6xtzG+inUfiGzUXi8ewwttiQWYJE=", + "lastModified": 1675673983, + "narHash": "sha256-8hzNh1jtiPxL5r3ICNzSmpSzV7kGb3KwX+FS5BWJUTo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0591d6b57bfeb55dfeec99a671843337bc2c3323", + "rev": "5a350a8f31bb7ef0c6e79aea3795a890cf7743d4", "type": "github" }, "original": { diff --git a/modules/rekey-drv.nix b/modules/rekey-drv.nix index 58e15a8..bfb30bb 100644 --- a/modules/rekey-drv.nix +++ b/modules/rekey-drv.nix @@ -15,8 +15,8 @@ pkgs: config: ( dontBuild = true; installPhase = '' - cp -r /tmp/nix-rekey.d/${builtins.hashString "sha1" pubKeyStr}/. $out \ - || { echo "Warning Secrets not available. Maybe you forgot to run 'nix run .#rekey' to rekey them?"; exit 1; } + cp -r /tmp/nix-rekey.d/${builtins.hashString "sha1" pubKeyStr}/. $out \ + || { echo "Warning Secrets not available. Maybe you forgot to run 'nix run .#rekey' to rekey them?"; exit 1; } ''; } ) diff --git a/modules/rekey.nix b/modules/rekey.nix index 036ec9e..7032c49 100644 --- a/modules/rekey.nix +++ b/modules/rekey.nix @@ -11,7 +11,7 @@ drv = import ./rekey-drv.nix pkgs config; in mkIf (config.rekey.secrets != {}) { - # export all secrets to agenix with rewritten path from rekey + # export all secrets to agenix with rewritten path from rekey age = { secrets = let secretPath = "${drv}/"; @@ -21,11 +21,11 @@ }; # Warn if rekey has to been executed - # use the drvPath to prevent nix from building the derivation in this step - # drvPath is not outPath so this warning does not work - # to fix it you would need some kind of way to access the outPath without evaluating the derivation + # use the drvPath to prevent nix from building the derivation in this step + # drvPath is not outPath so this warning does not work + # to fix it you would need some kind of way to access the outPath without evaluating the derivation #warnings = optional ( ! pathExists (removeSuffix ".drv" drv.drvPath)) '' - # Path ${drv.drvPath} + # Path ${drv.drvPath} # Rekeyed secrets not available. # Maybe you forgot to run "nix run '.#rekey'" to rekey them? #''; @@ -52,6 +52,5 @@ Only use yubikeys or password encrypted age keys ''; }; - }; } diff --git a/users/common/alias.nix b/users/common/alias.nix new file mode 100644 index 0000000..c81dd07 --- /dev/null +++ b/users/common/alias.nix @@ -0,0 +1,28 @@ +{...}: { + home.shellAliases = { + # Aliases + l = "ls -lahF --group-directories-first --show-control-chars --quoting-style=escape --color=auto"; + ll = "ls -lahF --group-directories-first --show-control-chars --quoting-style=escape --color=auto"; + t = "tree -F --dirsfirst -L 2"; + tt = "tree -F --dirsfirst -L 3 --filelimit 16"; + ttt = "tree -F --dirsfirst -L 6 --filelimit 16"; + + md = "mkdir"; + rmd = "rm -d"; + + #what the fuck is going on here???? + cpr = "rsync -axHAWXS --numeric-ids --info=progress2"; + + cp = "cp -vi"; + mv = "mv -vi"; + rm = "rm -I"; + chmod = "chmod -c --preserve-root"; + chown = "chown -c --preserve-root"; + + ip = "ip --color"; + tmux = "tmux -2"; + rg = "rg -S"; + + zf = "zathura --fork"; + }; +} diff --git a/users/common/default.nix b/users/common/default.nix index 9c8101b..3d49846 100644 --- a/users/common/default.nix +++ b/users/common/default.nix @@ -4,8 +4,10 @@ ... }: { imports = [ - ./zsh.nix + #./zsh.nix + ./fish.nix ./htop.nix + ./alias.nix ]; home.packages = with pkgs; [ diff --git a/users/common/fish.nix b/users/common/fish.nix new file mode 100644 index 0000000..69be036 --- /dev/null +++ b/users/common/fish.nix @@ -0,0 +1,132 @@ +{ + config, + pkgs, + lib, + ... +}: { + programs.atuin = { + enable = true; + settings.auto_sync = false; + }; + + programs.starship = { + enable = true; + settings = { + add_newline = false; + format = lib.concatStrings [ + "$username" + "$hostname" + " $directory" + "$git_branch" + "$git_commit" + "$git_state" + "$git_status" + "$nix_shell" + "$character" + ]; + + right_format = lib.concatStrings [ + "$cmd_duration" + "$status" + "$jobs" + "$time" + ]; + + username = { + style_user = "yellow"; + style_root = "bold red"; + show_always = true; + format = "[$user]($style)"; + }; + + hostname = { + style = "red"; + format = "@[$hostname]($style)"; + }; + + directory = { + format = "[$path]($style)[$read_only]($read_only_style) "; + fish_style_pwd_dir_length = 1; + truncate_to_repo = false; + }; + + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style)"; + }; + + git_status = { + conflicted = "$count"; + ahead = "⇡$count"; + behind = "⇣$count"; + diverged = "⇡$ahead_count⇣$behind_count"; + untracked = "?$count"; + stashed = "\\$$count"; + modified = "!$count"; + staged = "+$count"; + renamed = "→$count"; + deleted = "-$count"; + format = lib.concatStrings [ + "[( $conflicted)](red)" + "[( $stashed)](magenta)" + "[( $staged)](green)" + "[( $deleted)](red)" + "[( $renamed)](blue)" + "[( $modified)](yellow)" + "[( $untracked)](blue)" + "[( $ahead_behind)](green)" + ]; + }; + + nix_shell = { + heuristic = true; + }; + + cmd_duration = { + format = "[ $duration]($style) "; + style = "yellow"; + }; + + status = { + disabled = false; + pipestatus = true; + style = "red"; + pipestatus_format = "$pipestatus -> [$int( $signal_name)]($style)"; + pipestatus_separator = "[ | ]($style)"; + pipestatus_segment_format = "[$status]($style)"; + format = "[$status( $signal_name)]($style) "; + }; + + time = { + disabled = false; + format = "[ $time]($style)"; + style = "yellow"; + }; + }; + }; + + programs.fish = with lib; { + enable = true; + interactiveShellInit = lib.mkMerge [ + (lib.mkBefore '' + set -g ATUIN_NOBIND true + set -g fish_greeting + set -g fish_autosuggestion_enabled 0 + set -U FZF_COMPLETE 2 + '') + (lib.mkAfter '' + bind \cr _atuin_search + '') + ]; + plugins = [ + { + name = "fzf"; + src = pkgs.fetchFromGitHub { + owner = "jethrokuan"; + repo = "fzf"; + rev = "479fa67d7439b23095e01b64987ae79a91a4e283"; + sha256 = "0k6l21j192hrhy95092dm8029p52aakvzis7jiw48wnbckyidi6v"; + }; + } + ]; + }; +} diff --git a/users/common/kitty.nix b/users/common/kitty.nix index a0c1e8d..af81b5e 100644 --- a/users/common/kitty.nix +++ b/users/common/kitty.nix @@ -40,8 +40,8 @@ color12 = "#61afef"; color5 = " #9378de"; color13 = "#c678dd"; - color6 = " #cc9c66"; - color14 = "#e5ab69"; + color6 = " #56b6c2"; + color14 = "#56b6c2"; color7 = " #979eab"; color15 = "#abb2bf"; diff --git a/users/common/polybar.nix b/users/common/polybar.nix index e910172..062e0e8 100644 --- a/users/common/polybar.nix +++ b/users/common/polybar.nix @@ -8,9 +8,11 @@ # a = "lel" # a-b = "lul" # 2. polybar allows integer keys. In nix these have to be quoted - - -{lib, pkgs, ...}: let +{ + lib, + pkgs, + ... +}: let color = { shade1 = "#311B92"; shade2 = "#4527A0"; @@ -59,13 +61,13 @@ in { services.polybar = { enable = true; - package = pkgs.polybar.override{ - pulseSupport = true; - alsaSupport = true; - iwSupport = true; - }; + package = pkgs.polybar.override { + pulseSupport = true; + alsaSupport = true; + iwSupport = true; + }; - script = "polybar main @"; + script = "polybar main @"; settings = { "bar/main" = { monitor = "DP-1"; @@ -74,8 +76,8 @@ in { dpi = 96; height = 22; - offset.x = "0%"; - offset.y = "0%"; + offset.x = "0%"; + offset.y = "0%"; background = color.bground; foreground = color.fground; @@ -119,7 +121,6 @@ in { label-empty-foreground = "#707880"; }; - "module/workspaces" = { type = "internal/xworkspaces"; @@ -265,7 +266,6 @@ in { format.disconnected-background = color.shade3; format.disconnected-foreground = color.modulefg; format.disconnected-padding = "1"; - }; "module/keyboardswitcher" = { diff --git a/users/default.nix b/users/default.nix index 35793ba..286fc3e 100644 --- a/users/default.nix +++ b/users/default.nix @@ -3,7 +3,11 @@ home-manager, ... }: { - home-manager.users.patrick.imports = [./patrick.nix]; + home-manager.users.patrick.imports = [ + ./patrick.nix + ./common + ]; + home-manager.users.root = { imports = [./common]; home.stateVersion = "23.05"; diff --git a/users/patrick.nix b/users/patrick.nix index 91a1d1b..eaa4cad 100644 --- a/users/patrick.nix +++ b/users/patrick.nix @@ -9,7 +9,6 @@ common/autorandr.nix common/desktop.nix common/polybar.nix - ./common ]; home = {