From 98ecdbbcaa6e0e7d3440f1ec40de2130c57c54d2 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:27:50 +0100 Subject: [PATCH] Up --- README.md | 2 +- home/home.nix | 1 + home/misc/default.nix | 6 +- home/nvim/default.nix | 59 +++++ home/qutebrowser/default.nix | 2 + home/scripts/default.nix | 1 + home/scripts/nerdfetch.nix | 372 +++++++++++++++++++++++++++++ home/{misc => scripts}/scripts.nix | 0 home/shell/zsh.nix | 8 +- nixos/configuration.nix | 30 ++- 10 files changed, 470 insertions(+), 11 deletions(-) create mode 100644 home/scripts/default.nix create mode 100644 home/scripts/nerdfetch.nix rename home/{misc => scripts}/scripts.nix (100%) diff --git a/README.md b/README.md index fbb6b08..4fd44e3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is my dotfiles repo. It's a work in progress, and I'm still learning how to # TODOLIST -- [ ] custom colors on all config files +- [x] custom colors on all config files - [ ] auto update - [ ] auto remove old - [ ] script to edit, rebuild, push diff --git a/home/home.nix b/home/home.nix index 37a2629..0019444 100644 --- a/home/home.nix +++ b/home/home.nix @@ -48,5 +48,6 @@ ./shell ./misc ./nextcloud + ./scripts ]; } diff --git a/home/misc/default.nix b/home/misc/default.nix index 97038ab..05b8d79 100644 --- a/home/misc/default.nix +++ b/home/misc/default.nix @@ -1,5 +1 @@ -{ - - imports = [ ./scripts.nix ./sshconfig.nix ]; - -} +{ imports = [ ./sshconfig.nix ]; } diff --git a/home/nvim/default.nix b/home/nvim/default.nix index 690a308..f8a59d0 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -28,6 +28,65 @@ colorschemes.catppuccin.enable = true; colorschemes.catppuccin.transparentBackground = true; + plugins.alpha = { + enable = true; + layout = [ + { + type = "padding"; + val = 4; + } + { + type = "text"; + opts = { position = "center"; }; + val = [ + "  " + " ████ ██████ █████ ██ " + " ███████████ █████  " + " █████████ ███████████████████ ███ ███████████ " + " █████████ ███ █████████████ █████ ██████████████ " + " █████████ ██████████ █████████ █████ █████ ████ █████ " + " ███████████ ███ ███ █████████ █████ █████ ████ █████ " + " ██████ █████████████████████ ████ █████ █████ ████ ██████ " + " " + ]; + } + { + type = "padding"; + val = 4; + } + { + opts = { + position = "center"; + cursor = 3; + width = 50; + align_shortcut = "right"; + hl_shortcut = "Keyword"; + }; + type = "group"; + val = [ + { + type = "button"; + val = " New file"; + on_press.__raw = "function() vim.cmd[[ene]] end"; + opts.shortcut = "n"; + } + { + type = "button"; + val = " NixOs Config"; + on_press.__raw = "function() vim.cmd[[e ~/.config/nixos]] end"; + opts.shortcut = "n"; + } + { + type = "button"; + val = "󰩈 Quit Neovim"; + on_press.__raw = "function() vim.cmd[[qa]] end"; + opts.shortcut = "q"; + } + ]; + } + ]; + }; + keymaps = [ { key = "e"; diff --git a/home/qutebrowser/default.nix b/home/qutebrowser/default.nix index ca38e1f..a59fd11 100644 --- a/home/qutebrowser/default.nix +++ b/home/qutebrowser/default.nix @@ -91,6 +91,8 @@ }; }; + fonts = { default_family = "#${config.theme.font}"; }; + completion = { height = "30%"; open_categories = [ "history" ]; diff --git a/home/scripts/default.nix b/home/scripts/default.nix new file mode 100644 index 0000000..2dbb600 --- /dev/null +++ b/home/scripts/default.nix @@ -0,0 +1 @@ +{ imports = [ ./scripts.nix ./nerdfetch.nix ]; } diff --git a/home/scripts/nerdfetch.nix b/home/scripts/nerdfetch.nix new file mode 100644 index 0000000..e5de25b --- /dev/null +++ b/home/scripts/nerdfetch.nix @@ -0,0 +1,372 @@ +{ pkgs, config, ... }: + +let + homedir = config.home.homeDirectory; + + nerdfetch = pkgs.writeShellScriptBin "nerdfetch" '' + ostype="$(uname)" + + version=8.1.1 + font=nerd + distrotype=none + osi="" + ki="" + ri="󰍛" + pi="󰏔" + ui="󰅶" + ci="" + + case $1 in + "-p") + font=phosphor + osi="" + ki="" + ri="" + pi="" + ui="" + ci="" + ;; + "-c") + font=cozette + ki="♥" + ri="" + pi="" + ui="" + ci="" + ;; + "-e") + font=emoji + osi="🐧" + ki="💓" + ri="🐐" + pi="📦" + ui="☕" + ci="🎨" + ;; + "-v") + echo "NerdFetch $version" + exit + ;; + "-h") + echo "Flags: + -c: Cozette font + -p: Phosphor font + -e: Emoji font + -v: Version" + exit + ;; + esac + + if command -v getprop 1>/dev/null; then + distrotype=android + fi + kernel="$(echo $(uname -r) | cut -d'-' -f1-1)" + case $ostype in + *"Linux"*) + if [ $distrotype = android ]; then + host="$(hostname)" + USER="$(whoami)" + os="Android $(getprop ro.build.version.release)" + case $font in + phosphor) osi="" ;; + emoji) osi="🤖" ;; + *) osi="󰀲" ;; + esac + else + host="$(cat /proc/sys/kernel/hostname)" + . /etc/os-release + if [ -f /bedrock/etc/bedrock-release ]; then + os="$(brl version)" + else + os="''${PRETTY_NAME}" + if [ $font = nerd ]; then + case $(echo $ID | sed 's/ .*//') in + debian) osi="" ;; + arch) osi="󰣇" ;; + endeavouros) osi="" ;; + fedora) osi="" ;; + gentoo) osi="" ;; + rhel) osi="" ;; + slackware) osi="" ;; + void) osi="" ;; + alpine) osi="" ;; + nixos) osi="󱄅" ;; + artix) osi="" ;; + exherbo) osi="󰆚" ;; + mageia) osi="" ;; + manjaro) osi="" ;; + opensuse) osi="" ;; + solus) osi="" ;; + ubuntu) osi="" ;; + mint) osi="󰣭" ;; + trisquel) osi="" ;; + puppy) osi="" ;; + coreos) osi="" ;; + mx) osi="" ;; + vanilla) osi="" ;; + pop_os) osi="" ;; + raspbian) osi="" ;; + deepin) osi="" ;; + almalinux) osi="" ;; + garuda) osi="" ;; + centos) osi="" ;; + rocky) osi="" ;; + esac + elif [ $font = cozette ]; then + case $(echo $ID | sed 's/ .*//') in + debian) osi="" ;; + arch) osi="" ;; + fedora) osi="" ;; + gentoo) osi="" ;; + slackware) osi="" ;; + void) osi="" ;; + alpine) osi="" ;; + nixos) osi="" ;; + mageia) osi="" ;; + manjaro) osi="" ;; + opensuse) osi="" ;; + ubuntu) osi="" ;; + mint) osi="" ;; + coreos) osi="" ;; + centos) osi="" ;; + esac + fi + fi + fi + shell=$(basename "$SHELL") + ;; + *"Darwin"*) + host="$(hostname -f | sed -e 's/^[^.]*\.//')" + mac_product="$(/usr/libexec/PlistBuddy -c "Print:ProductName" /System/Library/CoreServices/SystemVersion.plist)" + mac_version="$(/usr/libexec/PlistBuddy -c "Print:ProductVersion" /System/Library/CoreServices/SystemVersion.plist)" + os="''${mac_product} ''${mac_version}" + case $font in + nerd) osi="" ;; + phosphor) osi="" ;; + cozette) osi="" ;; + emoji) osi="🍎" ;; + esac + ;; + *"FreeBSD"*) + host="$(hostname)" + distrotype=bsd + os="FreeBSD $(freebsd-version | sed 's/-.*//')" + case $font in + nerd) osi="" ;; + phosphor) osi="" ;; + cozette) osi="" ;; + emoji) osi="😈" ;; + esac + ;; + *"OpenBSD"*) + host="$(hostname)" + distrotype=bsd + os="OpenBSD $(uname -r)" + case $font in + nerd) osi="" ;; + phosphor) osi="" ;; + cozette) osi="⌘" ;; + emoji) osi="🐡" ;; + esac + ;; + *"NetBSD"*) + host="$(hostname)" + distrotype=netbsd + os="NetBSD $(uname -r)" + case $font in + nerd) osi="󰉀" ;; + phosphor) osi="" ;; + cozette) osi="" ;; + emoji) osi="🚩" ;; + esac + ;; + *) + os="Unix-like" + host="host" + ;; + esac + + ## PACKAGE MANAGER AND PACKAGES DETECTION + + MANAGER=$(which nix-env pkg flatpak yum zypper dnf rpm dpkg-query brew port pacman xbps-query emerge cave apk kiss pmm /usr/sbin/slackpkg bulge birb yay paru pacstall cpm pmm eopkg getprop 2>/dev/null) + manager=$(basename "$MANAGER") + if [ $distrotype = netbsd ]; then + manager="pkg_info-netbsd" + fi + case $manager in + cpm) packages="$(cpm C)" ;; + flatpak) packages="$(flatpak list --app | wc -l)" ;; + brew) packages="$(printf '%s\n' "$(brew --cellar)/"* | wc -l)" ;; + port) packages="$(port installed | wc -l)" ;; + dpkg-query) packages="$(dpkg-query -f '${ + "binary:Package" + }\n' -W | wc -l)" ;; + rpm) packages="$(rpm -qa --last | wc -l)" ;; + yum) packages="$(yum list installed | wc -l)" ;; + dnf) packages="$(dnf list installed | wc -l)" ;; + zypper) packages="$(zypper se | wc -l)" ;; + pacman) packages="$(pacman -Q | wc -l)" ;; + yay) packages="$(yay -Q | wc -l)" ;; + paru) packages="$(paru -Q | wc -l)" ;; + pacstall) packages="$(pacstall -L | wc -l)" ;; + kiss) packages="$(kiss list | wc -l)" ;; + emerge) packages="$(qlist -I | wc -l)" ;; + pkg) packages="$(pkg info | wc -l | tr -d ' ')" ;; + cave) packages="$(cave show installed-slots | wc -l)" ;; + xbps-query) packages="$(xbps-query -l | wc -l)" ;; + nix-env) packages="$(nix-store -q --requisites /run/current-system/sw | wc -l)" ;; + apk) packages="$(apk list --installed | wc -l)" ;; + pmm) packages="$(/bedrock/libexec/pmm pacman pmm -Q 2>/dev/null | wc -l)" ;; + eopkg) packages="$(eopkg li | wc -l)" ;; + /usr/sbin/slackpkg) packages="$(ls /var/log/packages | wc -l)" ;; + bulge) packages="$(bulge list | wc -l)" ;; + birb) packages="$(birb --list-installed | wc -l)" ;; + pkg_info) + packages="$(pkg_info -A | wc -l)" + manager="pkg" + ;; + pkg_info-netbsd) + packages="$(pkg_info -a | wc -l)" + manager="pkg" + ;; + *) + if [ $distrotype = android ]; then + packages="$(dpkg-query -f '${"binary:Package"}\n' -W | wc -l)" + manager="dpkg" + else + packages="$(ls /usr/bin | wc -l)" + manager="bin" + fi + ;; + esac + + packages="''${packages#"''${packages%%[![:space:]]*}"}" + manager=$(echo $manager | sed "s/-query//; s/\/usr\/.*\///") + + ## UPTIME DETECTION + + if [ $distrotype = android ]; then + uptime="$(echo $(uptime -p) | cut -c 4-)" + elif [ $distrotype = bsd ] || [ $distrotype = netbsd ]; then + uptime="$(uptime | sed -e 's/.* up //; s/, [0-9]* user.*//')" + else + case $ostype in + *"Linux"*) + IFS=. read -r s _ /dev/null 2>&1; then + mempercent="($(expr $(expr ''${mem_used} \* 100 / ''${mem_full}))%)" + fi + + ## DEFINE COLORS + + bold='' + black='' + red='' + green='' + yellow='' + blue='' + magenta='' + cyan='' + white='' + grey='' + reset='' + + ## USER VARIABLES -- YOU CAN CHANGE THESE + + lc="$reset$bold$magenta" # labels + nc="$reset$bold$magenta" # user + hn="$reset$bold$magenta" # hostname + ic="$reset$white" # info + c0="$reset$grey" # first color + c1="$reset$white" # second color + c2="$reset$yellow" # third color + + ## OUTPUT + + echo """ + ''${c0} ___ ''${nc}''${USER}''${grey}@''${reset}''${hn}''${host}''${reset} + ''${c0} (''${c1}.. ''${c0}\ ''${lc}''${osi} ''${ic}''${os}''${reset} + ''${c0} (''${c2}<> ''${c0}| ''${lc}''${ki} ''${ic}''${kernel}''${reset} + ''${c0} /''${c1}/ \\ ''${c0}\\ ''${lc}''${ri} ''${ic}''${RAM}''${memstat} ''${mempercent} + ''${c0} ( ''${c1}| | ''${c0}/| ''${lc}''${pi} ''${ic}''${packages} (''${manager})''${reset} + ''${c2} _''${c0}/\\ ''${c1}__)''${c0}/''${c2}_''${c0}) ''${lc}''${ui} ''${ic}''${uptime}''${reset} + ''${c2} \/''${c0}-____''${c2}\/''${reset} ''${lc}''${ci} ''${red}███''${green}███''${yellow}███''${blue}███''${magenta}███''${cyan}███''${reset} + """ + ''; + +in { home.packages = with pkgs; [ nerdfetch ]; } diff --git a/home/misc/scripts.nix b/home/scripts/scripts.nix similarity index 100% rename from home/misc/scripts.nix rename to home/scripts/scripts.nix diff --git a/home/shell/zsh.nix b/home/shell/zsh.nix index add1b5f..e32ebcf 100644 --- a/home/shell/zsh.nix +++ b/home/shell/zsh.nix @@ -7,6 +7,9 @@ enableAutosuggestions = true; enableCompletion = true; syntaxHighlighting.enable = true; + historySubstringSearch.enable = true; + + initExtraFirst = "nerdfetch"; history = { ignoreDups = true; @@ -14,9 +17,10 @@ size = 1000000; }; - profileExtra = lib.optionalString (config.home.sessionPath != [ ]) '' - export PATH="$PATH''${PATH:+:}${lib.concatStringsSep ":" config.home.sessionPath}" + export PATH="$PATH''${PATH:+:}${ + lib.concatStringsSep ":" config.home.sessionPath + }" ''; shellAliases = { diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 3b97166..bcd679e 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: { +{ pkgs, config, ... }: { imports = [ ./hardware-configuration.nix ]; # Bootloader. @@ -36,7 +36,6 @@ }; console.keyMap = "fr"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; programs.zsh.enable = true; users.defaultUserShell = pkgs.zsh; @@ -70,7 +69,10 @@ open = false; nvidiaSettings = true; }; - hardware.bluetooth.enable = true; + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; services.blueman.enable = true; # Set environment variables @@ -98,5 +100,27 @@ wireplumber.enable = true; }; + # Auto Update & Clean + system.autoUpgrade = { + enable = true; + dates = "04:00"; + flake = "${config.users.users.hadi.home}/.config/nixos"; + flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ]; + allowReboot = true; + }; + + nix = { + settings = { + auto-optimise-store = true; + experimental-features = [ "nix-command" "flakes" ]; + }; + gc = { + automatic = true; + persistent = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + system.stateVersion = "23.11"; }