diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e1632a9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700013383, + "narHash": "sha256-ZBhrew3BrUEv48i+3Mp2pDjLU6dcue8BKMz6tCDSyfc=", + "owner": "langedev", + "repo": "home-manager", + "rev": "6498661f3856a685c4fa7a19d0f8cbe17c08d8bd", + "type": "github" + }, + "original": { + "owner": "langedev", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1699825797, + "narHash": "sha256-W2m42mVt4/O6CJFbECPfLApmi8bO+qscbmSeEKrSHEg=", + "owner": "langedev", + "repo": "nixpkgs", + "rev": "a69768a1c385042d46ff57396c49d26df5ac035c", + "type": "github" + }, + "original": { + "owner": "langedev", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ec6e780 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + description = "Home Manager configuration of pan"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs. + nixpkgs.url = "github:langedev/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:langedev/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + homeConfigurations."pan" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ ./home.nix ]; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..b5b997e --- /dev/null +++ b/home.nix @@ -0,0 +1,54 @@ +{ config, pkgs, ... }: + +{ + nixpkgs.config.allowUnfree = true; + home.username = "pan"; + home.homeDirectory = "/home/pan"; + + xdg.enable = true; + + imports = [ + ./programs/alacritty + ./programs/pywal + ./programs/fish + ./programs/nnn + ./programs/rofi + ]; + + home.packages = with pkgs; [ + eww-wayland # eww widgets + socat # For hyprland scripts + swww # Wallpaper engine + trash-cli # Trash application + dunst # Notification Manager + wlr-randr # Xrandr for wayland + + # Applications + syncthing # For syncing files between computers + discord # Chat app + gimp # Photo editting + mpv # Video player + pamixer # Volume control + playerctl # Control media + wget # Download web stuff + zathura # PDF viewer + feh # Image viewer + sshfs # SSH File system + appimage-run # Lets you run app images + + # Development stuff, can be removed + nodejs # For compiling JS stuff + jq # May be critical for scripts? + ]; + # home.file = {}; + + home.sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + BROWSER = "librewolf"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + home.stateVersion = "23.05"; # don't change lol, u know why +} diff --git a/programs/alacritty/default.nix b/programs/alacritty/default.nix new file mode 100644 index 0000000..49c8763 --- /dev/null +++ b/programs/alacritty/default.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +{ + programs.alacritty.enable = true; + + + programs.alacritty.settings = { + font = let fam = "Cascadia Code"; in { + normal = { + family = fam; + style = "Regular"; + }; + bold = { + family = fam; + style = "Bold"; + }; + italic = { + family = fam; + style = "Italic"; + }; + bold_italic = { + family = fam; + style = "Bold Italic"; + }; + offset = { + x = 0; + y = 0; + }; + size = 24.0; + }; + }; +} diff --git a/programs/fish/default.nix b/programs/fish/default.nix new file mode 100644 index 0000000..93c6018 --- /dev/null +++ b/programs/fish/default.nix @@ -0,0 +1,43 @@ +{ config, pkgs, ... }: + +{ + programs.fish.enable = true; + + programs.fish.interactiveShellInit = '' + cat ~/.cache/wal/sequences + ''; + + programs.fish.functions = { + fish_greeting = ""; + fish_prompt = '' + ${builtins.readFile ./functions/fish_prompt.fish} + ''; + fish_right_prompt = '' + ${builtins.readFile ./functions/fish_right_prompt.fish} + ''; + git_branch_name = '' + ${builtins.readFile ./functions/git_branch_name.fish} + ''; + git_is_dirty = '' + ${builtins.readFile ./functions/git_is_dirty.fish} + ''; + git_is_repo = '' + ${builtins.readFile ./functions/git_is_repo.fish} + ''; + git_is_staged = '' + ${builtins.readFile ./functions/git_is_staged.fish} + ''; + git_is_touched = '' + ${builtins.readFile ./functions/git_is_touched.fish} + ''; + git_is_worktree = '' + ${builtins.readFile ./functions/git_is_worktree.fish} + ''; + n = '' + ${builtins.readFile ./functions/n.fish} + ''; + ssh = '' + ${builtins.readFile ./functions/ssh.fish} + ''; + }; +} diff --git a/programs/fish/functions/fish_prompt.fish b/programs/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..1740f57 --- /dev/null +++ b/programs/fish/functions/fish_prompt.fish @@ -0,0 +1,13 @@ +set -l last_command_status $status + +set -l symbol 'τ' + +set -l normal_color (set_color normal) +set -l symbol_color (set_color blue -o) +set -l error_color (set_color red -o) + +if test $last_command_status -eq 0 + echo -n -s $symbol_color $symbol " " $normal_color +else + echo -n -s $error_color $symbol " " $normal_color +end diff --git a/programs/fish/functions/fish_right_prompt.fish b/programs/fish/functions/fish_right_prompt.fish new file mode 100644 index 0000000..f46799d --- /dev/null +++ b/programs/fish/functions/fish_right_prompt.fish @@ -0,0 +1,61 @@ +set -l cwd +set -l cwd_color (set_color blue) +set -l normal_color (set_color normal) +set -l branch_color (set_color yellow) +set -l meta_color (set_color red) + +if git_is_repo + echo -n -s $branch_color (git_branch_name) $normal_color + set -l git_meta "" + if test (command git ls-files --others --exclude-standard | wc -w 2> /dev/null) -gt 0 + set git_meta "$git_meta?" + end + if test (command git rev-list --walk-reflogs --count refs/stash 2> /dev/null) + set git_meta "$git_meta\$" + end + if git_is_touched + git_is_dirty && set git_meta "$git_meta⨯" + git_is_staged && set git_meta "$git_meta●" + end + set -l commit_count (command git rev-list --count --left-right (git remote)/(git_branch_name)"...HEAD" 2> /dev/null) + if test $commit_count + set -l behind (echo $commit_count | cut -f 1) + set -l ahead (echo $commit_count | cut -f 2) + if test $behind -gt 0 + set git_meta "$git_meta🠋" + end + if test $ahead -gt 0 + set git_meta "$git_meta🠉" + end + end + if test $git_meta + echo -n -s $meta_color " " $git_meta " " $normal_color + else + echo -n -s " " + end + + + set root_folder (command git rev-parse --show-toplevel 2> /dev/null) + set parent_root_folder (dirname $root_folder) + set cwd (echo $PWD | sed -e "s|$parent_root_folder/||") +else + set cwd (prompt_pwd) +end + + +echo -n -s $cwd_color "$cwd" +set_color --dim + +set -l S (math $CMD_DURATION/1000) +set -l M (math $S/60) + + +echo -n -s " " +if test $M -gt 1 + echo -n -s $M m +else if test $S -gt 1 + echo -n -s $S s +else + echo -n -s $CMD_DURATION ms +end +set_color normal diff --git a/programs/fish/functions/git_branch_name.fish b/programs/fish/functions/git_branch_name.fish new file mode 100644 index 0000000..20b4149 --- /dev/null +++ b/programs/fish/functions/git_branch_name.fish @@ -0,0 +1,4 @@ +git_is_repo; and begin + command git symbolic-ref --short HEAD 2> /dev/null; + or command git show-ref --head -s --abbrev | head -n1 2> /dev/null +end diff --git a/programs/fish/functions/git_is_dirty.fish b/programs/fish/functions/git_is_dirty.fish new file mode 100644 index 0000000..f92e54d --- /dev/null +++ b/programs/fish/functions/git_is_dirty.fish @@ -0,0 +1 @@ +git_is_worktree; and not command git diff --no-ext-diff --quiet --exit-code diff --git a/programs/fish/functions/git_is_repo.fish b/programs/fish/functions/git_is_repo.fish new file mode 100644 index 0000000..00a2cfc --- /dev/null +++ b/programs/fish/functions/git_is_repo.fish @@ -0,0 +1,5 @@ +test -d .git +or begin + set -l info (command git rev-parse --git-dir --is-bare-repository 2>/dev/null) + and test $info[2] = false +end diff --git a/programs/fish/functions/git_is_staged.fish b/programs/fish/functions/git_is_staged.fish new file mode 100644 index 0000000..ef6b7ac --- /dev/null +++ b/programs/fish/functions/git_is_staged.fish @@ -0,0 +1,3 @@ +git_is_repo; and begin + not command git diff --cached --no-ext-diff --quiet --exit-code +end diff --git a/programs/fish/functions/git_is_touched.fish b/programs/fish/functions/git_is_touched.fish new file mode 100644 index 0000000..5605630 --- /dev/null +++ b/programs/fish/functions/git_is_touched.fish @@ -0,0 +1,6 @@ +git_is_worktree; and begin + # The first checks for staged changes, the second for unstaged ones. + # We put them in this order because checking staged changes is *fast*. + not command git diff-index --cached --quiet HEAD -- >/dev/null 2>&1 + or not command git diff --no-ext-diff --quiet --exit-code >/dev/null 2>&1 +end diff --git a/programs/fish/functions/git_is_worktree.fish b/programs/fish/functions/git_is_worktree.fish new file mode 100644 index 0000000..8b2c700 --- /dev/null +++ b/programs/fish/functions/git_is_worktree.fish @@ -0,0 +1,2 @@ +git_is_repo +and test (command git rev-parse --is-inside-git-dir) = false diff --git a/programs/fish/functions/n.fish b/programs/fish/functions/n.fish new file mode 100644 index 0000000..86eb7c3 --- /dev/null +++ b/programs/fish/functions/n.fish @@ -0,0 +1,30 @@ +# Block nesting of nnn in subshells +if test -n "$NNNLVL" + if [ (expr $NNNLVL + 0) -ge 1 ] + exit + return + end +end + +# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set) +# To cd on quit only on ^G, remove the "-x" as in: +# set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd" +# NOTE: NNN_TMPFILE is fixed, should not be modified +if test -n "$XDG_CONFIG_HOME" + set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd" +else + set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd" +end + +# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn +# stty start undef +# stty stop undef +# stty lwrap undef +# stty lnext undef + +nnn -T v $argv + +if test -e $NNN_TMPFILE + source $NNN_TMPFILE + rm $NNN_TMPFILE +end diff --git a/programs/fish/functions/ssh.fish b/programs/fish/functions/ssh.fish new file mode 100644 index 0000000..ec2b82e --- /dev/null +++ b/programs/fish/functions/ssh.fish @@ -0,0 +1 @@ +command ssh -o IPQoS=0 $argv; diff --git a/programs/nnn/default.nix b/programs/nnn/default.nix new file mode 100644 index 0000000..e5f27c9 --- /dev/null +++ b/programs/nnn/default.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + programs.nnn.enable = true; + home.sessionVariables = { + NNN_FCOLORS = "0000E6310000000000000000"; + NNN_OPTS = "eH"; + NNN_FIFO = "/tmp/nnn.fifo"; + NNN_TRASH = "1"; + }; +} diff --git a/programs/pywal/default.nix b/programs/pywal/default.nix new file mode 100644 index 0000000..f754d3e --- /dev/null +++ b/programs/pywal/default.nix @@ -0,0 +1,8 @@ +{ config, pkgs, ... }: + +{ + programs.pywal.enable = true; + home.packages = with pkgs; [ + pywalfox # Update librewolf's colorscheme based on pywal + ]; +} diff --git a/programs/rofi/default.nix b/programs/rofi/default.nix new file mode 100644 index 0000000..e24db42 --- /dev/null +++ b/programs/rofi/default.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: + +{ + programs.rofi.enable = true; + programs.rofi.package = pkgs.rofi-wayland; + programs.wofi.settings = { + show = "dmenu"; # Default to dmenu + prompt = ""; + hide_scroll = true; + insensitive = true; + location = "bottom_right"; + dynamic_lines = true; + yoffset = -100; + xoffset = -40; + height = "50%"; + width = "50%"; + }; + programs.wofi.style = '' + window { + background: rgba(0, 0, 0, 255); + font-size: 4rem; + } + #entry, #input { + margin: 2px; + background: #FFFFFF; + border-width: 2px; + border-color: #000000; + } + ''; +}