diff options
44 files changed, 1234 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ddf12a0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,18 @@ +[submodule "~/nixos/external/nvim/config"] + path = ~/nixos/external/nvim/config + url = https://github.com/phenax/peepeepoopoo-nvim-config.git +[submodule "packages/shotkey/source"] + path = packages/shotkey/source + url = https://github.com/phenax/shotkey.git +[submodule "packages/dwm/source"] + path = packages/dwm/source + url = git@github.com:phenax/dwm.git +[submodule "packages/st/source"] + path = packages/st/source + url = git@github.com:phenax/st.git +[submodule "packages/dmenu/source"] + path = packages/dmenu/source + url = git@github.com:phenax/dmenu.git +[submodule "packages/dwmblocks/source"] + path = packages/dwmblocks/source + url = git@github.com:phenax/dwmblocks.git diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..9ec52ab --- /dev/null +++ b/configuration.nix @@ -0,0 +1,206 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +let + # Packages + dmenu = pkgs.callPackage ./packages/dmenu/pkg.nix {}; + sensible-apps = pkgs.callPackage ./packages/sensible-apps/pkg.nix {}; + shotkey = pkgs.callPackage ./packages/shotkey/pkg.nix {}; + dwm = pkgs.callPackage ./packages/dwm/pkg.nix {}; + dwmBlocks = pkgs.callPackage ./packages/dwmblocks/pkg.nix {}; + st = pkgs.callPackage ./packages/st/pkg.nix {}; + + # Config + apps = (import ./packages/sensible-apps/sensible-apps.nix).apps; + windowManagers = { + dwm = '' + while true; do + (ssh-agent dwm &>> /tmp/dwm.log) || break; + done + ''; + }; +in { + imports = [ + ./hardware-configuration.nix + ]; + + nixpkgs.config = { + allowUnfree = true; + allowBroken = false; + }; + + # Network + networking.hostName = "dickhead"; + networking.networkmanager.enable = true; + + # I18n and keyboard layout + time.timeZone = "Asia/Kolkata"; + i18n.defaultLocale = "en_US.UTF-8"; + services.xserver.layout = "us"; + + # Global + environment.variables = { + EDITOR = apps.EDITOR; + VISUAL = apps.EDITOR; + TERMINAL = apps.TERMINAL; + BROWSER = apps.BROWSER; + PRIVATE_BROWSER = apps.PRIVATE_BROWSER; + }; + + environment.shells = [ pkgs.zsh pkgs.bashInteractive ]; + programs.zsh = { + enable = true; + enableCompletion = true; + enableBashCompletion = true; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + histFile = "~/.config/zshhistory"; + histSize = 50000; + interactiveShellInit = ''source ~/nixos/external/zsh/zshrc''; + promptInit = ""; + loginShellInit = '' + setup_dwm() { + echo "~/nixos/external/xconfig/init.sh; ${windowManagers.dwm}" > ~/.xinitrc; + } + + case "$(tty)" in + /dev/tty1) setup_dwm && startx ;; + *) echo "No tty for u" ;; + esac; + ''; + }; + + # X11 config + services.xserver = { + enable = true; + autorun = false; + displayManager.startx.enable = true; + libinput = { + enable = true; + tapping = true; + naturalScrolling = false; + }; + }; + fonts.fonts = with pkgs; [ + # jetbrains-mono + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + cozette + noto-fonts-emoji + ]; + services.picom = { + enable = true; + inactiveOpacity = 0.8; + backend = "glx"; + settings = { + "inactive-dim" = 0.3; + "focus-exclude" = [ "class_g = 'dwm'" "class_g = 'dmenu'"]; + }; + opacityRules = [ + "98:class_g = 'St' && focused" + "85:class_g = 'St' && !focused" + "90:class_g = 'qutebrowser' && !focused" + "100:class_g = 'qutebrowser' && focused" + ]; + menuOpacity = 0.9; + }; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + sound.enable = true; + # hardware.pulseaudio.enable = true; + + # User + users.users.imsohexy = { + isNormalUser = true; + extraGroups = [ + "wheel" + "input" + "audio" + "video" + "storage" + "git" + "networkmanager" + ]; + shell = pkgs.zsh; + }; + + # Nix config + nixpkgs.overlays = [ + (import ./external/nvim/neovim.nix) + (self: super: { + pass = super.pass.override { dmenu = dmenu; }; + }) + ]; + + # Packages + environment.systemPackages = with pkgs; [ + # Dev + neovim + silver-searcher + ripgrep + ctags + fzf + git + nodejs-15_x + yarn + + # Browser + firefox + brave + # qutebrowser + w3m + + # X + xorg.xinit + xorg.xrandr + xorg.xmodmap + xorg.xbacklight + + # Media + mpv + sxiv + feh + ffmpeg-full + + # Custom packages + sensible-apps + shotkey + dwm + dwmBlocks + st + dmenu + + # Utils + mtm + lf + pass + xcwd + alsaUtils + unzip + curl + wget + gotop + killall + inxi + pciutils + ]; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = false; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "20.09"; # Did you read the comment? +} + diff --git a/external/nvim/config b/external/nvim/config new file mode 160000 +Subproject fe37ad3930391ae10b44ce83154137d23a4a02d diff --git a/external/nvim/neovim.nix b/external/nvim/neovim.nix new file mode 100644 index 0000000..c9f93d0 --- /dev/null +++ b/external/nvim/neovim.nix @@ -0,0 +1,19 @@ +self: super: { + tree-sitter-updated = super.tree-sitter.overrideAttrs(oldAttrs: { + postInstall = '' + PREFIX=$out make install; + ''; + }); + neovim-unwrapped = super.neovim-unwrapped.overrideAttrs (oldAttrs: rec { + name = "neovim-nightly"; + version = "0.5-nightly"; + src = self.fetchFromGitHub { + owner = "neovim"; + repo = "neovim"; + rev = "nightly"; + sha256 = "0vpjdd32lgzyh85gyazqpms8vmaad6px3zx2svdxhvcdxgschqz9"; + }; + + nativeBuildInputs = with self.pkgs; [ unzip cmake pkgconfig gettext tree-sitter-updated ]; + }); +} diff --git a/external/xconfig/Xmodmap b/external/xconfig/Xmodmap new file mode 100644 index 0000000..8516782 --- /dev/null +++ b/external/xconfig/Xmodmap @@ -0,0 +1,8 @@ +clear Lock + +keycode 66 = Escape NoSymbol Escape +! keycode 66 = Hyper_L + +remove mod4 = Hyper_L +add mod3 = Hyper_L + diff --git a/external/xconfig/Xresources b/external/xconfig/Xresources new file mode 100644 index 0000000..ab3701b --- /dev/null +++ b/external/xconfig/Xresources @@ -0,0 +1,57 @@ + + +#define bg #0f0c19 +#define fg #d8dee9 +#define acc #4e3aA3 +! #383F6B +! #5587BA + +! Special +*.foreground: fg +*.background: bg +*.cursorColor: fg +*.accent: acc + +! Colors +*.color0: #15121f +*.color8: #555555 + +*.color1: #e06c75 +*.color9: #bf616a + +*.color2: #98C379 +*.color10: #a3be8c + +*.color3: #E5C07B +*.color11: #f7b731 + +*.color4: #60a3bc +*.color12: #5e81ac + +*.color5: #4e3aA3 +*.color13: #4e3aA3 + +*.color6: #56B6C2 +*.color14: #0fb9b1 + +*.color7: #ABB2BF +*.color15: #ebdbb2 + +dmenu.background: bg +dmenu.foreground: fg +dmenu.selbackground: acc +dmenu.selforeground: fg + +dmenu.highlightbg: bg +dmenu.highlightfg: acc +dmenu.highlightselbg: acc +dmenu.highlightselfg: bg + +dwm.normbordercolor: bg +dwm.normbgcolor: bg +dwm.normfgcolor: fg + +dwm.selbordercolor: acc +dwm.selbgcolor: acc +dwm.selfgcolor: fg + diff --git a/external/xconfig/init.sh b/external/xconfig/init.sh new file mode 100755 index 0000000..d51f6df --- /dev/null +++ b/external/xconfig/init.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +NIX_X="$HOME/nixos/external/xconfig"; + +# Xresources (theme) +xrdb -merge $NIX_X/Xresources; + +# Xmodmap (keymapping) +xmodmap $NIX_X/Xmodmap; + +# No screen saver +xset s off; +xset -dpms; +xset s noblank; + +# Typing rate +xset r rate 350 30; + +# Display settings +# ~/scripts/commands/:day + +# Sound +#~/scripts/sound.sh mic-vol full; +#~/scripts/sound.sh mute-mic; +#~/scripts/sound.sh mute; + diff --git a/external/zsh/aliases.zsh b/external/zsh/aliases.zsh new file mode 100644 index 0000000..7fb9112 --- /dev/null +++ b/external/zsh/aliases.zsh @@ -0,0 +1,34 @@ + +for f in $ZSH_CUSTOM_CONF_FILES/aliases/*.zsh; do source $f; done; + +alias grep="grep --color=auto"; + +# Application shortcuts +alias e="sensible-editor"; +alias v="nvim"; +alias o='open $(fzf)'; + +# Load work aliases +# source "$HOME/.work-config/zshconf/aliases.zsh"; + +# Utility stuff +alias clock="tty-clock -t -b -c"; +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'; +alias show-mobile-screen="adb shell screenrecord --output-format=h264 - | ffplay -"; + +# QR file transfer +alias qr-send="qrcp"; +alias qr-get="qrcp receive"; +qr-str() { curl qrenco.de/$1; } + +# Audio download +alias dl-audio="youtube-dl --ignore-errors --output '%(title)s.%(ext)s' --extract-audio"; + +# Swallow window +alias smpv="swallow mpv"; +alias ssxiv="swallow sxiv"; +alias szathura="swallow zathura"; + +# Dictionary +dict() { curl dict://dict.org/d:$1; } + diff --git a/external/zsh/aliases/dev.zsh b/external/zsh/aliases/dev.zsh new file mode 100644 index 0000000..c02eb20 --- /dev/null +++ b/external/zsh/aliases/dev.zsh @@ -0,0 +1,24 @@ + +alias aws="docker run --rm -it amazon/aws-cli" + +# :: Filename Pattern Replacetext +far() { + local file_r="$1"; shift; + local matcher_r="$1"; shift; + local result="$1"; shift; + fd "$file_r" | sad "$matcher_r" "$result" -p diff-so-fancy "$@"; +} + +# :: FileType Filename +codi() { + local syntax="${1:-python}" + shift + nvim -c \ + "let g:startify_disable_at_vimenter = 1 |\ + set bt=nofile ls=0 |\ + hi ColorColumn ctermbg=NONE |\ + hi VertSplit ctermbg=NONE |\ + hi NonText ctermfg=0 |\ + Codi $syntax" "$@" +} + diff --git a/external/zsh/aliases/dir.zsh b/external/zsh/aliases/dir.zsh new file mode 100644 index 0000000..508634e --- /dev/null +++ b/external/zsh/aliases/dir.zsh @@ -0,0 +1,27 @@ +take() { mkdir -p $@ && cd ${@:$#}; } + +alias ..='cd ..'; +alias ...='cd ../..'; + +alias gdv='cd ~/dev/'; + +alias gpic='cd ~/Pictures'; +alias gdl='cd ~/Downloads/dl'; +alias gm='cd ~/Downloads/music'; + +alias gnotes='cd ~/.config/vimwiki'; +alias gqute='cd ~/.config/qutebrowser'; + +alias gvim='cd ~/.config/nvim'; +alias gcmd='cd ~/scripts/commands'; +alias gzsh='cd ~/.config/zshconf'; + +alias gsuck='cd ~/.config/suckless'; +alias gdwm='cd ~/.config/suckless/dwm'; +alias gbar='cd ~/.config/suckless/dwmblocks'; + +alias gkey='cd ~/.config/suckless/shotkey'; + +alias gmutt='cd ~/.config/neomutt'; +alias gmuttp='cd ~/.work-config/neomutt'; + diff --git a/external/zsh/aliases/edit.zsh b/external/zsh/aliases/edit.zsh new file mode 100644 index 0000000..fa5e1b6 --- /dev/null +++ b/external/zsh/aliases/edit.zsh @@ -0,0 +1,17 @@ +# Config editors +alias eorg='gnotes && sensible-editor index.md'; +alias ezsh='gzsh && sensible-editor ~/.zshrc'; +alias edot='sensible-editor ~/scripts/dotfiles.sh'; +alias evim='gvim && sensible-editor init.lua'; + +alias edwm='gdwm && sensible-editor config.def.h'; +alias ebar='gbar && sensible-editor blocks.h'; +alias ekey='gkey && sensible-editor config.h'; +alias equte='gqute && sensible-editor config.py'; +alias eas='sensible-editor ~/.config/autostart.sh'; +alias emime="sensible-editor ~/.bin/open"; + +alias ehosts='sudo nvim /etc/hosts'; + +alias emutt='gmuttp && sensible-editor ~/.config/neomutt/neomuttrc'; + diff --git a/external/zsh/aliases/git.zsh b/external/zsh/aliases/git.zsh new file mode 100644 index 0000000..47d8c0c --- /dev/null +++ b/external/zsh/aliases/git.zsh @@ -0,0 +1,70 @@ +#function git_current_branch() { + #local ref + #ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) + #local ret=$? + #if [[ $ret != 0 ]]; then + #[[ $ret == 128 ]] && return # no git repo. + #ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + #fi + #echo ${ref#refs/heads/} +#} + +# reset-origin a2_develop +reset-origin() { + if [[ -z $(git status -s) ]]; + then + currentBranch="$(git rev-parse --abbrev-ref HEAD)"; + branch="$1"; + git checkout $branch && + git pull && + git reset --hard origin/production && + git push -u origin $branch -f && + git checkout $currentBranch; + else + echo "Your branch is dirty. Stash or commit changed before proceeding"; + fi +} + +# Git aliases +alias g='git' + +alias ga='git add' +alias gaa='git add --all' + +alias gco='git checkout' +alias gb='git branch' + +alias gc='git commit -v' +alias gcm='git commit -v -m' +alias gc!='git commit -v --amend' + +alias gst='git status' +alias gd='git diff' +alias gl='git log' + +alias gp='git push' + +grename() { + if [[ -z "$1" || -z "$2" ]]; then + echo "Usage: $0 old_branch new_branch" + return 1 + fi + + # Rename branch locally + git branch -m "$1" "$2" + # Rename branch in origin remote + if git push origin :"$1"; then + git push --set-upstream origin "$2" + fi +} + +g_most_edited() { + git log --pretty=format: --name-only "$@" | \ + sort | \ + uniq -c | \ + sort -rg | \ + grep -E -v '.(html|scss|json)$' | \ + head -n 10 \ + ; +} + diff --git a/external/zsh/aliases/ls.zsh b/external/zsh/aliases/ls.zsh new file mode 100644 index 0000000..b199563 --- /dev/null +++ b/external/zsh/aliases/ls.zsh @@ -0,0 +1,22 @@ +# Trash +alias trash="ls \$TRASH_TMP_DIR"; + +# List files aliases +alias ls="lsd"; +alias l="ls -1"; +alias la='ls -a'; +alias ll='ls -alF'; +alias lt='ls --tree'; +alias la='ls -A'; +alias lsize='du -h -d1'; + +lc () { # lf with cd to navigated directory on quit + tmp="$(mktemp)" + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} + diff --git a/external/zsh/aliases/npm.zsh b/external/zsh/aliases/npm.zsh new file mode 100644 index 0000000..efc8ec7 --- /dev/null +++ b/external/zsh/aliases/npm.zsh @@ -0,0 +1,20 @@ + +# Node aliases +alias nr="npm run"; +alias ns="npm start"; +alias nt="npm test"; + +run_npm_script() { + [[ ! -f "package.json" ]] && return 1; + + local commands=$(node -e 'const pkg = require("./package.json"); Object.entries(pkg.scripts || {}).map(([key, value]) => console.log(`${key}\t\t "${value}"`))'); + + local result=$(echo -e "$commands" | fzf | cut -f1); + + [[ -z "$result" ]] && return 1; + yarn "$result"; +} + +zle -N run_npm_script; +bindkey '^B' run_npm_script; + diff --git a/external/zsh/aliases/system.zsh b/external/zsh/aliases/system.zsh new file mode 100644 index 0000000..48951a9 --- /dev/null +++ b/external/zsh/aliases/system.zsh @@ -0,0 +1,13 @@ + +# Pacman aliases +alias auto-remove="yay -Rcs \$(yay -Qdtq)"; +alias update="yay -Syu"; +alias mirrorlist-refresh="sudo reflector --latest 200 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist-arch" + +# Sandbox +alias sandbox="sudo ~/scripts/host-file-elb-update.sh"; + +# Runit helpers +sv_enable() { [[ -f "/etc/runit/sv/$1" ]] && sudo ln -s /etc/runit/sv/$1 /run/runit/service; } +sv_disable() { sudo unlink /run/runit/service/$1; } + diff --git a/external/zsh/aliases/xplt.zsh b/external/zsh/aliases/xplt.zsh new file mode 100644 index 0000000..e2df43d --- /dev/null +++ b/external/zsh/aliases/xplt.zsh @@ -0,0 +1,55 @@ +export WORDLISTS=~/dev/xploits/wordlist; +export ROCK_YOU_WORDS="$WORDLISTS/rockyou.txt"; +export URL_WORDS="$WORDLISTS/dirb/common.txt"; +export URL_WORDS_MED="$WORDLISTS/dirb/dirbuster/directory-list-lowercase-2.3-medium.txt"; + +# metasploit +alias msfc="msfconsole --quiet -x \"db_connect postgres@msf\"" +# exploitdb +alias ssplt="searchsploit" +alias sspx="searchsploit -x" + +# Port scan +alias rmap="docker run -it --rm --name rustscan rustscan/rustscan:1.10.0" + +# DVWA +alias dvwa="docker run --rm -it -p 80:80 vulnerables/web-dvwa" + +# Directory search +alias crawl="gobuster dir -w $URL_WORDS" +alias crawl_strict="gobuster dir -w $URL_WORDS_MED" + +new_room() { + take ~/dev/xploits/temp/$1; nvim README.md; +} + +jrock() { + [[ "$#" != "2" ]] && echo "jrock (format) (hashfile)" && return 1; + john -format="$1" "$2" -wordlist=$ROCK_YOU_WORDS; +} + +hrock() { + # Usage: hrock $mode $hashfile + # mode - (1800 for sha512crypt $6$) + [[ "$#" != "2" ]] && echo "hrock (mode-num) (hashfile)" && return 1; + hashcat -m "$1" "$2" -o ./out $ROCK_YOU_WORDS --force; +} + +hydra_ssh() { + # Usage: hydra_ssh $username $ip + [[ "$#" != "2" ]] && echo "hydru (username) (host)" && return 1; + hydra -l $1 -P $ROCK_YOU_WORDS ssh://$2 -V; +} +hydra_post() { + # Usage: hydra_post $username $ip $login-string + # /login:username=^USER^&password=^PASS^:incorrect + [[ "$#" != "2" ]] && echo "hydru (username) (host)" && return 1; + hydra -l $1 -P $ROCK_YOU_WORDS $2 http-post-form "$3" -V; +} + +ip_get() { + # Usage: ip_get [$ip] + curl https://json.geoiplookup.io/$1 | \ + jq '.ip + " | " + .asn + "(" + .district + ", " + .region + ")"'; +} + diff --git a/external/zsh/config.zsh b/external/zsh/config.zsh new file mode 100644 index 0000000..eb409fa --- /dev/null +++ b/external/zsh/config.zsh @@ -0,0 +1,14 @@ +export VISUAL='nvim' +export EDITOR="nvim" +export TERMINAL="st" +export BROWSER="qutebrowser" +export PRIVATE_BROWSER="$BROWSER ':open -p'"; +export READER="zathura" +export FILE="lf" + +export FZF_DEFAULT_OPTS="--layout=reverse --height 40%" + +export HISTCONTROL=ignoreboth + +export LS_COLORS='di=35:ln=36:or=31:mi=31:ex=32:*.ts=36'; + diff --git a/external/zsh/init.zsh b/external/zsh/init.zsh new file mode 100644 index 0000000..1d7825c --- /dev/null +++ b/external/zsh/init.zsh @@ -0,0 +1,11 @@ + +export TRASH_TMP_DIR=/tmp/.trash-cache; + +[[ ! -d "$TRASH_TMP_DIR" ]] && mkdir $TRASH_TMP_DIR; + +#export rmrf() { + #for var in "$@"; do + #mv $var $TRASH_TMP_DIR; + #done +#} + diff --git a/external/zsh/keys.zsh b/external/zsh/keys.zsh new file mode 100644 index 0000000..5ed993c --- /dev/null +++ b/external/zsh/keys.zsh @@ -0,0 +1,51 @@ +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + function zle-line-init() { + echoti smkx + } + function zle-line-finish() { + echoti rmkx + } + zle -N zle-line-init + zle -N zle-line-finish +fi + +bindkey -e; + +autoload -z edit-command-line; zle -N edit-command-line; +bindkey "^E" edit-command-line; + +bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word +bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word + +# CHeck +bindkey ' ' magic-space + +if [[ "${terminfo[kpp]}" != "" ]]; then + bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history +fi +if [[ "${terminfo[knp]}" != "" ]]; then + bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history +fi + +bindkey '^?' backward-delete-char # [Backspace] - delete backward +if [[ "${terminfo[kdch1]}" != "" ]]; then + bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward +else + bindkey "^[[3~" delete-char + bindkey "^[3;5~" delete-char + bindkey "\e[3~" delete-char +fi + +# start typing + [Up-Arrow] - fuzzy find history forward +if [[ "${terminfo[kcuu1]}" != "" ]]; then + autoload -U up-line-or-beginning-search + zle -N up-line-or-beginning-search + bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search +fi +# start typing + [Down-Arrow] - fuzzy find history backward +if [[ "${terminfo[kcud1]}" != "" ]]; then + autoload -U down-line-or-beginning-search + zle -N down-line-or-beginning-search + bindkey "${terminfo[kcud1]}" down-line-or-beginning-search +fi + diff --git a/external/zsh/paths.zsh b/external/zsh/paths.zsh new file mode 100644 index 0000000..7f5b26b --- /dev/null +++ b/external/zsh/paths.zsh @@ -0,0 +1,42 @@ +export XDG_CONFIG_HOME=$HOME/.config; +export XDG_DATA_HOME=$HOME/.local/share; +export PKG_CONFIG_PATH=/usr/lib/pkgconfig; + +# Local scripts +export SCRIPTS_DIR="$HOME/scripts"; +export SCRIPTS_BINARY_DIR="$HOME/.bin"; +export COMMANDS_DIR="$HOME/scripts/commands"; + +# Lang specific stuff +export CARGO_HOME=$XDG_CONFIG_HOME/cargo; +export GEM_HOME=$HOME/.gem; +export GOROOT=/usr/lib/go; +export GOPATH=$HOME/dev/go; +export DENO_INSTALL="$HOME/.config/deno"; + +# Path +PATH=$GEM_HOME/ruby/2.7.0/bin:$GOPATH/bin:$GOROOT/bin:$CARGO_HOME/bin:$DENO_INSTALL/bin:$PATH; +PATH="$HOME/.local/bin:$PATH" +PATH="$SCRIPTS_BINARY_DIR:$PATH"; +PATH="$COMMANDS_DIR:$PATH"; +export PATH; + +# Android/JVM garbage TODO: Remove if not needed +export ANDROID_HOME=$HOME/dump/android-sdk; +PATH=$PATH:$HOME/.config/android-sdk/platform-tools; +PATH=$HOME/dump/flutter/bin:$PATH; +export PATH; + + +# Util config +export rofi_LIBS=/usr; +export GNUPGHOME=$XDG_CONFIG_HOME/gnupg; +export PASSWORD_STORE_DIR=$XDG_CONFIG_HOME/password-store; +export BTPD_HOME=$XDG_CONFIG_HOME/btpd; + +# Development dir variables +export DEV_DIR="$HOME/dev"; +export PROJECTS_DIR="$DEV_DIR/projects"; +export SHAADI=$PROJECTS_DIR/sh-react; +export REG_SHAADI=$PROJECTS_DIR/sh-profile-creation; + diff --git a/external/zsh/plugins.zsh b/external/zsh/plugins.zsh new file mode 100644 index 0000000..0ab6100 --- /dev/null +++ b/external/zsh/plugins.zsh @@ -0,0 +1 @@ +for f in $ZSH_CUSTOM_CONF_FILES/plugins/*.zsh; do source $f; done; diff --git a/external/zsh/plugins/completion.zsh b/external/zsh/plugins/completion.zsh new file mode 100644 index 0000000..bf6e731 --- /dev/null +++ b/external/zsh/plugins/completion.zsh @@ -0,0 +1,11 @@ + +autoload -Uz compinit && compinit; +# load bashcompinit for some old bash completions +autoload bashcompinit && bashcompinit + +# partial completion suggestions +zstyle ':completion:*' list-suffixes +zstyle ':completion:*' expand prefix suffix + +# Case insensitive +zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' diff --git a/external/zsh/plugins/fzf-history.zsh b/external/zsh/plugins/fzf-history.zsh new file mode 100644 index 0000000..f91cc99 --- /dev/null +++ b/external/zsh/plugins/fzf-history.zsh @@ -0,0 +1,19 @@ +full_history() { + [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1; +} + +trim() { sed 's/^\s*//g'; } +reverse() { sed -n '1!G;h;$p'; } +unique() { awk '!seen[$0]++'; } + +search_history() { + local result=$(full_history | trim | cut -d' ' -f 2- | reverse | unique | fzf); + + # Replace the buffer with the editor output. + print -Rz - "$(echo -n "$result" | trim)"; + + zle send-break # Force reload from the buffer stack +} + +zle -N search_history; +bindkey '^R' search_history; diff --git a/external/zsh/plugins/magic-enter.zsh b/external/zsh/plugins/magic-enter.zsh new file mode 100644 index 0000000..5d50316 --- /dev/null +++ b/external/zsh/plugins/magic-enter.zsh @@ -0,0 +1,29 @@ +# Bind quick stuff to enter! +# +# Pressing enter in a git directory runs `git status` +# in other directories `ls` +magic-enter () { + # If commands are not already set, use the defaults + [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ." + [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ." + + if [[ -z $BUFFER ]]; then + echo "" + if git rev-parse --is-inside-work-tree &>/dev/null; then + eval "$MAGIC_ENTER_GIT_COMMAND" + else + eval "$MAGIC_ENTER_OTHER_COMMAND" + fi + zle redisplay + else + zle accept-line + fi +} + +zle -N magic-enter + +bindkey "^M" magic-enter + +# Auto correct typos +#setopt CORRECT +#setopt CORRECT_ALL diff --git a/external/zsh/plugins/manpage.zsh b/external/zsh/plugins/manpage.zsh new file mode 100644 index 0000000..8c8c372 --- /dev/null +++ b/external/zsh/plugins/manpage.zsh @@ -0,0 +1,6 @@ + +open-man() { macho; } + +zle -N open-man +bindkey -M emacs '^_' open-man + diff --git a/external/zsh/plugins/sudo.zsh b/external/zsh/plugins/sudo.zsh new file mode 100644 index 0000000..fd43b93 --- /dev/null +++ b/external/zsh/plugins/sudo.zsh @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# sudo or sudoedit will be inserted before the command +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Dongweiming <ciici123@gmail.com> +# +# ------------------------------------------------------------------------------ + +MAGIC_ENTER_GIT_COMMAND='git status'; +MAGIC_ENTER_OTHER_COMMAND='ls'; + +sudo-command-line() { + [[ -z $BUFFER ]] && zle up-history + if [[ $BUFFER == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + elif [[ $BUFFER == $EDITOR\ * ]]; then + LBUFFER="${LBUFFER#$EDITOR }" + LBUFFER="sudoedit $LBUFFER" + elif [[ $BUFFER == sudoedit\ * ]]; then + LBUFFER="${LBUFFER#sudoedit }" + LBUFFER="$EDITOR $LBUFFER" + else + LBUFFER="sudo $LBUFFER" + fi +} + +zle -N sudo-command-line; +bindkey '^Z' sudo-command-line; + diff --git a/external/zsh/script-runners.zsh b/external/zsh/script-runners.zsh new file mode 100644 index 0000000..57cb8a7 --- /dev/null +++ b/external/zsh/script-runners.zsh @@ -0,0 +1,18 @@ + +BIN_DIR="$SCRIPTS_BINARY_DIR"; +SCRIPT="$SCRIPTS_DIR"; + +_create_runner() { + local name="$1"; + local filename="${2:-"$1.sh"}"; + local filepath="$SCRIPT/$filename"; + + alias $name="$filepath"; +} + +_create_runner "artemis"; +_create_runner "update-dotfiles" "dotfiles.sh"; +_create_runner "session-box" "qutebrowser/session-box.sh"; + +scr() { ~/scripts/$@; } + diff --git a/external/zsh/theme.zsh b/external/zsh/theme.zsh new file mode 100644 index 0000000..8666a7a --- /dev/null +++ b/external/zsh/theme.zsh @@ -0,0 +1,54 @@ +setopt prompt_subst + +# Theme +COL_ACCENT=13; + +COL_DIR=$COL_ACCENT; + +COL_STATUS_ERROR=red; +COL_STATUS_BG=cyan; + +COL_GIT_DIRTY=yellow; +COL_GIT_NORMAL=green; + + +segment() { echo -n "%K{$2}%F{$3} $1 %f%k"; } +git_changes() { git status --porcelain 2> /dev/null | wc -l; } + +# Prompt dir +p_dir() { + segment "%2~" $COL_DIR white; +} + +# Prompt terminal status +p_status() { + echo -n "%(?..$(segment 'x' black $COL_STATUS_ERROR))" + echo -n "%(1j.$(segment '(jobs: %j)' black $COL_STATUS_BG).)" +} + +p_git() { + local ref dirty mode repo_path color; + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + repo_path=$(git rev-parse --git-dir 2>/dev/null); + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"; + + changes=$(git_changes); + color=$([[ ! $changes = "0" ]] && echo $COL_GIT_DIRTY || echo $COL_GIT_NORMAL); + dirty=$([[ ! $changes = "0" ]] && echo " ($changes)"); + + segment "${ref/refs\/heads\//}$dirty" $color black; + fi +} + +prompt() { + RETVAL=$?; + p_status; + p_dir; + echo -n '$(p_git)'; + segment "$" black white; +} + +export PROMPT="$(prompt) "; +#export RPROMPT='wow' + diff --git a/external/zsh/zshrc b/external/zsh/zshrc new file mode 100644 index 0000000..114e68d --- /dev/null +++ b/external/zsh/zshrc @@ -0,0 +1,23 @@ +autoload -U colors && colors; +setopt auto_cd; +setopt inc_append_history; + +export SAVEHIST=10000 +# export HISTSIZE=50000 +# export HISTFILE=~/.config/zsh_history + +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt share_history # share command history data + +export ZSH_CUSTOM_CONF_FILES="$HOME/nixos/external/zsh"; + +for f in $ZSH_CUSTOM_CONF_FILES/*.zsh; do source $f; done; +source $ZSH_CUSTOM_CONF_FILES/aliases.zsh; + +# Plugins +# source ~/.config/zshplugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh; + diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..4f35056 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,52 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd = { + availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "wl" ]; + kernelModules = [ "wl" ]; + }; + boot.kernelModules = ["kvm-intel" "wl"]; + boot.kernelParams = [ "i8042.nopnp=1" "pci=nocrs" "quiet" "splash" ]; + boot.extraModulePackages = []; + boot.extraModprobeConfig = '' + options snd slots=snd-hda-intel + ''; + + hardware = { + enableAllFirmware = true; + cpu.intel.updateMicrocode = true; + firmware = with pkgs; [ wireless-regdb ]; + }; + + # Bootloader + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + + # File system + fileSystems = { + "/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + "/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + }; + }; + swapDevices = [ { device = "/dev/disk/by-label/swap"; } ]; + + + powerManagement = { + enable = true; + cpuFreqGovernor = lib.mkDefault "powersave"; + }; +} diff --git a/packages/dmenu/pkg.nix b/packages/dmenu/pkg.nix new file mode 100644 index 0000000..d91db13 --- /dev/null +++ b/packages/dmenu/pkg.nix @@ -0,0 +1,18 @@ +{ stdenv, libX11, libXinerama, libXft }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "local-dmenu-${version}"; + version = "6.2.0"; + + src = ./source; + + buildInputs = [ libX11 libXinerama libXft ]; + + + unpackPhase = ''cp -r $src/* .''; + + buildPhase = ''make''; + + installPhase = ''make PREFIX=$out DESTDIR="" install''; +} diff --git a/packages/dmenu/source b/packages/dmenu/source new file mode 160000 +Subproject 121d3bbb8985f274e36321967c8ef2ef52aa3a0 diff --git a/packages/dwm/autostart.sh b/packages/dwm/autostart.sh new file mode 100755 index 0000000..1d0caa8 --- /dev/null +++ b/packages/dwm/autostart.sh @@ -0,0 +1,105 @@ +source ~/nixos/external/zsh/paths.zsh; +source ~/nixos/external/zsh/config.zsh; + +##### Helpers {{{ +action="$1"; + +# Is logout command (Cleanup) +is_kill() { [[ "$action" == "kill" ]]; } + +# Focus on a tag/ws +focus_tag() { [[ ! -z "$1" ]] && dwmc view $(($1 - 1)); sleep 0.2; } + +# Only run when there are no windows on the screen +on_startup() { is_kill || [[ "$(wmctrl -l | wc -l)" = "0" ]] && $@ & } + +# Run only once. If an instance is already running, noop +once() { + local name=$1; shift; + if (is_kill); then + killall "$name"; + else + pgrep $name || $@ & + fi; +} + +# Kill previous instance and run again +run() { + local name=$1; shift; + [[ ! -z "$name" ]] && killall -9 $name && sleep 0.05; + is_kill || $@ & +} +# }}} + + +##### Autostart {{{ + echo "[Autostart]: Running daemons"; + + # Wallpaper + run "" ~/.fehbg; + + # Key daemon + run "shotkey" shotkey; + + # Dwm blocks status text + run "dwmblocks" dwmblocks; + + # Notification daemon + run "dunst" dunst -config ~/.config/dunst/dunstrc; + + # Compositor + run "picom" picom --experimental-backends --config ~/.config/compton.conf; + + # Cron jobs + run "crond" crond -n -f ~/.config/crontab/crontab; + + # Battery watcher + run "" ~/scripts/battery-watch.sh start; + + # Disk automount + once "udiskie" ~/.bin/with_zsh udiskie; + + # Clipboard history + once "clipmenud" clipmenud; + + # Network manager applet + once "nm-applet" nm-applet; + + # Syncthing + run "syncthing" syncthing -logflags=0 -no-browser 2>&1 >/dev/null; + + # Torrent daemon + #once "btpd" btpd -d "$HOME/.config/btpd"; + once "transmission" transmission-daemon --download-dir ~/Downloads/dl; + + # Music daemon + once "mpd" mpd ~/.config/mpd/mpd.conf --stdout --no-daemon; + + # Hide mouse pointer + once "unclutter" unclutter; +# }}} + + +##### Initialized applications {{{ +echo "[Autostart]: Checking applications"; +#on_startup sensible-browser; + +applications() { + #sleep 0.5; + + #focus_tag 9; + #on_startup :today; + #on_startup :tasks; + + #focus_tag 6; + #on_startup sensible-browser; + + #focus_tag 1; +} + +applications & + +# }}} + + +disown; diff --git a/packages/dwm/pkg.nix b/packages/dwm/pkg.nix new file mode 100644 index 0000000..533acb9 --- /dev/null +++ b/packages/dwm/pkg.nix @@ -0,0 +1,18 @@ +{ stdenv, libX11, libXinerama, libXft }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "local-dwm-${version}"; + version = "6.2.0"; + + src = ./source; + + buildInputs = [ libX11 libXinerama libXft ]; + + + unpackPhase = ''cp -r $src/* .''; + + buildPhase = ''make''; + + installPhase = ''make PREFIX=$out DESTDIR="" install''; +} diff --git a/packages/dwm/source b/packages/dwm/source new file mode 160000 +Subproject 3dd70306618f086e473bb9650bfa9b79b1fc844 diff --git a/packages/dwmblocks/pkg.nix b/packages/dwmblocks/pkg.nix new file mode 100644 index 0000000..79a23f8 --- /dev/null +++ b/packages/dwmblocks/pkg.nix @@ -0,0 +1,19 @@ +{ stdenv, libX11, pkgconfig }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "local-dwmblocks-${version}"; + version = "0.1.0"; + + src = ./source; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ libX11 ]; + + + unpackPhase = ''cp -r $src/* .''; + + buildPhase = ''make''; + + installPhase = ''make PREFIX=$out DESTDIR="" install''; +} diff --git a/packages/dwmblocks/source b/packages/dwmblocks/source new file mode 160000 +Subproject 1b7209ba919e0213521c88a8a85a2284ae5dac9 diff --git a/packages/sensible-apps/install.sh b/packages/sensible-apps/install.sh new file mode 100644 index 0000000..ec13109 --- /dev/null +++ b/packages/sensible-apps/install.sh @@ -0,0 +1,18 @@ +apps=" +sensible-terminal $TERMINAL +sensible-editor $EDITOR +sensible-browser $BROWSER +sensible-private-browser $PRIVATE_BROWSER +"; + +BIN=$out/bin; + +echo -e "$apps" | while read app bin; do + if [[ ! -z "$bin" ]]; then + echo "[SENSIBLE_APPS]:: Setting $app to $bin ($BIN/$bin)"; + mkdir -p $BIN; + echo -e "#!/usr/bin/env sh\nexec $bin \"\$@\"" > $BIN/$app; + chmod +x $BIN/$app; + fi; +done; + diff --git a/packages/sensible-apps/pkg.nix b/packages/sensible-apps/pkg.nix new file mode 100644 index 0000000..3a50480 --- /dev/null +++ b/packages/sensible-apps/pkg.nix @@ -0,0 +1,4 @@ + +# Rexported derivation +let sensibleApps = import ./sensible-apps.nix; in sensibleApps.package + diff --git a/packages/sensible-apps/sensible-apps.nix b/packages/sensible-apps/sensible-apps.nix new file mode 100644 index 0000000..db35bf7 --- /dev/null +++ b/packages/sensible-apps/sensible-apps.nix @@ -0,0 +1,33 @@ +let + apps = { + EDITOR = "nvim"; + TERMINAL = "st"; + BROWSER = "firefox"; + PRIVATE_BROWSER = "firefox"; + }; + package = { stdenv }: stdenv.mkDerivation rec { + name = "local-sensible-apps-${version}"; + version = "0.0.1"; + + src = [ ./install.sh ]; + + unpackPhase = '' + for srcFile in $src; do + local tgt=$(echo $srcFile | cut --delimiter=- --fields=2-) + cp $srcFile $tgt + done + ''; + + installPhase = '' + export TERMINAL="${apps.TERMINAL}"; + export EDITOR="${apps.EDITOR}"; + export BROWSER="${apps.BROWSER}"; + export PRIVATE_BROWSER="${apps.PRIVATE_BROWSER}"; + ls -la; + sh ./install.sh + ''; + }; +in { + package = package; + apps = apps; +} diff --git a/packages/shotkey/pkg.nix b/packages/shotkey/pkg.nix new file mode 100644 index 0000000..3a9eea7 --- /dev/null +++ b/packages/shotkey/pkg.nix @@ -0,0 +1,18 @@ +{ stdenv, libX11 }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "local-shotkey-${version}"; + version = "0.1.0"; + + src = ./source; + + buildInputs = [ libX11 ]; + + + unpackPhase = ''cp -r $src/* .''; + + buildPhase = ''make''; + + installPhase = ''make PREFIX=$out DESTDIR="" install''; +} diff --git a/packages/shotkey/source b/packages/shotkey/source new file mode 160000 +Subproject 299bd436635cb1a4d7877bac50b482d32fccffe diff --git a/packages/st/pkg.nix b/packages/st/pkg.nix new file mode 100644 index 0000000..3931819 --- /dev/null +++ b/packages/st/pkg.nix @@ -0,0 +1,19 @@ +{ stdenv, libX11, libXinerama, libXft, fontconfig, pkgconfig, ncurses }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "local-st-${version}"; + version = "0.8.4"; + + src = ./source; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ libX11 libXft fontconfig ncurses ]; + + + unpackPhase = ''cp -r $src/* .''; + + buildPhase = ''make''; + + installPhase = ''TERMINFO=$out/share/terminfo make PREFIX=$out DESTDIR="" install''; +} diff --git a/packages/st/source b/packages/st/source new file mode 160000 +Subproject e702bebb0837f9d08a73e8ce8392dd6b339f4b4 |
