diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dfe3987 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js,py}] +charset = utf-8 + +# 4 space indentation +[*.py] +indent_style = space +indent_size = 4 + +[*.nix] +indent_style = space +indent_size = 4 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +# Indentation override for all JS under lib directory +[lib/**.js] +indent_style = space +indent_size = 2 + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 + diff --git a/README.md b/README.md index 8cd0cfd..e935bc7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,147 @@ -# nixos-config-priv +# Nix-Config -WIP \ No newline at end of file +## Architecture + +## Inputs + +Dependencies + +- release-23.11 +- unstable +- hardware +- sops +- home manager +- + + +## Outputs + + + +### Systems Confs (./systems) + +Configurations (In the traditional way configuration.nix) that are specific to specific machines/hosts/systems. + +#### Systems/Common/core + +Configuration that is common to !all systems!. + +#### Systems/Common/users + +Configuration that is common to specific users. + +#### Systems/Common/optional + +Configuration that is optional, does not have to be on any user or system. + +### Home Manager Configs (./home) + +User-specific Configurations that should not give a crap where they live. + +### Custom ./modules + +Contains Nix expressions that offer customized functionalities inside and outside of my config. +Split into system and home + +#### Home + +Defines those modules that are specific to my user envs. + +#### System + +Defines system wide modules. + +### [Custom ./overlays](https://nixos.org/manual/nixpkgs/stable/#chap-overlays) + +overrides, patches, builds to nixpkgs. + +### pkgs + +Custom packages, nicely imports together with nixpkgs. TBH should go upstream, so this is for temporary pkgs fixes + +### shell.nix + +Run this on new systems to get temporary shell to setup the whole rest. + +### Formatter + +Useful without LSP setup + +## Inspirations + +A thank you to: + +[Emergent Mind's nix flake config and yewtube vids]() +[NvChad](https://github.com/NvChad/NvChad) +[Hlissner's dotfiles](https://github.com/hlissner/dotfiles) + +## 💾 References + +### features + +#### Cache + +https://docs.attic.rs/introduction.html + +#### Wayland + +[Awesome Wayland](https://github.com/rcalixte/awesome-wayland) + + +### Disko +https://github.com/nix-community/disko +https://nixos.wiki/wiki/Disko + +### Python +https://wiki.nixos.org/wiki/Python#Using_regular_Python_virtual_environment + +https://github.com/nvbn/thefuck +https://stevelosh.com/projects/ + + + +### 04/25 + +Added some things from + +- https://github.com/fidgetingbits/nixvim +- https://github.com/yrashk/nix-home/tree/master +- + +### Yubikey based fde + +https://nixos.wiki/wiki/Yubikey_based_Full_Disk_Encryption_(FDE)_on_NixOS + +### 👥 Nix ppl + +#### [Misterio77](https://github.com/Misterio77) + +[Dotfiles](https://github.com/Misterio77/dotfiles) + +[Nixcolors](https://github.com/Misterio77/nix-colors) + +#### [Vimjoyer](https://github.com/vimjoyer) + +#### [Sioodmy](https://github.com/sioodmy/dotfiles) + +#### [NotAShelf(https://github.com/NotAShelf/nyx/) + +#### [Hutzdog](https://git.sr.ht/~hutzdog/Dotfiles) + +#### [Gytis-ivaskevicius](https://github.com/gytis-ivaskevicius/nixfiles/) + +#### [Fufexan](https://github.com/fufexan/dotfiles) + +#### []() +### 👥 Non-Nix ppl + +#### [Bennetthardwick](https://github.com/bennetthardwick/dotfiles) + +#### + + +### Desktop features + +#### [Hyprland]() + +#####[HyprPicker](https://github.com/hyprwm/hyprpicker) diff --git a/etc/nixos/configuration.nix b/etc/nixos/configuration.nix new file mode 100644 index 0000000..d9d9fa4 --- /dev/null +++ b/etc/nixos/configuration.nix @@ -0,0 +1,47 @@ +{ config, pkgs, ... }: + +{ + # Import other configuration modules + # (hardware-configuration.nix is autogenerated upon installation) + # paths in nix expressions are always relative the file which defines them + imports = + [ + ./hardware-configuration.nix + ./my-dev-tools.nix + ./my-desktop-env.nix + ./etc.nix + ]; + + # Name your host machine + networking.hostName = "mymachine"; + + # Set your time zone. + time.timeZone = "Europe/Paris"; + + # Enter keyboard layout + services.xserver.layout = "us"; + services.xserver.xkbVariant = "altgr-intl"; + + # Define user accounts + users.extraUsers = + { + myuser = + { + extraGroups = [ "wheel" "networkmanager" ]; + isNormalUser = true; + }; + }; + + # Install some packages + environment.systemPackages = + with pkgs; + [ + ddate + testdisk + zsh + ]; + + # Enable the OpenSSH daemon + services.openssh.enable = true; + +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1918dea --- /dev/null +++ b/flake.nix @@ -0,0 +1,168 @@ +{ + description = "Nix Config"; + + # ===================================================================== # + # ============================== INPUTS =============================== # + # ===================================================================== # + inputs = { + # ============= Official NixOS and HM Package Sources ============= # + + nixpkgs.url = "github:NixOS/nixpkgs/release-23.11"; + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; # also see 'unstable-packages' overlay at 'overlays/default.nix" + + hardware.url = "github:nixos/nixos-hardware"; + + home-manager = { + url = "github:nix-community/home-manager/release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # =========================== Utilities =========================== # + + # -------------------------- Lanzaboote --------------------------- # + lanzabote = { + url = "github:nix-community/lanzaboote"; + inputs.nixpkgs.follows = "unstable"; + }; + + # ------------ Declarative partitioning and formatting ------------ # + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + + # ------------- Secrets mngmt. C ./docs/secretsmgmt.md ------------ # + sops-nix = { + url = "github:mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # ------------------------------ VIM ------------------------------ # + nixvim = { + url = "github:nix-community/nixvim/nixos-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # ------------------------ Windows manager ------------------------ # + hyprland = { + url = "github:hyprwm/hyprland"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + hyprland-plugins = { + url = "github:hyprwm/hyprland-plugins"; + inputs.hyprland.follows = "hyprland"; + }; + hyprland-themes = { + url = "github:hyprwm/hyprland-themes"; + inputs.hyprland.follows = "hyprland"; + }; + # ------------------------------ ZSH ------------------------------ # + nix-zsh-completions = { + url = "github:nix-community/nix-zsh-completions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # -------------------------- Nix-Colors --------------------------- # + # https://github.com/Misterio77/nix-colors + nix-colors = { + url = "github:misterio77/nix-colors"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # ====================== Personal Repositories ====================== # + + # Private secrets repo. See ./docs/secretsmgmt.md + # Authenticate via ssh and use shallow clone + nix-secrets = { + url = "git+ssh://git@gitlab.com/emergentmind/nix-secrets.git?ref=main&shallow=1"; + flake = false; + }; + }; + + # ===================================================================== # + # ============================== OUTPUTS ============================== # + # ===================================================================== # + outputs = { self, nixpkgs, home-manager, ... } @ inputs: + let + inherit (self) outputs; + forAllSystems = nixpkgs.lib.genAttrs [ + "x86_64-linux" + #"aarch64-darwin" + ]; + inherit (nixpkgs) lib; + configVars = import ./vars { inherit inputs lib; }; + configLib = import ./lib { inherit lib; }; + specialArgs = { inherit inputs outputs configVars configLib nixpkgs; }; + in + { + # ============================ CUSTOM ============================= # + # ---------------------------- Modules ---------------------------- # + # Custom modules to enable special functionality for nixos or home-manager oriented configs. + nixosModules = import ./modules/nixos; + homeManagerModules = import ./modules/home-manager; + + # ---------------------------- Overlays --------------------------- # + # Custom modifications/overrides to upstream packages. + overlays = import ./overlays { inherit inputs outputs; }; + + # ---------------------------- Packages --------------------------- # + # Custom packages to be shared or upstreamed. + packages = forAllSystems + (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in import ./pkgs { inherit pkgs; } + ); + + # ============================= Tools ============================= # + # --------------------------- Formatter --------------------------- # + # Nix formatter available through 'nix fmt' https://nix-community.github.io/nixpkgs-fmt + formatter = forAllSystems + (system: + nixpkgs.legacyPackages.${system}.nixpkgs-fmt + ); + + # -------------------------- INIT Shell -------------------------- # + # Shell configured with packages that are typically only needed when working on or with nix-config. + devShells = forAllSystems + (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in import ./shell.nix { inherit pkgs; } + ); + + # ======================= Configurations ========================== # + # + # Building configurations available through `just rebuild` or `nixos-rebuild --flake .#hostname` + nixosConfigurations = { + # Jedidiah - the + # jedidiah + # The one who listened too much + rehoboam = lib.nixosSystem { + modules = [ ./system/rehoboam ]; + specialArgs = { inherit inputs outputs;}; + }; + # The rebel who worships the golden calf + jeroboam = lib.nixosSystem { + modules = [ ./systems/jeroboam ]; + specialArgs = { inherit inputs outputs;}; + } + + }; + + homeConfigurations = { + "sunzi@rehoboam" = lib.homeManagerConfiguration { + modules = [ ./home/sunzi/rehoboam.nix ]; + pkgs = pkgsFor.x86_64-linux; + extraSpecialArgs = {inherit inputs nix-colors outputs;}; + }; + "sunzi@jeroboam" = lib.homeManagerConfiguration { + modules = [ ./home/sunzi/jeroboam.nix ]; + pkgs = pkgsFor.x86_64-linux; + extraSpecialArgs = {inherit inputs nix-colors outputs;}; + }; + "laozi@rehoboam" = lib.homeManagerConfiguration { + modules = [ ./home/laozi/rehoboam.nix ]; + pkgs = pkgsFor.x86_64-linux; + extraSpecialArgs = {inherit inputs nix-colors outputs;}; + }; + }; + } +} diff --git a/home/kongzi/common/core/default.nix b/home/kongzi/common/core/default.nix new file mode 100644 index 0000000..37f498b --- /dev/null +++ b/home/kongzi/common/core/default.nix @@ -0,0 +1,95 @@ +{ config, lib, pkgs, outputs, ... }: +{ + imports = [ + + # Packages with custom configs go here + + ./bash.nix # backup shell + ./bat.nix # cat with better syntax highlighting and extras like batgrep. + ./direnv.nix # shell environment manager. Hooks inot shell direnv to look for .envrc before prompts + ./fonts.nix # core fonts + ./git.nix # personal git config + ./foot.nix # terminal + ./nixvim # vim goodness + ./screen.nix # hopefully rarely needed but good to have if so + ./ssh.nix # personal ssh configs + ./zoxide.nix # cd replacement + ./zsh # primary shell: includes zsh, oh-my-zsh, and p10k theme + + ] ++ (builtins.attrValues outputs.homeManagerModules); + + services.ssh-agent.enable = true; + + home = { + username = lib.mkDefault "laozi"; + homeDirectory = lib.mkDefault "/home/${config.home.username}"; + stateVersion = lib.mkDefault "23.11"; + sessionPath = [ + "$HOME/.local/bin" + "$HOME/scripts/talon_scripts" + ]; + sessionVariables = { + FLAKE = "$HOME/src/nix-config"; + SHELL = "zsh"; + TERM = "foot"; + TERMINAL = "foot"; + EDITOR = "nvim"; + MANPAGER = "batman"; # see ./cli/bat.nix + }; + }; + + home.packages = builtins.attrValues { + inherit (pkgs) + + # Packages that don't have custom configs go here + + # TODO: spaces before comment are removed by nixpkgs-fmt + # See: https://github.com/nix-community/nixpkgs-fmt/issues/305 + borgbackup# backups + btop# resource monitor + coreutils# basic gnu utils + # curl + eza# ls replacement + fd# tree style ls + findutils# find + fzf# fuzzy search + jq# JSON pretty printer and manipulator + nix-tree# nix package tree viewer + ncdu# TUI disk usage + pciutils + pfetch# system info + pre-commit# git hooks + p7zip# compression & encryption + ripgrep# better grep + usbutils + tree# cli dir tree viewer + unzip# zip extraction + unrar# rar extraction + wget# downloader + zip; # zip compression + }; + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + warn-dirty = true; + }; + }; + + programs = { + home-manager.enable = true; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; +} diff --git a/home/laozi/common/core/default.nix b/home/laozi/common/core/default.nix new file mode 100644 index 0000000..0ca7d14 --- /dev/null +++ b/home/laozi/common/core/default.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, outputs, ... }: +let + +in +{ + imports = [ + # Packages with custom configs go here + ./brave.nix + ./gtk.nix + + ] ++ (builtins.attrValues outputs.homeManagerModules); + + home = { + username = lib.mkDefault "laozi"; + homeDirectory = lib.mkDefault "/home/${config.home.username}"; + stateVersion = lib.mkDefault "23.11"; + sessionPath = [ + "$HOME/.local/bin" + ]; + sessionVariables = { + SHELL = "bash"; + }; + }; + + home.packages = builtins.attrValues { + inherit (pkgs) + + # Packages that don't have custom configs go here + nix-tree; + }; + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = [ "nix-command" "flakes" ]; + warn-dirty = false; + }; + }; + + programs = { + home-manager.enable = true; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; +} diff --git a/home/laozi/jeroboam.nix b/home/laozi/jeroboam.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/laozi/rehoboam.nix b/home/laozi/rehoboam.nix new file mode 100644 index 0000000..85570af --- /dev/null +++ b/home/laozi/rehoboam.nix @@ -0,0 +1,15 @@ +{ inputs, lib, pkgs, config, outputs, ... }: +{ + imports = [ + #################### Required Configs #################### + common/core #required + + #################### Host-specific Optional Configs #################### + common/optional/sops.nix + common/optional/helper-scripts + + common/optional/desktops/gtk.nix + common/optional/browsers/brave.nix # for testing against 'media' user + + ]; +} diff --git a/home/zhuangzi/common/core/bash.nix b/home/zhuangzi/common/core/bash.nix new file mode 100644 index 0000000..7667dce --- /dev/null +++ b/home/zhuangzi/common/core/bash.nix @@ -0,0 +1,78 @@ +{ + programs.bash = { + enable = true; + enableCompletion = true; + shellAliases = { + ll = "ls -alF"; + la = "ls -A"; + l = "ls -CF"; + vi = "nvim"; + vim = "nvim"; + + # Add an "alert" alias for long running commands. Use like so: + # sleep 10; alert + alert = "notify-send --urgency=low -i \"$([ $? = 0 ] && echo terminal || echo error)\" \"$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')\""; + }; + + initExtra = '' + # ~/.bashrc: executed by bash(1) for non-login shells. + # If not running interactively, don't do anything + case $- in + *i*) ;; + *) return;; + esac + + # don't put duplicate lines or lines starting with space in the history. + # See bash(1) for more options + HISTCONTROL=ignoreboth + + # append to the history file, don't overwrite it + shopt -s histappend + + # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) + HISTSIZE=1000 + HISTFILESIZE=2000 + + # check the window size after each command and, if necessary, + # update the values of LINES and COLUMNS. + shopt -s checkwinsize + + # make less more friendly for non-text input files, see lesspipe(1) + [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + + # set a fancy prompt (non-color, unless we know we "want" color) + case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; + esac + + # enable color support of ls and also add handy aliases + if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' + fi + + # colored GCC warnings and errors + #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + + # Alias definitions. + # You may want to put all your additions into a separate file like + # ~/.bash_aliases, instead of adding them here directly. + # See /usr/share/doc/bash-doc/examples in the bash-doc package. + + if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases + fi + + export LC_ALL=en_US.UTF-8 + export LANG=en_US.UTF-8 + + complete -C /usr/bin/terraform terraform + ''; + }; +} diff --git a/home/zhuangzi/common/core/default.nix b/home/zhuangzi/common/core/default.nix new file mode 100644 index 0000000..37f498b --- /dev/null +++ b/home/zhuangzi/common/core/default.nix @@ -0,0 +1,95 @@ +{ config, lib, pkgs, outputs, ... }: +{ + imports = [ + + # Packages with custom configs go here + + ./bash.nix # backup shell + ./bat.nix # cat with better syntax highlighting and extras like batgrep. + ./direnv.nix # shell environment manager. Hooks inot shell direnv to look for .envrc before prompts + ./fonts.nix # core fonts + ./git.nix # personal git config + ./foot.nix # terminal + ./nixvim # vim goodness + ./screen.nix # hopefully rarely needed but good to have if so + ./ssh.nix # personal ssh configs + ./zoxide.nix # cd replacement + ./zsh # primary shell: includes zsh, oh-my-zsh, and p10k theme + + ] ++ (builtins.attrValues outputs.homeManagerModules); + + services.ssh-agent.enable = true; + + home = { + username = lib.mkDefault "laozi"; + homeDirectory = lib.mkDefault "/home/${config.home.username}"; + stateVersion = lib.mkDefault "23.11"; + sessionPath = [ + "$HOME/.local/bin" + "$HOME/scripts/talon_scripts" + ]; + sessionVariables = { + FLAKE = "$HOME/src/nix-config"; + SHELL = "zsh"; + TERM = "foot"; + TERMINAL = "foot"; + EDITOR = "nvim"; + MANPAGER = "batman"; # see ./cli/bat.nix + }; + }; + + home.packages = builtins.attrValues { + inherit (pkgs) + + # Packages that don't have custom configs go here + + # TODO: spaces before comment are removed by nixpkgs-fmt + # See: https://github.com/nix-community/nixpkgs-fmt/issues/305 + borgbackup# backups + btop# resource monitor + coreutils# basic gnu utils + # curl + eza# ls replacement + fd# tree style ls + findutils# find + fzf# fuzzy search + jq# JSON pretty printer and manipulator + nix-tree# nix package tree viewer + ncdu# TUI disk usage + pciutils + pfetch# system info + pre-commit# git hooks + p7zip# compression & encryption + ripgrep# better grep + usbutils + tree# cli dir tree viewer + unzip# zip extraction + unrar# rar extraction + wget# downloader + zip; # zip compression + }; + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + warn-dirty = true; + }; + }; + + programs = { + home-manager.enable = true; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; +} diff --git a/home/zhuangzi/common/core/direnv.nix b/home/zhuangzi/common/core/direnv.nix new file mode 100644 index 0000000..c7d2d36 --- /dev/null +++ b/home/zhuangzi/common/core/direnv.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + #set to default values + programs.direnv = { + package = pkgs.direnv; + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + silent = false; + loadInNixShell = true; + direnvrcExtra = ""; + nix-direnv = { + enable = true; # better than native direnv nix functionality - https://github.com/nix-community/nix-direnv + package = pkgs.nix-direnv; + }; + } diff --git a/home/zhuangzi/common/core/fonts.nix b/home/zhuangzi/common/core/fonts.nix new file mode 100644 index 0000000..32f98d0 --- /dev/null +++ b/home/zhuangzi/common/core/fonts.nix @@ -0,0 +1,11 @@ + #----=[ Fonts ]=----# +{ pkgs, ... }: +{ + fonts.fontconfig.enable = true; # required to autoload fonts from packages + home.packages = [ + pkgs.noto-fonts + # pkgs.nerdfonts # => loads the complete collection. + (nerdfonts.override { fonts = [ "FiraCode" "GeistMono" "DroidSansMono" "FontAwesome" "MaterialDesignIcons"]; }) + pkgs.meslo-lgs-nf + ]; +} diff --git a/home/zhuangzi/common/core/git.nix b/home/zhuangzi/common/core/git.nix new file mode 100644 index 0000000..da08a8b --- /dev/null +++ b/home/zhuangzi/common/core/git.nix @@ -0,0 +1,29 @@ +{ pkgs, lib, config, ... }: +{ + programs.git = { + enable = true; + package = pkgs.gitAndTools.gitFull; + userName = "mattmor"; + userEmail = "matt.b.morin@protonmail.com"; + aliases = { }; + extraConfig = { + init.defaultBranch = "master"; + url = { + "ssh://git@github.com" = { + insteadOf = "https://github.com"; + }; + "ssh://git@gitlab.com" = { + insteadOf = "https://gitlab.com"; + }; + }; + + user.signing.key = ""; + #TODO sops - Re-enable once sops setup complete + commit.gpgSign = false; + gpg.program = "${config.programs.gpg.package}/bin/gpg2"; + }; + # enable git Large File Storage: https://git-lfs.com/ + # lfs.enable = true; + ignores = [ ".direnv" "result" ]; + }; +} diff --git a/home/zhuangzi/common/core/nixvim/default.nix b/home/zhuangzi/common/core/nixvim/default.nix new file mode 100644 index 0000000..67cba41 --- /dev/null +++ b/home/zhuangzi/common/core/nixvim/default.nix @@ -0,0 +1,518 @@ +{ inputs, pkgs, ... }: { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ]; + + programs.nixvim = { + enable = true; + enableMan = true; # install man pages for nixvim options + + clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers + + # TODO: nixvim: gruvbox-material + colorschemes = { + gruvbox = { + enable = true; + contrastDark = "medium"; + transparentBg = "true"; + }; + }; + + options = { + # # Lua reference: + # vim.o behaves like :set + # vim.go behaves like :setglobal + # vim.bo for buffer-scoped options + # vim.wo for window-scoped options (can be double indexed) + + # + # ========= General Appearance ========= + # + hidden = true; # Makes vim act like all other editors, buffers can exist in the background without being in a window. http://items.sjbach.com/319/configuring-vim-right + number = true; # show line numbers + relativenumber = true; # show relative linenumbers + laststatus = 0; # Display status line always + history = 1000; # Store lots of :cmdline history + showcmd = true; # Show incomplete cmds down the bottom + showmode = true; # Show current mode down the bottom + autoread = true; # Reload files changed outside vim + lazyredraw = true; # Redraw only when needed + showmatch = true; # highlight matching braces + ruler = true; # show current line and column + visualbell = true; # No sounds + + listchars = "trail:·"; # Display tabs and trailing spaces visually + + wrap = false; # Don't wrap lines + linebreak = true; # Wrap lines at convenient points + + # ========= Font ========= + guifont = "NotoSansMono:h9"; # fontname:fontsize + + # ========= Cursor ========= + guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,n-v-i:blinkon0"; + + # ========= Redirect Temp Files ========= + # backup + backupdir = "$HOME/.vim/backup//,/tmp//,."; + writebackup = false; + # swap + directory = "$HOME/.vim/swap//,/tmp//,."; + + # ================ Indentation ====================== + autoindent = true; + cindent = true; # automatically indent braces + smartindent = true; + smarttab = true; + shiftwidth = 4; + softtabstop = 4; + tabstop = 4; + expandtab = true; + + # ================ Folds ============================ + foldmethod = "indent"; # fold based on indent + foldnestmax = 3; # deepest fold is 3 levels + foldenable = false; # don't fold by default + + # ================ Completion ======================= + wildmode = "list:longest"; + wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches + + # stuff to ignore when tab completing + wildignore = "*.o,*.obj,*~,vim/backups,sass-cache,DS_Store,vendor/rails/**,vendor/cache/**,*.gem,log/**,tmp/**,*.png,*.jpg,*.gif"; + + # ================ Scrolling ======================== + scrolloff = 4; # Start scrolling when we're 4 lines away from margins + sidescrolloff = 15; + sidescroll = 1; + + # ================ Searching ======================== + incsearch = true; + hlsearch = true; + ignorecase = true; + smartcase = true; + + # ================ Movement ======================== + backspace = "indent,eol,start"; # allow backspace in insert mode + }; + + # + # ========= UI Plugins ========= + # + + # Display colors for when # FFFFFF codes are detected in buffer text. + plugins.nvim-colorizer = { + enable = true; + fileTypes = [ "*" ]; + }; + + # TODO: nixvim: additional commands for alpha + # Greeter + plugins.alpha = { + enable = true; + iconsEnabled = true; # installs nvim-web-devicons. + layout = [ + { + type = "padding"; + val = 2; + } + { + type = "text"; + val = [ + " ______" + " / /\\" + " / /##\\" + " / /####\\" + " / /######\\" + " / /########\\" + " / /##########\\" + " / /#####/\\#####\\" + " / /#####/++\\#####\\" + " / /#####/++++\\#####\\" + " / /#####/\\+++++\\#####\\" + " / /#####/ \\+++++\\#####\\" + " / /#####/ \\+++++\\#####\\" + " / /#####/ \\+++++\\#####\\" + " / /#####/ \\+++++\\#####\\" + " / /#####/__________\\+++++\\#####\\" + " / \\+++++\\#####\\" + "/__________________________\\+++++\\####/" + "\\+++++++++++++++++++++++++++++++++\\##/" + " \\+++++++++++++++++++++++++++++++++\\/" + " ``````````````````````````````````" + "" + ]; + } + { + type = "padding"; + val = 2; + } + { + type = "group"; + val = [ + { + command = "ene "; + desc = " New file"; + shortcut = "cn"; + } + { + command = ":qa"; + desc = " Quit Neovim"; + shortcut = ":q"; + } + ]; + } + { + type = "padding"; + val = 2; + } + { + opts = { + hl = "Keyword"; + position = "center"; + }; + type = "text"; + val = "The way out is through."; + } + ]; + }; + # TODO: nixvim switch to lightline and lightline-bufferline + plugins.airline = { + enable = true; + powerline = true; + extensions = { + # TODO: nixvim: Figure out tabline extension stuff in nixvim + # TODO: nixvim: Possibly use bufferline or lightline-bufferline instead + # """" Tabline settings + # + # " show buffer numbers in the tab line for easier deleting + # " use :echo airline#extensions#tabline#get() to see what is actually set + # let g:airline#extensions#tabline#show_tab_nr = 1 + # let g:airline#extensions#tabline#tabs_label = 't' + # let g:airline#extensions#tabline#buffers_label = 'b' + # let g:airline#extensions#tabline#buffer_nr_show = 1 + # + # " Disable showing buffer numbers for splits when using tabs. This gets quite + # " annoying if there's quite a few splits open. + # let g:airline#extensions#tabline#show_splits = 0 + # + # " Title adjustments + # "airline_symbols Show tab numbers in the tab title + # let g:airline#extensions#tabline#tab_nr_type = 1 + # + # " https://github.com/vim-airline/vim-airline/issues/476 + # + # " show the buffer index + # "let g:airline#extensions#tabline#buffer_idx_mode = 1 + # " + # " https://github.com/vim-airline/vim-airline/wiki/Configuration-Examples-and-Snippets#a-different-example-add-the-window-number-in-front-of-the-mode + # function! WindowNumber(...) + # let builder = a:1 + # let context = a:2 + # call builder.add_section('airline_b', '%{tabpagewinnr(tabpagenr())}') + # return 0 + # endfunction + }; + }; + plugins.fidget = { + enable = true; + text.spinner = "triangle"; + }; + + # ========= Undo history ======== + # TODO: nixvim: set up alos, map to u + # plugins.undotree = {}; + + + # + # ========= File Search ========= + # + plugins.telescope = { + # https://github.com/nvim-telescope/telescope.nvim + enable = true; + extensions.fzy-native.enable = true; + }; + + # ========= File Nav =========== + # TODO: nixvim set this one up + # plugins.harpoon = {}; + + # + # ========== Dev Tools ========= + # + plugins.fugitive.enable = true; # vim-fugitive + # plugins.surround.enable = true; # vim-surround + + # Load Plugins that aren't provided as modules by nixvim + extraPlugins = builtins.attrValues { + inherit (pkgs.vimPlugins) + # linting and fixing (config in extraConfigVim) + # https://github.com/dense-analysis/ale + # TODO: nixvim: revamp setup to lua + # there is also a lightline-ale plugin/extension for lightline when you get around to it + # by default ALE completion is disabled. need to determine if it's worth enabling and ditching youcompleteme ... it likely is for simplicity! + ale + + vim-illuminate# Highlight similar words as are under the cursor + vim-numbertoggle# Use relative number on focused buffer only + range-highlight-nvim# Highlight range as specified in commandline e.g. :10,15 + vimade# Dim unfocused buffers + vim-twiggy# Fugitive plugin to add branch control + vimwiki# Vim Wiki + YouCompleteMe# Code completion engine + + # TODO: nixvim: make sure this is working and not conflicting with YCM + # supertab # Use for insert completion needs - https://github.com/ervandew/supertab/ + + # Keep vim-devicons as last entry + vim-devicons; + }; + + # ========= Mapleader ========= + globals.mapleader = ";"; + + # + # ========= Key binds ========= + # + # MODES Key: + # "n" Normal mode + # "i" Insert mode + # "v" Visual and Select mode + # "s" Select mode + # "t" Terminal mode + # "" Normal, visual, select and operator-pending mode + # "x" Visual mode only, without select + # "o" Operator-pending mode + # "!" Insert and command-line mode + # "l" Insert, command-line and lang-arg mode + # "c" Command-line mode + keymaps = [ + # TODO: nixvim: Test sudo save + # { + # # sudo save + # mode= ["c"]; + # key = "w!!"; + # action = "w !sudo tee > /dev/null %"; + # } + { + # edit vimrc + mode = [ "" ]; + key = "ve"; + action = "e ~/.config/.vimrc"; + options = { noremap = true; }; + } + { + # reload vimrc + mode = [ "n" ]; + key = "vr"; + action = "so $MYVIMRC"; + options = { noremap = true; }; + } + { + # clear search highlighting + mode = [ "n" ]; + key = ""; + action = "nohlsearch"; + options = { noremap = true; }; + } + + # ======== Movement ======== + { + # move down through wrapped lines + mode = [ "n" ]; + key = "j"; + action = "gj"; + options = { noremap = true; }; + } + { + # move up through wrapped lines + mode = [ "n" ]; + key = "k"; + action = "gk"; + options = { noremap = true; }; + } + { + # rebind 1/2 page down + mode = [ "n" ]; + key = ""; + action = ""; + options = { noremap = true; }; + } + { + # rebind 1/2 page up + mode = [ "n" ]; + key = ""; + action = ""; + options = { noremap = true; }; + } + { + # move to beginning/end of line + mode = [ "n" ]; + key = "E"; + action = "$"; + options = { noremap = true; }; + } + # { + # # disable default move to beginning/end of line + # mode = ["n"]; + # key = "$"; + # action = ""; + # } + + # =========== Fugitive Plugin ========= + { + # quick git status + mode = [ "n" ]; + key = "gs"; + action = "G"; + options = { noremap = true; }; + } + { + # quick merge command: take from right page (tab 3) upstream + mode = [ "n" ]; + key = "gj"; + action = "diffget //3"; + options = { noremap = true; }; + } + { + # quick merge command: take from left page (tab 2) head + mode = [ "n" ]; + key = "gf"; + action = "diffget //2"; + options = { noremap = true; }; + } + + # ========== Telescope Plugin ========= + { + # find files + mode = [ "n" ]; + key = "ff"; + action = "Telescope find_files"; + options = { noremap = true; }; + } + { + # live grep + mode = [ "n" ]; + key = "fg"; + action = "Telescope live_grep"; + options = { noremap = true; }; + } + { + # buffers + mode = [ "n" ]; + key = "fb"; + action = "Telescope buffers"; + options = { noremap = true; }; + } + { + # help tags + mode = [ "n" ]; + key = "fh"; + action = "Telescope help_tags"; + options = { noremap = true; }; + } + + # ========= Twiggy ============= + { + # toggle display twiggy + mode = [ "n" ]; + key = "tw"; + action = ":Twiggy"; + options = { noremap = true; }; + } + ]; + extraConfigVim = '' + " ================ Persistent Undo ================== + " Keep undo history across sessions, by storing in file. + " Only works all the time. + if has('persistent_undo') + silent !mkdir ~/.vim/backups > /dev/null 2>&1 + set undodir=~/.vim/backups + set undofile + endif + + " ================ Vim Wiki config ================= + " See :h vimwiki_list for info on registering wiki paths + let wiki_0 = {} + let wiki_0.path = '~/dotfiles.wiki/' + let wiki_0.index = 'home' + let wiki_0.syntax = 'markdown' + let wiki_0.ext = '.md' + + " fill spaces in page names with _ in pathing + let wiki_0.links_space_char = '_' + + " TODO: nixvim: CONFIRM THESE PATHS FOR NIXOS + let wiki_1 = {} + let wiki_1.path = '~/doc/foundry/thefoundry.wiki/' + let wiki_1.index = 'home' + let wiki_1.syntax = 'markdown' + let wiki_1.ext = '.md' + " fill spaces in page names with _ in pathing + let wiki_1.links_space_char = '_' + + let g:vimwiki_list = [wiki_0, wiki_1] + " let g:vimwiki_list = [wiki_0, wiki_1, wiki_2] + + " ================ Ale ======================== + " linter and fixer packages have to be installed via AUR or pamac + let g:ale_linters = { + \ 'c': ['clang-tidy'], + \ 'python': ['flake8'], + \ 'vim': ['vint'], + \ 'markdown': ['markdownlint'], + \ } + + let g:ale_fixers = { + \ 'c': ['clang-format'], + \ 'javascript': ['prettier', 'eslint'], + \ 'json': ['fixjson', 'prettier'], + \ 'python': ['black', 'isort'], + \ } + + " Set global fixers for all file types except Markdown + " Why? because double spaces at the end of a line in markdown indicate a + " linebreak without creating a new paragraph + function! SetGlobalFixers() + let g:ale_fixers['*'] = ['trim_whitespace', 'remove_trailing_lines'] + endfunction + + augroup GlobalFixers + autocmd! + autocmd VimEnter * call SetGlobalFixers() + augroup END + + " Set buffer-local fixers for Markdown files + augroup MarkdownFixers + autocmd! + autocmd FileType markdown let b:ale_fixers = ['prettier'] + augroup END + + let g:ale_fix_on_save = 1 + ''; + + # extraConfigLua = '' + # -- ========= Colorscheme Overrides ========== + # -- Override cursor color and blink for nav and visual mode + # vim.cmd("highlight Cursor guifg=black guibg=orange"); + # + # -- Override cursor color for insert mode + # vim.cmd("highlight iCursor guifg=black guibg=orange"); + # ''; + }; +} + +# # Syntax support +# vim-polyglot # a collection of language packs for vim +# +# # The following are commented out because they are already included in vim-polyglot +# # but in case poly-glot fails I want to be able to quickly enable what I need. +# haskell-vim +# plantuml-syntax +# pgsql-vim +# python-syntax +# rust-vim +# vim-markdown +# vim-nix +# vim-terraform +# vim-toml diff --git a/home/zhuangzi/common/core/ssh.nix b/home/zhuangzi/common/core/ssh.nix new file mode 100644 index 0000000..7c1f09c --- /dev/null +++ b/home/zhuangzi/common/core/ssh.nix @@ -0,0 +1,33 @@ +{ outputs, lib, ... }: +{ + programs.ssh = { + enable = true; + + extraConfig = '' + #req'd for enabling yubikey-agent + AddKeysToAgent yes + ''; + + matchBlocks = { + "yubikey-hosts" = { + host = "gitlab.com github.com"; + forwardAgent = true; + identitiesOnly = true; + identityFile = [ + "~/.ssh/id_yubikey" # This is an auto symlink to whatever yubikey is plugged in. See hosts/common/optional/yubikey + "~/.ssh/id_mila" + "~/.ssh/id_hello" # fallback to id_hello if yubis aren't present + ]; + }; + }; + # FIXME: This should probably be for git systems only? + #controlMaster = "auto"; + #controlPath = "~/.ssh/sockets/S.%r@%h:%p"; + #controlPersist = "60m"; + + #extraConfig = '' + #Include config.d/* + #''; + }; + # home.file.".ssh/sockets/.keep".text = "# Managed by Home Manager"; +} diff --git a/home/zhuangzi/common/core/zoxide.nix b/home/zhuangzi/common/core/zoxide.nix new file mode 100644 index 0000000..2590afc --- /dev/null +++ b/home/zhuangzi/common/core/zoxide.nix @@ -0,0 +1,10 @@ +{ + programs.zoxide = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + options = [ + "--cmd cd" #replace cd with z and zi (via cdi) + ]; + }; +} diff --git a/home/zhuangzi/common/core/zsh/default.nix b/home/zhuangzi/common/core/zsh/default.nix new file mode 100644 index 0000000..44d7291 --- /dev/null +++ b/home/zhuangzi/common/core/zsh/default.nix @@ -0,0 +1,130 @@ +{ pkgs, ... }: { + programs.zsh = { + enable = true; + + # relative to ~ + dotDir = ".config/zsh"; + enableCompletion = true; + syntaxHighlighting.enable = true; + autocd = true; + enableAutosuggestions = true; + history.size = 10000; + history.share = true; + + plugins = [ + { + name = "powerlevel10k-config"; + src = ./p10k; + file = "p10k.zsh"; + } + { + name = "zsh-powerlevel10k"; + src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/"; + file = "powerlevel10k.zsh-theme"; + } + { + name = "zsh-term-title"; + src = "${pkgs.zsh-term-title}/share/zsh/zsh-term-title/"; + } + { + name = "cd-gitroot"; + src = "${pkgs.cd-gitroot}/share/zsh/cd-gitroot"; + } + { + name = "zhooks"; + src = "${pkgs.zhooks}/share/zsh/zhooks"; + } + ]; + + initExtraFirst = '' + # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. + # Initialization code that may require console input (password prompts, [y/n] + # confirmations, etc.) must go above this block; everything else may go below. + if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then + source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" + fi + ''; + + initExtra = '' + # autoSuggestions config + + unsetopt correct # autocorrect commands + + setopt hist_ignore_all_dups # remove older duplicate entries from history + setopt hist_reduce_blanks # remove superfluous blanks from history items + setopt inc_append_history # save history entries as soon as they are entered + + # auto complete options + setopt auto_list # automatically list choices on ambiguous completion + setopt auto_menu # automatically use menu completion + zstyle ':completion:*' menu select # select completions with arrow keys + zstyle ':completion:*' group-name "" # group results by category + zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion + + # bindkey '^I' forward-word # tab + # bindkey '^[[Z' backward-word # shift+tab + # bindkey '^ ' autosuggest-accept # ctrl+space + ''; + + oh-my-zsh = { + enable = true; + # Standard OMZ plugins pre-installed to $ZSH/plugins/ + # Custom OMZ plugins are added to $ZSH_CUSTOM/plugins/ + # Enabling too many plugins will slowdown shell startup + plugins = [ + "git" + "sudo" # press Esc twice to get the previous command prefixed with sudo https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/sudo + ]; + extraConfig = '' + # Display red dots whilst waiting for completion. + COMPLETION_WAITING_DOTS="true" + ''; + }; + + shellAliases = { + # Overrides those provided by OMZ libs, plugins, and themes. + # For a full list of active aliases, run `alias`. + + #-------------Bat related------------ + cat = "bat"; + diff = "batdiff"; + rg = "batgrep"; + man = "batman"; + + #------------Navigation------------ + doc = "cd $HOME/documents"; + scripts = "cd $HOME/scripts"; + ts = "cd $HOME/.talon/user/fidget"; + src = "cd $HOME/src"; + edu = "cd $HOME/src/edu"; + dfs = "cd $HOME/src/dotfiles"; + dfsw = "cd $HOME/src/dotfiles.wiki"; + nfs = "cd $HOME/src/nix-config"; + uc = "cd $HOME/src/unmovedcentre"; + l = "eza -lah"; + la = "eza -lah"; + ll = "eza -lh"; + ls = "eza"; + lsa = "eza -lah"; + + #-------------Neovim--------------- + e = "nvim"; + vi = "nvim"; + vim = "nvim"; + + #-----------Nix related---------------- + ne = "nix-instantiate --eval"; + nb = "nix-build"; + ns = "nix-shell"; + + #-----------Remotes---------------- + cakes = "ssh -l freshcakes freshcakes.memeoid.cx"; + gooey = "ssh -l pi 10.13.37.69"; + gusto = "ssh -l ta 10.13.37.5"; + grief = "ssh -l ta 10.13.37.7"; + + #-------------Git Goodness------------- + # just reference `$ alias` and use the defautls, they're good. + }; + }; +} diff --git a/home/zhuangzi/common/core/zsh/p10k/p10k.zsh b/home/zhuangzi/common/core/zsh/p10k/p10k.zsh new file mode 100644 index 0000000..c94f8ba --- /dev/null +++ b/home/zhuangzi/common/core/zsh/p10k/p10k.zsh @@ -0,0 +1,1663 @@ +# Generated by Powerlevel10k configuration wizard on 2023-12-15 at 17:55 MST. +# Based on romkatv/powerlevel10k/config/p10k-lean.zsh. +# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 2 lines, +# dotted, full frame, dark-ornaments, compact, many icons, concise, transient_prompt, +# instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' + + # Zsh >= 5.1 is required. + [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline # \n + prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + asdf # asdf version manager (https://github.com/asdf-vm/asdf) + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + pyenv # python environment (https://github.com/pyenv/pyenv) + goenv # go environment (https://github.com/syndbg/goenv) + nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) + # java_version # java version (https://www.java.com/) + # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) + fvm # flutter version management (https://github.com/leoafarias/fvm) + luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) + jenv # java version from jenv (https://github.com/jenv/jenv) + plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) + scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) + haskell_stack # haskell version from stack (https://haskellstack.org/) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + # terraform_version # terraform version (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + gcloud # google cloud cli account and project (https://cloud.google.com/) + google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + toolbox # toolbox name (https://github.com/containers/toolbox) + context # user@hostname + # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) + nnn # nnn shell (https://github.com/jarun/nnn) + lf # lf shell (https://github.com/gokcehan/lf) + xplr # xplr shell (https://github.com/sayanarijit/xplr) + vim_shell # vim shell indicator (:sh) + midnight_commander # midnight commander shell (https://midnight-commander.org/) + nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + # vpn_ip # virtual private network indicator + # load # CPU load + # disk_usage # disk usage + # ram # free RAM + # swap # used swap + # todo # todo items (https://github.com/todotxt/todo.txt-cli) + # timewarrior # timewarrior tracking status (https://timewarrior.net/) + # taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # cpu_arch # CPU architecture + # time # current time + # =========================[ Line #2 ]========================= + newline + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=meslo-lgs-nf + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=none + + # Basic style options that define the overall look of your prompt. You probably don't want to + # change them. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%240F╭─' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%240F├─' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%240F╰─' + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%240F─╮' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%240F─┤' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%240F─╯' + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll + # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and + # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. + typeset -g POWERLEVEL9K_SHOW_RULER=false + typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' + typeset -g POWERLEVEL9K_RULER_FOREGROUND=240 + + # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' + # to make it easier to see the alignment between left and right prompt and to separate prompt + # from command output. It serves the same purpose as ruler (see above) without increasing + # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false + # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact + # prompt. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·' + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=240 + # Add a space between the end of left prompt and the filler. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + # Add a space between the filler and the start of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + + ##################################[ dir: current directory ]################################## + # Default current directory color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + # + # Optionally, "first" and "last" can be followed by ":" where is an integer. + # This moves the truncation point to the right (positive offset) or to the left (negative offset) + # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" + # respectively. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON + # and POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 + + # The default icon shown next to non-writable and non-existent directories when + # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories + # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one + # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or + # WORK_NON_EXISTENT. + # + # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NON_EXISTENT. + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 ' + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + fi + + local res + + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" + fi + + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi + + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" + fi + + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg repository. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for repositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes at least this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent directory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Julia version from asdf. + typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### + # lf shell color. + typeset -g POWERLEVEL9K_LF_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## + # xplr shell color. + typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########################[ vim_shell: vim shell indicator (:sh) ]########################### + # Vim shell indicator color. + typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 + # Custom icon. + # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### + # Midnight Commander shell color. + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## + # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 + + # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. + # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## + # chezmoi shell color. + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 + # Custom icon. + # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ cpu_arch: CPU architecture ]################################ + # CPU architecture color. + typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 + + # Hide the segment when on a specific CPU architecture. + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # If set to "false", won't show virtualenv if pyenv is already shown. + # If set to "if-different", won't show virtualenv if it's the same as pyenv. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + + # Anaconda segment format. The following parameters are available within the expansion. + # + # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. + # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. + # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). + # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). + # + # CONDA_PROMPT_MODIFIER can be configured with the following command: + # + # conda config --set env_prompt '({default_env}) ' + # + # The last argument is a Python format string that can use the following variables: + # + # - prefix The same as CONDA_PREFIX. + # - default_env The same as CONDA_DEFAULT_ENV. + # - name The last segment of CONDA_PREFIX. + # - stacked_env Comma-separated list of names in the environment stack. The first element is + # always the same as default_env. + # + # Note: '({default_env}) ' is the default value of env_prompt. + # + # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER + # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former + # is empty. + typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' + + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or + # starts with "$P9K_PYENV_PYTHON_VERSION/". + # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ + # Perlbrew color. + typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 + # Show perlbrew version only when in a perl project subdirectory. + typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true + # Don't show "perl-" at the front. + typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### + # Scala color. + typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 + # Hide scala version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) + # If set to false, hide scala version if it's the same as global: + # $(scalaenv version-name) == $(scalaenv global). + typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide scala version if it's equal to "system". + typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Don't show terraform workspace if it's literally "default". + typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ terraform_version: terraform version (https://www.terraform.io) ]############## + # Terraform version color. + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # AWS segment format. The following parameters are available within the expansion. + # + # - P9K_AWS_PROFILE The name of the current AWS profile. + # - P9K_AWS_REGION The region associated with the current AWS profile. + typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### + # Toolbox color. + typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 + # Don't display the name of the toolbox if it matches fedora-toolbox-*. + typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' + # Custom icon. + # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_FOREGROUND=38 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+------------------------------------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt + # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES='\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578' + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -f 208 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/home/zhuangzi/common/optional/browsers/brave.nix b/home/zhuangzi/common/optional/browsers/brave.nix new file mode 100644 index 0000000..444c2b5 --- /dev/null +++ b/home/zhuangzi/common/optional/browsers/brave.nix @@ -0,0 +1,9 @@ +{ + programs.brave = { + enable = true; + commandLineArgs = [ + "--no-default-browser-check" + "--restore-last-sesion" + ]; + }; +} diff --git a/home/zhuangzi/common/optional/browsers/default.nix b/home/zhuangzi/common/optional/browsers/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/common/optional/browsers/firefox.nix b/home/zhuangzi/common/optional/browsers/firefox.nix new file mode 100644 index 0000000..444c2b5 --- /dev/null +++ b/home/zhuangzi/common/optional/browsers/firefox.nix @@ -0,0 +1,9 @@ +{ + programs.brave = { + enable = true; + commandLineArgs = [ + "--no-default-browser-check" + "--restore-last-sesion" + ]; + }; +} diff --git a/home/zhuangzi/common/optional/comms/default.nix b/home/zhuangzi/common/optional/comms/default.nix new file mode 100644 index 0000000..98330cf --- /dev/null +++ b/home/zhuangzi/common/optional/comms/default.nix @@ -0,0 +1,8 @@ +# +# TODO stage 4: this is a placeholder list for now +# + +signal-desktop + telegram-desktop + discord + slack diff --git a/home/zhuangzi/common/optional/desktops/default.nix b/home/zhuangzi/common/optional/desktops/default.nix new file mode 100644 index 0000000..c32600f --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/default.nix @@ -0,0 +1,17 @@ +{ + imports = [ + # Packages with custom configs go here + + ./hyprland + + ########## Utilities ########## + # ./services/dunst.nix # Notification daemon + # ./waybar.nix # infobar + #./rofi-wayland.nix #app launcher + #./hyprpaper.nix #wallpaper daemon + + # ./gtk.nix # mainly in gnome + # ./qt.nix # mainly in kde + # ./fonts.nix + ]; +} diff --git a/home/zhuangzi/common/optional/desktops/fonts.nix b/home/zhuangzi/common/optional/desktops/fonts.nix new file mode 100644 index 0000000..f28f0ef --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/fonts.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + + # TODO add ttf-font-awesome or font-awesome for waybar + fontProfiles = { + enable = true; + monospace = { + family = "FiraCode Nerd Font"; + package = pkgs.nerdfonts.override { fonts = [ "FiraCode" ]; }; + }; + regular = { + family = "Fira Sans"; + package = pkgs.fira; + }; + }; +} diff --git a/home/zhuangzi/common/optional/desktops/gtk.nix b/home/zhuangzi/common/optional/desktops/gtk.nix new file mode 100644 index 0000000..8b6d409 --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/gtk.nix @@ -0,0 +1,34 @@ +{ config, pkgs, lib, ... }: + +{ + gtk = { + enable = true; + #font.name = TODO see misterio https://github.com/Misterio77/nix-config/blob/f4368087b0fd0bf4a41bdbf8c0d7292309436bb0/home/misterio/features/desktop/common/gtk.nix he has a custom config for managing fonts, colorsheme etc. + + theme = { + name = "adwaita-dark"; + package = pkgs.adw-gtk3; + }; + + iconTheme = { + name = "elementary-Xfce-dark"; + package = pkgs.elementary-xfce-icon-theme; + }; + + #TODO add ascendancy cursor pack + #cursortTheme.name = ""; + #cursortTheme.package = ; + # https://store.kde.org/p/2135229 Catpuccin Mocha Modern Aurora 6 Plasma 6 Window Decorations + + gtk3.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + gtk4.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + }; +} diff --git a/home/zhuangzi/common/optional/desktops/hyprland/binds.nix b/home/zhuangzi/common/optional/desktops/hyprland/binds.nix new file mode 100644 index 0000000..c345ffc --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/hyprland/binds.nix @@ -0,0 +1,141 @@ +# +++ https://github.com/Misterio77/nix-config/blob/main/home/misterio/features/desktop/hyprland/basic-binds.nix +{ lib, config, ... }: { + wayland.windowManager.hyprland.settings = { + bindm = [ + "SUPER,mouse:272,movewindow" + "SUPER,mouse:273,resizewindow" + ]; + + bind = + let + workspaces = [ + "0" + "1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" + "F1" + "F2" + "F3" + "F4" + "F5" + "F6" + "F7" + "F8" + "F9" + "F10" + "F11" + "F12" + ]; + # Map keys (arrows and hjkl) to hyprland directions (l, r, u, d) + directions = rec { + left = "l"; + right = "r"; + up = "u"; + down = "d"; + h = left; + l = right; + k = up; + j = down; + }; + + #swaylock = "${config.programs.swaylock.package}/bin/swaylock"; + #playerctl = "${config.services.playerctld.package}/bin/playerctl"; + #playerctld = "${config.services.playerctld.package}/bin/playerctld"; + #makoctl = "${config.services.mako.package}/bin/makoctl"; + #wofi = "${config.programs.wofi.package}/bin/wofi"; + #pass-wofi = "${pkgs.pass-wofi.override { + #pass = config.programs.password-store.package; + #}}/bin/pass-wofi"; + + #grimblast = "${pkgs.inputs.hyprwm-contrib.grimblast}/bin/grimblast"; + #pactl = "${pkgs.pulseaudio}/bin/pactl"; + #tly = "${pkgs.tly}/bin/tly"; + #gtk-play = "${pkgs.libcanberra-gtk3}/bin/canberra-gtk-play"; + #notify-send = "${pkgs.libnotify}/bin/notify-send"; + + #gtk-launch = "${pkgs.gtk3}/bin/gtk-launch"; + #xdg-mime = "${pkgs.xdg-utils}/bin/xdg-mime"; + #defaultApp = type: "${gtk-launch} $(${xdg-mime} query default ${type})"; + + #terminal = config.home.sessionVariables.TERM; + #browser = defaultApp "x-scheme-handler/https"; + #editor = defaultApp "text/plain"; + in + [ + #################### Program Launch #################### + "SHIFTALT,Return,exec,kitty" + + #################### Basic Bindings #################### + "SHIFTALT,q,killactive" + "SUPERSHIFT,e,exit" + + "SUPER,s,togglesplit" + "SUPER,f,fullscreen,1" + "SUPERSHIFT,f,fullscreen,0" + "SUPERSHIFT,space,togglefloating" + + "SUPER,minus,splitratio,-0.25" + "SUPERSHIFT,minus,splitratio,-0.3333333" + + "SUPER,equal,splitratio,0.25" + "SUPERSHIFT,equal,splitratio,0.3333333" + + "SUPER,g,togglegroup" + "SUPER,t,lockactivegroup,toggle" + "SUPER,apostrophe,changegroupactive,f" + "SUPERSHIFT,apostrophe,changegroupactive,b" + + "SUPER,u,togglespecialworkspace" + "SUPERSHIFT,u,movetoworkspacesilent,special" + "SUPER,i,pseudo" + ] ++ + # Change workspace + (map + (n: + "ALT,${n},workspace,name:${n}" + ) + workspaces) ++ + # Move window to workspace + (map + (n: + "SHIFTALT,${n},movetoworkspacesilent,name:${n}" + ) + workspaces) ++ + # Move focus + (lib.mapAttrsToList + (key: direction: + "ALT,${key},movefocus,${direction}" + ) + directions) ++ + # Swap windows + (lib.mapAttrsToList + (key: direction: + "SUPERSHIFT,${key},swapwindow,${direction}" + ) + directions) ++ + # Move windows + (lib.mapAttrsToList + (key: direction: + "SHIFTALT,${key},movewindoworgroup,${direction}" + ) + directions) ++ + # Move monitor focus + (lib.mapAttrsToList + (key: direction: + "SUPERALT,${key},focusmonitor,${direction}" + ) + directions) ++ + # Move workspace to other monitor + (lib.mapAttrsToList + (key: direction: + "SUPERALTSHIFT,${key},movecurrentworkspacetomonitor,${direction}" + ) + directions); + }; +} diff --git a/home/zhuangzi/common/optional/desktops/hyprland/default.nix b/home/zhuangzi/common/optional/desktops/hyprland/default.nix new file mode 100644 index 0000000..5e8a658 --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/hyprland/default.nix @@ -0,0 +1,100 @@ +{ lib, config, pkgs, ... }: +let + hyprland = pkgs.inputs.hyprland.hyprland.override {wrapRuntimeDeps = false;}; + xdph = pkgs.inputs.hyprland.xdg-desktop-portal-hyprland.override {inherit hyprland;}; +in { + imports = [ + # custom key binds + ./binds.nix + ]; + + # NOTE: xdg portal package is currently set in /hosts/common/optional/hyprland.nix + + wayland.windowManager.hyprland = { + enable = true; + # systemd = { + # enable = true; + # # TODO: experiment with whether this is required. + # # Same as default, but stop the graphical session too + # extraCommands = lib.mkBefore [ + # "systemctl --user stop graphical-session.target" + # "systemctl --user start hyprland-session.target" + # ]; + # }; + + # plugins = [];v + + settings = { + env = [ + "NIXOS_OZONE_WL, 1" # for ozone-based and electron apps to run on wayland + "MOZ_ENABLE_WAYLAND, 1" # for firefox to run on wayland + "MOZ_WEBRENDER, 1" # for firefox to run on wayland + "XDG_SESSION_TYPE,wayland" + "WLR_NO_HARDWARE_CURSORS,1" + "WLR_RENDERER_ALLOW_SOFTWARE,1" + # "QT_QPA_PLATFORM,wayland" + ]; + + # general = { + # gaps_in = 8; + # gaps_out = 5; + # border_size = 3; + # cursor_inactive_timeout = 4; + # }; + # + # input = { + # kb_layout = "us"; + # # mouse = { + # # acceleration = 1.0; + # # naturalScroll = true; + # # }; + # }; + # + # decoration = { + # active_opacity = 0.94; + # inactive_opacity = 0.75; + # fullscreen_opacity = 1.0; + # # rounding = 7; + # blur = { + # enabled = false; + # size = 5; + # passes = 3; + # new_optimizations = true; + # ignore_opacity = true; + # }; + # drop_shadow = false; + # shadow_range = 12; + # shadow_offset = "3 3"; + # "col.shadow" = "0x44000000"; + # "col.shadow_inactive" = "0x66000000"; + # }; + + # exec-once = ''${startupScript}/path''; + }; + + # load at the end of the hyperland set + # extraConfig = '' ''; + }; + + # # TODO: move below into individual .nix files with their own configs + # home.packages = builtins.attrValues { + # inherit (pkgs) + # nm-applet --indicator & # notification manager applet. + # bar + # waybar # closest thing to polybar available + # where is polybar? not supported yet: https://github.com/polybar/polybar/issues/414 + # eww # alternative - complex at first but can do cool shit apparently + # + # # Wallpaper daemon + # hyprpaper + # swaybg + # wpaperd + # mpvpaper + # swww # vimjoyer recoomended + # nitrogen + # + # # app launcher + # rofi-wayland; + # wofi # gtk rofi + # }; +} diff --git a/home/zhuangzi/common/optional/desktops/hyprland/hyprlock.nix b/home/zhuangzi/common/optional/desktops/hyprland/hyprlock.nix new file mode 100644 index 0000000..e2a5a20 --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/hyprland/hyprlock.nix @@ -0,0 +1,79 @@ +# https://www.reddit.com/r/hyprland/comments/1b2l3lc/hyprlock_with_pywal/ +# https://github.com/zDyanTB/HyprNova/blob/master/.config/hypr/hyprlock.conf +{ + source = $HOME/.cache/wal/colors-hyprland.conf + + background { + monitor = + path = $HOME/.current_wallpaper # only png supported for now + # color = $color1 + + # all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations + blur_size = 4 + blur_passes = 3 # 0 disables blurring + noise = 0.0117 + contrast = 1.3000 # Vibrant!!! + brightness = 0.8000 + vibrancy = 0.2100 + vibrancy_darkness = 0.0 + } + + input-field { + monitor = + size = 250, 50 + outline_thickness = 3 + dots_size = 0.26 # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 0.64 # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true + outer_color = $color0 + inner_color = $color0 + font_color = $color6 + fade_on_empty = true + placeholder_text = Password... # Text rendered in the input box when it's empty. + hide_input = false + + position = 0, 50 + halign = center + valign = bottom + } + + # Current time + label { + monitor = + text = cmd[update:1000] echo " $(date +"%H:%M:%S") " + color = $color6 + font_size = 64 + font_family = JetBrains Mono Nerd Font 10 + shadow_passes = 3 + shadow_size = 4 + + position = 0, 16 + halign = center + valign = center + } + + # Date + label { + monitor = + text = cmd[update:18000000] echo " "$(date +'%A, %-d %B %Y')" " + color = $color7 + font_size = 24 + font_family = JetBrains Mono Nerd Font 10 + + position = 0, -16 + halign = center + valign = center + } + + label { + monitor = + text = Hey $USER + color = $color7 + font_size = 18 + font_family = Inter Display Medium + + position = 0, 30 + halign = center + valign = bottom + } +} diff --git a/home/zhuangzi/common/optional/desktops/hyprland/services/dunst.nix b/home/zhuangzi/common/optional/desktops/hyprland/services/dunst.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/common/optional/desktops/hyprpaper.nix b/home/zhuangzi/common/optional/desktops/hyprpaper.nix new file mode 100644 index 0000000..ab24856 --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/hyprpaper.nix @@ -0,0 +1,75 @@ +{ + lib, + stdenv, + pkg-config, + cmake, + cairo, + expat, + file, + fribidi, + hyprlang, + libdatrie, + libGL, + libjpeg, + libselinux, + libsepol, + libthai, + libwebp, + pango, + pcre, + pcre2, + util-linux, + wayland, + wayland-protocols, + wayland-scanner, + libXdmcp, + debug ? false, + version ? "git", +}: +stdenv.mkDerivation { + pname = "hyprpaper" + lib.optionalString debug "-debug"; + inherit version; + + src = ../.; + + cmakeBuildType = + if debug + then "Debug" + else "Release"; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + cairo + expat + file + fribidi + hyprlang + libdatrie + libGL + libjpeg + libselinux + libsepol + libthai + libwebp + pango + pcre + pcre2 + wayland + wayland-protocols + wayland-scanner + libXdmcp + util-linux + ]; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprpaper"; + description = "A blazing fast wayland wallpaper utility with IPC controls"; + license = licenses.bsd3; + platforms = platforms.linux; + mainProgram = "hyprpaper"; + }; +} diff --git a/home/zhuangzi/common/optional/desktops/qt.nix b/home/zhuangzi/common/optional/desktops/qt.nix new file mode 100644 index 0000000..472269e --- /dev/null +++ b/home/zhuangzi/common/optional/desktops/qt.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + qt = { + enable = true; + platformTheme = "gtk2"; + style = { + name = "gtk2"; + # autodetected themes: + # adwaita, adwaita-dark, adwaita-highcontrast, adwaita-hightcontrastinverse, breeze, bb10bright, bb10dark, cde, cleanlooks, gtk2, motfi, plastique + #theme package + package = pkgs.qt6Packages.qt6gtk2; + }; + }; +} diff --git a/home/zhuangzi/common/optional/dev/default.nix b/home/zhuangzi/common/optional/dev/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/common/optional/dev/foot.nix b/home/zhuangzi/common/optional/dev/foot.nix new file mode 100644 index 0000000..fdfb7aa --- /dev/null +++ b/home/zhuangzi/common/optional/dev/foot.nix @@ -0,0 +1,96 @@ +{ + pkgs, + theme, + ... +}: { + home.packages = with pkgs; [ + libsixel + # for displaying images + ]; + programs.foot = { + enable = true; + server.enable = false; + settings = { + main = { + app-id = "foot"; + title = "foot"; + locked-title = "no"; + term = "xterm-256color"; + font = "monospace:size=10.5"; + vertical-letter-offset = "-0.75"; + pad = "12x21 center"; + resize-delay-ms = 100; + notify = "notify-send -a \${app-id} -i \${app-id} \${title} \${body}"; + selection-target = "primary"; + # box-drawings-uses-font-glyphs = "yes"; + dpi-aware = "yes"; + bold-text-in-bright = "no"; + word-delimiters = ",│`|:\"'()[]{}<>"; + }; + cursor = { + style = "beam"; + beam-thickness = 2; + }; + scrollback = { + lines = 10000; + multiplier = 3; + }; + + bell = { + urgent = "yes"; + notify = "yes"; + command = "notify-send bell"; + command-focused = "no"; + }; + url = { + launch = "xdg-open \${url}"; + label-letters = "sadfjklewcmpgh"; + osc8-underline = "url-mode"; + protocols = "http, https, ftp, ftps, file, gemini, gopher, irc, ircs"; + + uri-characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,~:;/?#@!$&%*+=\"'()[]"; + }; + colors = with theme.colors; { + alpha = "0.75"; + foreground = text; + background = base; + + regular0 = surface1; + regular1 = red; + regular2 = green; + regular3 = yellow; + regular4 = blue; + regular5 = pink; + regular6 = teal; + regular7 = subtext1; + + bright0 = surface2; + bright1 = red; + bright2 = green; + bright3 = yellow; + bright4 = blue; + bright5 = pink; + bright6 = teal; + bright7 = subtext0; + }; + mouse = { + hide-when-typing = "yes"; + }; + key-bindings = { + show-urls-launch = "Control+Shift+u"; + unicode-input = "Control+Shift+i"; + }; + mouse-bindings = { + selection-override-modifiers = "Shift"; + primary-paste = "BTN_MIDDLE"; + select-begin = "BTN_LEFT"; + select-begin-block = "Control+BTN_LEFT"; + select-extend = "BTN_RIGHT"; + select-extend-character-wise = "Control+BTN_RIGHT"; + select-word = "BTN_LEFT-2"; + select-word-whitespace = "Control+BTN_LEFT-2"; + #select-row = "BTN_LEFT-3"; + }; + }; + }; +} diff --git a/home/zhuangzi/common/optional/dev/vscodium.nix b/home/zhuangzi/common/optional/dev/vscodium.nix new file mode 100644 index 0000000..d2fe162 --- /dev/null +++ b/home/zhuangzi/common/optional/dev/vscodium.nix @@ -0,0 +1,435 @@ +/* +VS Codium +*/ + +{ pkgs, inputs, system, config, ... }: + +{ + programs.vscodium = { + enable = true; + package = pkgs.unstable.vscodium; + enableExtensionUpdateCheck = true; + enableUpdateCheck = true; + + extensions = let + t = inputs.nix-vscode-extensions.extensions.${system}.forVSCodeVersion + config.programs.vscode.package.version; + p = t.vscode-marketplace; + in [ + # general + p.bierner.emojisense + p.bierner.markdown-checkbox + p.bierner.markdown-emoji + p.davidlday.languagetool-linter + p.dracula-theme.theme-dracula + p.eamodio.gitlens + p.gruntfuggly.todo-tree + p.mkhl.direnv + p.robole.marky-stats + p.stkb.rewrap + p.tomoki1207.pdf + p.tyriar.sort-lines + + # haskell + p.haskell.haskell # language server + p.justusadam.language-haskell # syntax highlighting + p.s0kil.vscode-hsx # HSX is HTML templating for IHP + + # other languages + p.banacorn.agda-mode + p.denoland.vscode-deno + p.jnoortheen.nix-ide + p.kokakiwi.vscode-just + p.mark-hansen.hledger-vscode + p.samuelcolvin.jinjahtml + p.scala-lang.scala + p.scalameta.metals + p.tamasfe.even-better-toml + + # C# + # the nixpkgs version of this has a patch for a problem where uname isn't found + pkgs.unstable.vscode-extensions.ms-dotnettools.csharp + p.ms-dotnettools.vscode-dotnet-runtime + p.csharpier.csharpier-vscode + ]; + + { + "extensionsGallery": { + "serviceUrl": "https://open-vsx.org/vscode/gallery", + "itemUrl": "https://open-vsx.org/vscode/item" + "cacheUrl": "", + "controlUrl": "" + } +} + keybindings = [ + { + key = "ctrl+shift+t"; + command = "workbench.action.terminal.focus"; + when = "!terminalFocus"; + } + { + key = "ctrl+shift+t"; + command = "workbench.action.focusActiveEditorGroup"; + when = "terminalFocus"; + } + + # use ctrl+c in the terminal for copying if there's a selection + # (passed through to the shell otherwise) + # thanks to https://stackoverflow.com/a/69928270/7659481 + { + key = "ctrl+c"; + command = "workbench.action.terminal.copySelection"; + when = "terminalFocus && terminalProcessSupported && terminalTextSelected"; + } + + # use ctrl+v in the terminal for pasting + { + key = "ctrl+v"; + command = "workbench.action.terminal.paste"; + when = "terminalFocus && terminalProcessSupported"; + } + + # workaround to use Neo2 backslash for Agda Unicode input + # neither `[Backslash]` nor `capslock+u` work + # taken from the record keys function from the shortcut editor + { + key = "[Backslash]"; + command = "-agda-mode.input-symbol[Activate]"; + } + { + key = "["; # this is what Neo2 ß registers as + command = "agda-mode.input-symbol[Activate]"; + when = "editorTextFocus && !editorHasSelection && editorLangId == 'agda'"; + } + + { + key = "ctrl+x ctrl+="; + command = "-agda-mode.lookup-symbol"; + } + { + key = "ctrl+c ctrl+s"; + command = "agda-mode.lookup-symbol"; + when = "editorTextFocus && !editorHasSelection && editorLangId == 'agda'"; + } + ]; + + userSettings = { + # ======== General ======== + "workbench.commandPalette.experimental.suggestCommands" = true; + "security.workspace.trust.enabled" = false; + "update.showReleaseNotes" = false; + "extensions.autoUpdate" = false; + # Themes + "workbench.colorTheme": "Kimbie Dark" + "workbench.iconTheme" = "material-icon-theme"; + "workbench.productIconTheme" = "material-product-icons"; + + "workbench.cloudChanges.continueOn" = "off"; + "workbench.cloudChanges.autoResume" = "off"; + "workbench.startupEditor" = "none"; + "update.mode" = "start"; + "window.menuBarVisibility": "compact", + + # ======== Telemetry ======== + "continue.telemetryEnabled" = false; + + "allowAnonymousTelemetry" = false; + "telemetry.telemetryLevel" = "off"; + "aws.telemetry" = false; + "redhat.telemetry.enabled" = false; + "aws.codeWhisperer.shareCodeWhispererContentWithAWS" = false; + "code-runner.enableAppInsights" = false; + "workbench.enableExperiments" = false; + "typescript.tsserver.experimental.enableProjectDiagnostics" = false; + + "keyboard.dispatch" = "keyCode"; + + # ======== Terminal ======== + "terminal.integrated.splitCwd" = "workspaceRoot"; + "terminal.integrated.confirmOnKill" = "always"; + "terminal.integrated.copyOnSelection" = true; + "terminal.integrated.tabs.hideCondition" = "never"; + "terminal.integrated.scrollback" = 5000; + "terminal.integrated.cursorStyle" = "line"; + "terminal.integrated.cursorBlinking" = "solid"; + "terminal.integrated.cursorWidth" = 1; + "terminal.integrated.fontFamily" = "Geist"; + "terminal.integrated.fontSize" = 14; + "terminal.integrated.lineHeight" = 1.2; + "terminal.integrated.rightClickBehavior" = "default"; + "terminal.integrated.minimumContrastRatio" = 1; + + # ===== Linux ===== + /* + vscode fixes colors in the termial to meet certain contrast ratios + I just want the original colors + */ + + # "terminal.integrated.shell.linux" = "${pkgs.fish}/bin/fish"; + # "terminal.integrated.shellArgs.linux" = [ + # "--login" + # "-c" + # "set -x EDITOR vim" + # ]; + "terminal.integrated.defaultProfile.linux" = "zsh"; + "terminal.integrated.profiles.linux" = { + "zsh" = { + "path" = "${pkgs.zsh}/bin/zsh"; + }; + }; + "terminal.external.linuxExec" = "#!/bin/bash"; + + # ===== Win ===== + "terminal.integrated.defaultProfile.windows" = "Git Bash"; + "terminal.integrated.profiles.windows" = { + "Custom Init" = { + "path" = "pwsh.exe"; + "args" = [ + "-noexit"; + "-file"; + "${env:APPDATA}\\PowerShell\\custom-init.ps1" + ] + } + }; + "terminal.integrated.env.windows" = { + "CHERE_INVOKING" = "1" + }; + # "terminal.integrated.defaultProfile.windows" = "PowerShell"; + # "terminal.integrated.shell.windows" = "${pkgs.pwsh}/bin/pwsh.exe"; + # "terminal.integrated.shellArgs.windows" = [ + # "-NoLogo" + # "-NoProfile" + # "-Command" + # "set-location ${pkgs.pwsh}" + # "-Command" + # "set-location ${pkgs.pwsh}" + # "-Command" + # "set EDITOR vim" + # ]; + + + # ===== Explorer ===== + "explorer.confirmDelete" = false; + "explorer.confirmDragAndDrop" = false; + + # ===== Files ===== + "files.defaultLanguage" = "javascript"; + "files.enableTrash" = true; + "files.insertFinalNewline" = true; + "files.trimTrailingWhitespace" = false; + + # ===== Git ===== + "git.autofetch" = "all"; # regularly fetch from all remotes of the repo + "git.autofetchPeriod" = 120; + "git.closeDiffOnOperation" = true; # close diff editors on commits etc. + "git.confirmForcePush" = false; + "git.confirmSync" = false; + "git.allowForcePush" = true; + "git.path" = ""; + "git.enableSmartCommit" = false; # commit all if nothing staged + + + # ===== Editor ===== + "editor.inlineSuggest.enabled" = true; + "editor.links" = true; + "editor.codeLens" = true; + "editor.autoIndent" = "advanced"; + "editor.detectIndentation" = true; + "editor.hover.enabled" = true; + + # allow various mathematical symbols for use in stuff like TeX and Agda + "editor.unicodeHighlight.allowedCharacters" = builtins.listToAttrs (map (x: { name = x; value = true; }) [ + "ℕ" "ℚ" "ℝ" "ℤ" "α" "γ" "ρ" "σ" "ι" "∨" "ℓ" "‘" + ]); + + "editor.hover.delay" = 150; + "editor.suggest.preview" = true; + "editor.suggestFontSize" = 12; + "editor.fontFamily" = "Geist"; + "editor.fontSize" = 15; + "editor.fontLigatures" = true; + "editor.rulers" = [ 100 ]; + "editor.wordWrapColumn" = 100; # column to wrap at; ignored by default due to wordWrap, relevant e.g. for markdown + "editor.wordWrap" = "on"; # by default, wrap at the viewport + "rewrap.wrappingColumn" = 100; # rewrap text with rewrap extension at column 100 + "editor.renderWhitespace" = "boundary"; + "editor.guides.bracketPairs" = true; + "editor.language.brackets" = [ + [ "[" "]" ] + [ "{" "}" ] + [ "(" ")" ] + [ "⟨" "⟩" ] + ]; + # by default, I use tabs for indentation for accessibility reasons + "editor.insertSpaces" = false; + "editor.tabSize" = 4; + "editor.detectIndentation" = true; + + "editor.scrollbar.vertical" = "visible"; + "editor.minimap.showSlider" = "always"; + "editor.minimap.size" = "fill"; + "editor.minimap.maxColumn" = 100; + + # DiffEditor + "diffEditor.experimental.showMoves" = true; + "diffEditor.ignoreTrimWhitespace" = false; + "diffEditor.diffAlgorithm" = "advanced"; + + # Files + "files.trimFinalNewlines" = true; + "files.trimTrailingWhitespace" = true; + "files.insertFinalNewline" = true; + "files.watcherExclude" = { + "**/.bloop" = true; + "**/.metals" = true; + "**/.ammonite" = true; + }; + + # === JS/TS === + "[javascript]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode" + }; + "[typescript]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode" + }; + "javascript.format.enable" = true; + "javascript.format.semicolons" = "insert"; + "debug.javascript.codelens.npmScripts" = "all"; + "javascript.suggestionActions.enabled" = true; + # "debug.javascript.autoAttachSmartPattern" = [ + # "${workspaceFolder}/**"; + # "!**/node_modules/**"; + # "**/$KNOWN_TOOLS$/**" + # ]; + "typescript.updateImportsOnFileMove.enabled" = "always"; + "typescript.implementationsCodeLens.enabled" = true; + "typescript.tsserver.log" = "off"; + "typescript.tsserver.enableTracing" = false; + "typescript.format.placeOpenBraceOnNewLineForFunctions" = true; + "typescript.implementationsCodeLens.showOnInterfaceMethods" = true; + "typescript.tsserver.useSyntaxServer" = "always"; + "typescript.tsserver.maxTsServerMemory" = 2048; + "typescript.tsserver.web.projectWideIntellisense.enabled" = true; + "typescript.format.enable" = true; + "javascript.referencesCodeLens.enabled" = false; + "javascript.referencesCodeLens.showOnAllFunctions" = true; + "javascript.inlayHints.parameterNames.enabled" = "all"; + "javascript.inlayHints.parameterTypes.enabled" = true; + "javascript.updateImportsOnFileMove.enabled" = "always"; + "npm.fetchOnlinePackageInfo" = true; + + # Svelte + Web dev + + "svelte.plugin.typescript.hover.enable" = true; + "svelte.plugin.typescript.enable" = true; + "svelte.enable-ts-plugin" = true; + "css.hover.documentation" = true; + "html.hover.documentation" = true; + + # === Rust === + "rust.show_hover_context" = true; + + + # === Golang === + "go.useLanguageServer" = true; + "go.lintTool" = "golangci-lint"; + + + # === Py === + "[python]" = { + "editor.formatOnType" = true + }; + "python.missingPackage.severity" = "Warning"; + "python.languageServer" = "Jedi"; + "python.experiments.enabled" = false; + "python.experiments.optOutFrom" = [ + "All" + ]; + + # Haskell + "haskell.manageHLS"= "PATH"; + + # TODO Tree + #"todo-tree.general.showActivityBarBadge" = true; + #"todo-tree.general.tags" = [ "TODO" "FIXME" ]; + + # Marky Markdown + "markyMarkdown.statsShowReadingTime" = false; + "markyMarkdown.statsShowWords" = true; + "markyMarkdown.statsShowCharacters" = true; + "markyMarkdown.statsItemSeparator" = " / "; + + "languageToolLinter.lintOnOpen" = true; + # https://github.com/davidlday/vscode-languagetool-linter/issues/603 + # "languageToolLinter.languageTool.ignoredWordHint" = false; + + "languageToolLinter.languageTool.preferredVariants" = "en-US,de-DE,nl-NL"; + "languageToolLinter.languageTool.ignoredWordsGlobal" = [ + "iirc" "eisfunke" "eisfunkelab" "kb" "nebelhorn" "agda" "dir" + ]; + + # === IaC, Devops === + "terraform.experimentalFeatures.prefillRequiredFields" = true; + "terraform.experimentalFeatures.validateOnSave" = true; + "[ansible]" = { + "editor.detectIndentation" = true; + "editor.insertSpaces" = true; + "editor.tabSize" = 2; + "editor.quickSuggestions" = { + "comments" = true; + "other" = true; + "strings" = true + }; + "editor.autoIndent" = "advanced" + }; + "ansible.lightspeed.enabled" = false; + "yaml.hover" = true; + "yaml.completion" = true; + + # === Nix === + "nix.enableLanguageServer" = true; // Enable LSP. + "nix.serverPath" = "nil"; // The path to the LSP server executable. + # === advanced + "nix.serverSettings" = { + "nil" = { + "formatting" = { "command" = ["nixpkgs-fmt"] } + } + }; + + + #"agdaMode.inputMethod.activationKey" = "ß"; + + # language specific indentation settings + "[html]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode" + }; + "[jsonc]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode" + }; + "[json]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode" + }; + "[latex]" = { + "editor.defaultFormatter" = "esbenp.prettier-vscode"; + "editor.formatOnPaste" = false; + "editor.suggestSelection" = "recentlyUsedByPrefix" + }; + "[svelte]" = { + "editor.acceptSuggestionOnCommitCharacter" = true; + "editor.acceptSuggestionOnEnter" = "off" + }; + "[scala]" = { # follow Scala style guide + "editor.insertSpaces" = true; + "editor.tabSize" = 2; + }; + "[markdown]" = { # indent markdown with spaces so YAML frontmatter doesn't break + "editor.wordWrap" = "bounded"; # wrap markdown files at line width + "editor.insertSpaces" = true; + "editor.tabSize" = 2; + }; + "[haskell]"."editor.insertSpaces" = true; # GHC warns when using tabs + "[python]"."editor.insertSpaces" = true; # black forces spaces + "[agda]"."editor.insertSpaces" = true; # agda forces spaces + }; + }; +} diff --git a/home/zhuangzi/common/optional/graphical/default.nix b/home/zhuangzi/common/optional/graphical/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/common/optional/graphical/extra.nix b/home/zhuangzi/common/optional/graphical/extra.nix new file mode 100644 index 0000000..d2b3ad9 --- /dev/null +++ b/home/zhuangzi/common/optional/graphical/extra.nix @@ -0,0 +1,11 @@ +/* +additional shell apps not needed on a minimal system +*/ + +{ pkgs, inputs', ... }: + +{ + home.packages = [ + pkgs.ffmpeg_6 + pkgs.yt-dlp + pkgs.dcraw # for converting RAW pictures diff --git a/home/zhuangzi/common/optional/media/default.nix b/home/zhuangzi/common/optional/media/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/common/optional/sops.nix b/home/zhuangzi/common/optional/sops.nix new file mode 100644 index 0000000..ea6fb95 --- /dev/null +++ b/home/zhuangzi/common/optional/sops.nix @@ -0,0 +1,44 @@ +# home level sops. see hosts/common/optional/sops.nix for hosts level +# TODO should I split secrtets.yaml into a home level and a hosts level or move to a single sops.nix entirely? + +{ inputs, ... }: +let + secretspath = builtins.toString inputs.mysecrets; +in +{ + imports = [ + inputs.sops-nix.homeManagerModules.sops + ]; + + sops = { + # gnupg = { + # home = "/var/lib/sops"; + # sshKeyPaths = [ ]; + # } + + # This is the ta/dev key and needs to have been copied to this location on the host + age.keyFile = "/home/ta/.config/sops/age/keys.txt"; + + defaultSopsFile = "${secretspath}/secrets.yaml"; + # defaultSopsFile = ../../../../hosts/common/secrets.yaml; + validateSopsFiles = false; + + secrets = { + "private_keys/maya" = { + path = "/home/ta/.ssh/id_maya"; + }; + "private_keys/mara" = { + path = "/home/ta/.ssh/id_mara"; + }; + "private_keys/manu" = { + path = "/home/ta/.ssh/id_manu"; + }; + "private_keys/mila" = { + path = "/home/ta/.ssh/id_mila"; + }; + "private_keys/meek" = { + path = "/home/ta/.ssh/id_meek"; + }; + }; + }; +} diff --git a/home/zhuangzi/common/optional/systems/rehoboam.nix b/home/zhuangzi/common/optional/systems/rehoboam.nix new file mode 100644 index 0000000..50e6269 --- /dev/null +++ b/home/zhuangzi/common/optional/systems/rehoboam.nix @@ -0,0 +1,30 @@ +{pkgs, ...}: { + imports = [ + ./global + ./features/desktop/wireless + ./features/desktop/hyprland + ./features/pass + ]; + + wallpaper = pkgs.wallpapers.plains-gold-field; + + monitors = [ + { + name = "HDMI-A-1"; + width = 1920; + height = 1080; + workspace = "2"; + x = 0; + } + { + name = "eDP-1"; + width = 1920; + height = 1080; + workspace = "1"; + x = 1920; + primary = true; + } + ]; + + # programs.git.userEmail = "gabriel@zoocha.com"; +} diff --git a/home/zhuangzi/common/optional/tools/default.nix b/home/zhuangzi/common/optional/tools/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/host-template.nix b/home/zhuangzi/host-template.nix new file mode 100644 index 0000000..1931b17 --- /dev/null +++ b/home/zhuangzi/host-template.nix @@ -0,0 +1,34 @@ +{ lib, configVars, ... }: +let + +in +{ + imports = [ + #################### Hardware Modules #################### + inputs.hardware.nixosModules.common-cpu-amd + inputs.hardware.nixosModules.lenovo-ideapad-15arh05 # Replace with actual model, push upstream, several drivers needed. + inputs.hardware.nixosModules.common-pc-ssd + inputs.hardware.nixosModules.common-pc-laptop + # inputs.hardware.nixosModules.common-cpu-amd + # inputs.hardware.nixosModules.common-cpu-intel + # inputs.hardware.nixosModules.common-gpu-nvidia + # inputs.hardware.nixosModules.common-gpu-intel + # example fingerprint sensor https://github.com/ahbnr/nixos-06cb-009a-fingerprint-sensor/tree/main/pkgs + + + + #################### Required Configs #################### + ./common/core #required + + #################### Host-specific Optional Configs #################### + + + ]; + + home = { + username = configVars.username; + homeDirectory = "/home/${configVars.username}"; + }; + # Disable impermanence + #home.persistence = lib.mkForce { }; +} diff --git a/home/zhuangzi/jeroboam.nix b/home/zhuangzi/jeroboam.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/zhuangzi/rehoboam.nix b/home/zhuangzi/rehoboam.nix new file mode 100644 index 0000000..4fb674b --- /dev/null +++ b/home/zhuangzi/rehoboam.nix @@ -0,0 +1,15 @@ +{ inputs, lib, pkgs, config, outputs, ... }: +{ + imports = [ + # =========== Required Configs =========== # + common/core #required + + # =========== Host-specific Optional Configs =========== # + common/optional/sops.nix + common/optional/helper-scripts + + common/optional/desktops/gtk.nix + common/optional/browsers/brave.nix # for testing against 'media' user + + ]; +} diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e69de29 diff --git a/keys/id_dromedar b/keys/id_dromedar new file mode 100644 index 0000000..e69de29 diff --git a/keys/id_falcon b/keys/id_falcon new file mode 100644 index 0000000..e69de29 diff --git a/keys/id_fennec b/keys/id_fennec new file mode 100644 index 0000000..e69de29 diff --git a/keys/id_gerbil b/keys/id_gerbil new file mode 100644 index 0000000..e69de29 diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..9f98b7a --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,23 @@ +{ lib, ... }: +{ + # use path relative to the root of the project + relativeToRoot = lib.path.append ../.; + scanPaths = path: + builtins.map + (f: (path + "/${f}")) + (builtins.attrNames + (lib.attrsets.filterAttrs + ( + path: _type: + (_type == "directory") # include directories + || ( + # FIXME this barfs when child directories don't contain a default.nix + # example: + # error: getting status of '/nix/store/mx31x8530b758ap48vbg20qzcakrbc8 (see hosts/common/core/services/default.nix)a-source/hosts/common/core/services/default.nix': No such file or directory + # I created a blank default.nix in hosts/common/core/services to work around + (path != "default.nix") # ignore default.nix + && (lib.strings.hasSuffix ".nix" path) # include .nix files + ) + ) + (builtins.readDir path))); +} diff --git a/modules/home-manager/colors.nix b/modules/home-manager/colors.nix new file mode 100644 index 0000000..8fcced8 --- /dev/null +++ b/modules/home-manager/colors.nix @@ -0,0 +1,59 @@ +# https://github.com/Misterio77/nix-config/blob/63850798c0216eee77a09958236e0608c8cab023/modules/home-manager/colors.nix +{ + lib, + config, + pkgs, + ... +}: let + cfg = config.colorscheme; + inherit (lib) types mkOption; + + hexColor = types.strMatching "#([0-9a-fA-F]{3}){1,2}"; + + removeFilterPrefixAttrs = prefix: attrs: + lib.mapAttrs' (n: v: { + name = lib.removePrefix prefix n; + value = v; + }) (lib.filterAttrs (n: _: lib.hasPrefix prefix n) attrs); + +in { + options.colorscheme = { + source = mkOption { + type = types.either types.path hexColor; + # TODO: generate default from hostname + # colorFromString = c: builtins.substring 0 6 (builtins.hashString "md5" c); + default = + if config.wallpaper != null + then config.wallpaper + else "#2B3975"; + }; + mode = mkOption { + type = types.enum ["dark" "light"]; + default = "dark"; + }; + type = mkOption { + type = types.enum (pkgs.generateColorscheme null null).schemeTypes; + default = "fruit-salad"; + }; + + generatedDrv = mkOption { + type = types.package; + default = pkgs.generateColorscheme (cfg.source.name or "default") cfg.source; + }; + rawColorscheme = mkOption { + type = types.attrs; + default = cfg.generatedDrv.imported.${cfg.type}; + }; + + colors = mkOption { + readOnly = true; + type = types.attrsOf hexColor; + default = cfg.rawColorscheme.colors.${cfg.mode}; + }; + harmonized = mkOption { + readOnly = true; + type = types.attrsOf hexColor; + default = removeFilterPrefixAttrs "${cfg.mode}-" cfg.rawColorscheme.harmonized_colors; + }; + }; +} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix new file mode 100644 index 0000000..b7b0ed8 --- /dev/null +++ b/modules/home-manager/default.nix @@ -0,0 +1,7 @@ +{ + fonts = import ./fonts.nix; + monitors = import ./monitors.nix; + shellcolor = import ./shellcolor.nix; + wallpaper = import ./wallpaper.nix; + colors = import ./colors.nix; +} diff --git a/modules/home-manager/fonts.nix b/modules/home-manager/fonts.nix new file mode 100644 index 0000000..3709dec --- /dev/null +++ b/modules/home-manager/fonts.nix @@ -0,0 +1,36 @@ +# https://github.com/Misterio77/nix-config/blob/63850798c0216eee77a09958236e0608c8cab023/modules/home-manager/fonts.nix +{ + lib, + config, + ... +}: let + mkFontOption = kind: { + family = lib.mkOption { + type = lib.types.str; + default = null; + description = "Family name for ${kind} font profile"; + example = "Fira Code"; + }; + package = lib.mkOption { + type = lib.types.package; + default = null; + description = "Package for ${kind} font profile"; + example = "pkgs.fira-code"; + }; + }; + cfg = config.fontProfiles; +in { + options.fontProfiles = { + enable = lib.mkEnableOption "Whether to enable font profiles"; + monospace = mkFontOption "monospace"; + regular = mkFontOption "regular"; + }; + + config = lib.mkIf cfg.enable { + fonts.fontconfig.enable = true; + home.packages = [ + cfg.monospace.package + cfg.regular.package + ]; + }; +} diff --git a/modules/home-manager/monitors.nix b/modules/home-manager/monitors.nix new file mode 100644 index 0000000..20534bf --- /dev/null +++ b/modules/home-manager/monitors.nix @@ -0,0 +1,65 @@ +# https://github.com/Misterio77/nix-config/blob/63850798c0216eee77a09958236e0608c8cab023/modules/home-manager/monitors.nix +{ + lib, + config, + ... +}: let + inherit (lib) mkOption types; + cfg = config.monitors; +in { + options.monitors = mkOption { + type = types.listOf ( + types.submodule { + options = { + name = mkOption { + type = types.str; + example = "DP-1"; + }; + primary = mkOption { + type = types.bool; + default = false; + }; + width = mkOption { + type = types.int; + example = 1920; + }; + height = mkOption { + type = types.int; + example = 1080; + }; + refreshRate = mkOption { + type = types.int; + default = 60; + }; + x = mkOption { + type = types.int; + default = 0; + }; + y = mkOption { + type = types.int; + default = 0; + }; + enabled = mkOption { + type = types.bool; + default = true; + }; + workspace = mkOption { + type = types.nullOr types.str; + default = null; + }; + }; + } + ); + default = []; + }; + config = { + assertions = [ + { + assertion = + ((lib.length config.monitors) != 0) + -> ((lib.length (lib.filter (m: m.primary) config.monitors)) == 1); + message = "Exactly one monitor must be set to primary."; + } + ]; + }; +} diff --git a/modules/home-manager/shellcolor.nix b/modules/home-manager/shellcolor.nix new file mode 100644 index 0000000..739edb4 --- /dev/null +++ b/modules/home-manager/shellcolor.nix @@ -0,0 +1,85 @@ +# https://github.com/Misterio77/nix-config/blob/63850798c0216eee77a09958236e0608c8cab023/modules/home-manager/shellcolor.nix +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.programs.shellcolor; + package = pkgs.shellcolord; + + renderSetting = key: value: '' + ${key}=${value} + ''; + renderSettings = settings: lib.concatStrings (lib.mapAttrsToList renderSetting settings); +in { + options.programs.shellcolor = { + enable = lib.mkEnableOption "shellcolor"; + + enableBashIntegration = lib.mkOption { + default = true; + type = lib.types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + enableZshIntegration = lib.mkOption { + default = true; + type = lib.types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + + enableBashSshFunction = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + Whether to enable SSH integration by replacing ssh with a bash function. + ''; + }; + settings = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = {}; + example = lib.literalExpression '' + { + base00 = "000000"; + base05 = "ffffff"; + } + ''; + description = '' + Options for shellcolord config file. Colors (without leading #) + from base00 until base0F. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [package]; + + xdg.configFile."shellcolor.conf" = lib.mkIf (cfg.settings != {}) { + text = renderSettings cfg.settings; + onChange = '' + timeout 1 ${package}/bin/shellcolor apply || true + ''; + }; + + programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration ( + lib.mkBefore '' + ${package}/bin/shellcolord $$ & disown + ${lib.optionalString cfg.enableBashSshFunction '' + ssh() { + ${package}/bin/shellcolor disable $$ + command ssh "$@" + ${package}/bin/shellcolor enable $$ + ${package}/bin/shellcolor apply $$ + } + ''} + '' + ); + programs.zsh.initExtra = lib.mkIf cfg.enableZshIntegration ( + lib.mkBefore '' + ${package}/bin/shellcolord $$ & disown + '' + ); +} diff --git a/modules/home-manager/wallpaper.nix b/modules/home-manager/wallpaper.nix new file mode 100644 index 0000000..6de0990 --- /dev/null +++ b/modules/home-manager/wallpaper.nix @@ -0,0 +1,11 @@ +{lib, ...}: let + inherit (lib) types mkOption; +in { + options.wallpaper = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Wallpaper path + ''; + }; +} diff --git a/modules/home-manager/yubikey-touch-detector.nix b/modules/home-manager/yubikey-touch-detector.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/starship/default.nix b/modules/starship/default.nix new file mode 100644 index 0000000..aa649d6 --- /dev/null +++ b/modules/starship/default.nix @@ -0,0 +1,14 @@ +starship.enable = true; + starship.settings = { + aws.disabled = true; + gcloud.disabled = true; + kubernetes.disabled = false; + git_branch.style = "242"; + directory.style = "blue"; + directory.truncate_to_repo = false; + directory.truncation_length = 8; + python.disabled = true; + ruby.disabled = true; + hostname.ssh_only = false; + hostname.style = "bold green"; + }; diff --git a/modules/zsh/default.nix b/modules/zsh/default.nix new file mode 100644 index 0000000..120abb7 --- /dev/null +++ b/modules/zsh/default.nix @@ -0,0 +1,94 @@ +{ pkgs, lib, config, ... }: +with lib; +let cfg = config.modules.zsh; +in { + options.modules.zsh = { enable = mkEnableOption "zsh"; }; + + config = mkIf cfg.enable { + home.packages = [ + pkgs.zsh + ]; + + programs.zsh = { + enable = true; + + # directory to put config files in + dotDir = ".config/zsh"; + + enableCompletion = true; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + + # .zshrc + initExtra = '' + PROMPT="%F{blue}%m %~%b "$'\n'"%(?.%F{green}%Bλ%b |.%F{red}?) %f" + + export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store"; + export ZK_NOTEBOOK_DIR="~/stuff/notes"; + export DIRENV_LOG_FORMAT=""; + bindkey '^ ' autosuggest-accept + + # zoxide + eval "$(zoxide init zsh)" + + edir() { tar -cz $1 | age -p > $1.tar.gz.age && rm -rf $1 &>/dev/null && echo "$1 encrypted" } + ddir() { age -d $1 | tar -xz && rm -rf $1 &>/dev/null && echo "$1 decrypted" } + ''; + + # basically aliases for directories: + # `cd ~dots` will cd into ~/.config/nixos + dirHashes = { + dots = "$HOME/.config/nixos"; + stuff = "$HOME/stuff"; + media = "/run/media/$USER"; + junk = "$HOME/stuff/other"; + }; + + # Tweak settings for history + history = { + save = 1000; + size = 1000; + path = "$HOME/.cache/zsh_history"; + }; + + # Set some aliases + shellAliases = { + gc = "nix-collect-garbage --delete-old"; + refresh = "source ${config.home.homeDirectory}/.zshrc"; + show_path = "echo $PATH | tr ':' '\n'"; + c = "clear"; + mkdir = "mkdir -vp"; + rm = "rm -rifv"; + mv = "mv -iv"; + cp = "cp -riv"; + cat = "bat --paging=never --style=plain"; + ls = "exa -a --icons"; + tree = "exa --tree --icons"; + nd = "nix develop -c $SHELL"; + rebuild = "doas nixos-rebuild switch --flake $NIXOS_CONFIG_DIR --fast; notify-send 'Rebuild complete\!'"; + }; + + # Source all plugins, nix-style + plugins = [ + { + name = "auto-ls"; + src = pkgs.fetchFromGitHub { + owner = "notusknot"; + repo = "auto-ls"; + rev = ""; + sha256 = ""; + }; + }; + # { + # name = "" + # src = pkgs.fetchFromGitHub { + # owner = ""; + # repo = ""; + # rev = ""; + # sha256 = ""; + # } + # } + ]; + }; +}; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..669bd73 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,26 @@ +# +# This file defines overlays/custom modifications to upstream packages +# + +{ inputs, ... }: { + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs { pkgs = final; }; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: let ... in { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/pkgs/colorschemes/default.nix b/pkgs/colorschemes/default.nix new file mode 100644 index 0000000..3c08df8 --- /dev/null +++ b/pkgs/colorschemes/default.nix @@ -0,0 +1,8 @@ +#https://github.com/Misterio77/nix-config/tree/63850798c0216eee77a09958236e0608c8cab023/pkgs/colorschemes +{ + pkgs, + wallpapers, + generateColorscheme, + ... +}: +pkgs.lib.mapAttrs (_: v: generateColorscheme v.name v) wallpapers diff --git a/pkgs/colorschemes/generator.nix b/pkgs/colorschemes/generator.nix new file mode 100644 index 0000000..656cecb --- /dev/null +++ b/pkgs/colorschemes/generator.nix @@ -0,0 +1,52 @@ +{pkgs, ...}: let + inherit (pkgs) lib; + matugen = import (fetchTarball { + url = "https://github.com/InioX/matugen/archive/3040fe974b94bc70b49e6c3b868a8eb1c7b294a3.tar.gz"; + sha256 = "sha256:0v7np4294fzwxmgf7pjcxvky63lrq1ajim1b8ywbp47wy9k0pcgs"; + }) {inherit pkgs;}; + generateColorscheme = name: source: let + schemeTypes = ["content" "expressive" "fidelity" "fruit-salad" "monochrome" "neutral" "rainbow" "tonal-spot"]; + isHexColor = c: lib.isString c && (builtins.match "#([0-9a-fA-F]{3}){1,2}" c) != null; + + config = (pkgs.formats.toml {}).generate "config.toml" { + templates = {}; + config = { + colors_to_harmonize = { + light-red = "#d03e3e"; + light-orange = "#d7691d"; + light-yellow = "#ad8200"; + light-green = "#31861f"; + light-cyan = "#00998f"; + light-blue = "#3173c5"; + light-magenta = "#9e57c2"; + dark-red = "#e15d67"; + dark-orange = "#fc804e"; + dark-yellow = "#e1b31a"; + dark-green = "#5db129"; + dark-cyan = "#21c992"; + dark-blue = "#00a3f2"; + dark-magenta = "#b46ee0"; + }; + }; + }; + in + pkgs.runCommand "colorscheme-${name}" { + __contentAddressed = true; + passthru = let + drv = generateColorscheme name source; + in { + inherit schemeTypes; + # Incurs IFD + imported = lib.genAttrs schemeTypes (scheme: lib.importJSON "${drv}/${scheme}.json"); + }; + } '' + mkdir "$out" -p + for type in ${lib.concatStringsSep " " schemeTypes}; do + ${matugen}/bin/matugen ${ + if (isHexColor source) + then "color hex" + else "image" + } --config ${config} -j hex -t "scheme-$type" "${source}" > "$out/$type.json" + done + ''; +in generateColorscheme diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..4ad4110 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,22 @@ +{pkgs ? import {}}: let + inherit (pkgs) lib; +in rec { + # Personal scripts + nix-inspect = pkgs.callPackage ./nix-inspect {}; + + # My slightly customized plymouth theme, just makes the blue outline white + plymouth-spinner-monochrome = pkgs.callPackage ./plymouth-spinner-monochrome {}; + + # My wallpaper collection + wallpapers = import ./wallpapers {inherit pkgs;}; + allWallpapers = pkgs.linkFarmFromDrvs "wallpapers" (lib.attrValues wallpapers); + + # And colorschemes based on it + generateColorscheme = import ./colorschemes/generator.nix {inherit pkgs;}; + colorschemes = import ./colorschemes {inherit pkgs wallpapers generateColorscheme;}; + allColorschemes = let + # This is here to help us keep IFD cached (hopefully) + combined = pkgs.writeText "colorschemes.json" (builtins.toJSON (lib.mapAttrs (_: drv: drv.imported) colorschemes)); + in + pkgs.linkFarmFromDrvs "colorschemes" (lib.attrValues colorschemes ++ [combined]); +} diff --git a/pkgs/hyprland-xdg-portal/flake.nix b/pkgs/hyprland-xdg-portal/flake.nix new file mode 100644 index 0000000..21dd21b --- /dev/null +++ b/pkgs/hyprland-xdg-portal/flake.nix @@ -0,0 +1,29 @@ +{ + pkgs = import {}; + + # Dependencies (replace if versions differ) + deps = pkgs.stdenv + pkgs.libdrm + pkgs.sdbus + pkgs.wayland + pkgs.pipewire; + + # Build xdg-desktop-portal-hyprland (adjust as needed) + xdgDesktopPortalHyprland = pkgs.buildPackage { + name = "xdg-desktop-portal-hyprland"; + src = pkgs.fetchFromGitHub { + rev = "v0.5.2"; # Replace with desired version + owner = "hyprwm"; + repo = "xdg-desktop-portal-hyprland"; + }; + buildInputs = deps; + meta = with pkgs; in { + # Set installation paths (optional, adjust as needed) + buildInputs = pkgs.lib.make (deps ++ [ stdenv.cc ]); + installPhase = pkgs.mkDerivation { + name = "xdg-desktop-portal-hyprland-install"; + buildInputs = with pkgs; in deps ++ [ buildInputs ]; + shellHook = '' + cp -r ${src}/build/lib ${pkgs.lib}/ + cp -r ${src}/build/include ${pkgs.lib.include}/xdg-desktop-portal-hyprland + ''; + }; + }; + }; +} diff --git a/pkgs/name/default.nix b/pkgs/name/default.nix new file mode 100644 index 0000000..ce44ee8 --- /dev/null +++ b/pkgs/name/default.nix @@ -0,0 +1,37 @@ +{ lib, stdenv, fetchgit }: +let + pname = "cd-gitroot"; + install_path = "share/zsh/${pname}"; +in +stdenv.mkDerivation { + inherit pname; + version = "66f6ba7549b9973eb57bfbc188e29d2f73bf31bb"; + src = fetchgit { + url = "https://github.com/mollifier/cd-gitroot"; + hash = "sha256-pLdF8wbkA9mPI5cg8VPYAW7i3cWNJX3+lfAZ5cZPUgE="; + }; + strictDeps = true; + dontBuild = true; + buildInputs = [ ]; + installPhase = '' + install -m755 -D cd-gitroot.plugin.zsh --target-directory $out/${install_path}/ + install -m755 -D cd-gitroot --target-directory $out/${install_path}/ + install -m755 -D _cd-gitroot --target-directory $out/share/zsh/site-functions/ + ''; + meta = with lib; { + homepage = "https://github.com/mollifier/cd-gitroot"; + license = licenses.mit; + longDescription = ''zsh plugin to change directory to git repository root directory. + You can add the following to your `programs.zsh.plugins` list: + ```nix + programs.zsh.plugins = [ + { + name = "${pname}"; + src = "''${pkgs.${pname}}/${install_path}"; + } + ]; + ``` + ''; + maintainers = with maintainers; [ fidgetingbits ]; + }; +} diff --git a/pkgs/plymouth-custom/default.nix b/pkgs/plymouth-custom/default.nix new file mode 100644 index 0000000..16b045f --- /dev/null +++ b/pkgs/plymouth-custom/default.nix @@ -0,0 +1,23 @@ +{ + stdenv, + logo ? null, + lib, + ... +}: +stdenv.mkDerivation { + pname = "plymouth-custom"; + version = "1.0"; + src = ./src; + + buildPhase = lib.optionalString (logo != null) '' + ln -s ${logo} watermark.png + ''; + installPhase = '' + mkdir -p $out/share/plymouth/themes + cp -rT . $out/share/plymouth/themes/spinner-monochrome + ''; + + meta = { + platforms = lib.platforms.all; + }; +} diff --git a/scripts/bootstrap-nixos.sh b/scripts/bootstrap-nixos.sh new file mode 100644 index 0000000..e5f1c71 --- /dev/null +++ b/scripts/bootstrap-nixos.sh @@ -0,0 +1,281 @@ +#!/usr/bin/env bash +set -eo pipefail + +# User variables +config_location="git://git@git.mattmor.in/org/nix/os-config.git" +target_hostname="" +target_destination="" +target_user="ta" +ssh_key="" +ssh_port="22" +remote_passwd="nixos" +persist_dir="" +# Create a temp directory for generated host keys +temp=$(mktemp -d) + +# Cleanup temporary directory on exit +function cleanup() { + rm -rf "$temp" +} +trap cleanup exit + + +function red() { + echo -e "\x1B[31m[!] $1 \x1B[0m" + if [ -n "${2-}" ]; then + echo -e "\x1B[31m[!] $($2) \x1B[0m" + fi +} +function green() { + echo -e "\x1B[32m[+] $1 \x1B[0m" + if [ -n "${2-}" ]; then + echo -e "\x1B[32m[+] $($2) \x1B[0m" + fi +} +function yellow() { + echo -e "\x1B[33m[*] $1 \x1B[0m" + if [ -n "${2-}" ]; then + echo -e "\x1B[33m[*] $($2) \x1B[0m" + fi +} + +function yes_or_no() { + while true; do + read -rp "$* [y/n] (default: y): " yn + yn=${yn:-y} + case $yn in + [Yy]*) return 0 ;; + [Nn]*) return 1 ;; + esac + done +} + +function sync() { + # $1 = user, $2 = source, $3 = destination + rsync -av --filter=':- .gitignore' -e "ssh -l $1" "$2" "$1"@"${target_destination}": +} + +function help_and_exit() { + echo + echo "Remotely installs NixOS on a target machine using this nix-config." + echo + echo "USAGE: $0 -n= -d= -k= [OPTIONS]" + echo + echo "ARGS:" + echo " -n= specify target_hostname of the target host to deploy the nixos config on." + echo " -d= specify ip or url to the target host." + echo " -k= specify the full path to the ssh_key you'll use for remote access to the" + echo " target during install process." + echo " Example: -k=/home/${target_user}/.ssh/my_ssh_key" + echo + echo "OPTIONS:" + echo " -u= specify target_user with sudo access. nix-config will be cloned to their home." + echo " Default='${target_user}'." + echo " -p= Specify a password for target machine user. This is temporary until install is complete." + echo " Default='${remote_passwd}'." + echo " --port= specify the ssh port to use for remote access. Default=${ssh_port}." + echo " --impermanence Use this flag if the target machine has impermanence enabled. WARNING: Assumes /persist path." + echo " --debug Enable debug mode." + echo " -h | --help Print this help." + exit 0 +} + +# Handle command-line arguments +while [[ $# -gt 0 ]]; do + case "$1" in + -n=*) + target_hostname="${1#-n=}" + ;; + -d=*) + target_destination="${1#-d=}" + ;; + -u=*) + target_user="${1#-u=}" + ;; + -k=*) + ssh_key="${1#-k=}" + ;; + -p=*) + remote_passwd="${1#-p=}" + ;; + --port=*) + ssh_port="${1#--port=}" + ;; + --temp-override=*) + temp="${1#--temp-override=}" + ;; + --impermanence) + persist_dir="/persist" + ;; + --debug) + set -x + ;; + -h | --help) help_and_exit ;; + *) + echo "Invalid option detected." + help_and_exit + ;; + esac + shift +done + +# SSH commands +ssh_cmd="ssh -oport=${ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i $ssh_key -t $target_user@$target_destination" +ssh_root_cmd=$(echo "$ssh_cmd" | sed "s|${target_user}@|root@|") # uses @ in the sed switch to avoid it triggering on the $ssh_key value +scp_cmd="scp -oport=${ssh_port} -o StrictHostKeyChecking=no -i $ssh_key" + +function nixos_anywhere() { + green "Installing NixOS on remote host $target_hostname at $target_destination" + + ### + # nixos-anywhere extra-files generation + ### + green "Preparing a new ssh_host_ed25519_key pair for $target_hostname." + # Create the directory where sshd expects to find the host keys + install -d -m755 "$temp/$persist_dir/etc/ssh" + + # Generate host keys without a passphrase + ssh-keygen -t ed25519 -f "$temp/$persist_dir/etc/ssh/ssh_host_ed25519_key" -C root@"$target_hostname" -N "" + # ssh-keygen -t ed25519 -f "$temp/$persist_dir/etc/ssh/ssh_host_ed25519_key" -C "$target_user"@"$target_hostname" -N "" + + # Set the correct permissions so sshd will accept the key + chmod 600 "$temp/$persist_dir/etc/ssh/ssh_host_ed25519_key" + + echo "Adding ssh host fingerprint at $target_destination to ~/.ssh/known_hosts" + # This will fail if we already know the host, but that's fine + ssh-keyscan -p "$ssh_port" "$target_destination" >>~/.ssh/known_hosts || true + + ### + # nixos-anywhere installation + ### + cd nixos-installer + + # disko expects a passphrase on /tmp/disko-password, so we set it for now and will update the passphrase later + green "Preparing a temporary password for disko." + $ssh_root_cmd "/bin/sh -c 'echo passphrase > /tmp/disko-password'" + + # copy our repo there via rsync for speed + green "Syncing nix-config to $target_hostname" + sync root "$PWD" + $ssh_root_cmd "nixos-generate-config --no-filesystems --root /mnt" + $scp_cmd root@"$target_destination":/mnt/etc/nixos/hardware-configuration.nix ../hosts/"$target_hostname"/hardware-configuration.nix + sync root "$PWD" + + # --extra-files here picks up the ssh host key we generated earlier and puts it onto the target machine + # FIXME: Double check that it will delete them? + SHELL=/bin/sh nix run github:nix-community/nixos-anywhere -- --ssh-port "$ssh_port" --extra-files "$temp" --flake .#"$target_hostname" root@"$target_destination" + + echo "Updating ssh host fingerprint at $target_destination to ~/.ssh/known_hosts" + # This will fail if we already know the host, but that's fine + ssh-keyscan -p "$ssh_port" "$target_destination" >>~/.ssh/known_hosts || true + + # FIXME: Do we need this? I get errors: + # /etc/tmpfiles.d/journal-nocow.conf:26: Failed to resolve specifier: uninitialized /etc/ detected, skipping. + # And there is no /etc/machine-id after first rebuild... + if [ -n "$persist_dir" ]; then + $ssh_root_cmd "cp /etc/machine-id $persist_dir/etc/machine-id || true" + $ssh_root_cmd "cp -R /etc/ssh/ $persist_dir/etc/ssh/ || true" + fi + cd - +} + +function generate_age_keys() { + green "Generating an age key based on the new ssh_host_ed25519_key." + + target_key=$(ssh-keyscan -p "$ssh_port" -t ssh-ed25519 "$target_destination" 2>&1 | rg ssh-ed25519 | cut -f2- -d" ") + age_key=$(nix shell nixpkgs#ssh-to-age.out -c sh -c "echo $target_key | ssh-to-age") + + if grep -qv '^age1' <<<"$age_key"; then + red "The result from generated age key does not match the expected format." + yellow "Result: $age_key" + yellow "Expected format: age10000000000000000000000000000000000000000000000000000000000" + exit 1 + else + echo "$age_key" + fi + + green "Updating nix-secrets/.sops.yaml" + cd ../nix-secrets + + SOPS_FILE=".sops.yaml" + sed -i "{ + # Remove any * and & entries for this host + /[*&]$target_hostname/ d; + # Inject a new age: entry + # n matches the first line following age: and p prints it, then we transform it while reusing the spacing + /age:/{n; p; s/\(.*- \*\).*/\1$target_hostname/}; + # Inject a new hosts: entry + /&hosts:/{n; p; s/\(.*- &\).*/\1$target_hostname $age_key/} + }" $SOPS_FILE + + green "Updating nix-secrets/.sops.yaml" + cd - + just rekey + + green "Updating flake lock on source machine with new .sops.yaml info" + nix flake lock --update-input nix-secrets +} + + +# Validate required options +if [ -z "${target_hostname}" ] || [ -z "${target_destination}" ] || [ -z "${ssh_key}" ]; then + red "ERROR: -n, -d, and -k are all required" + echo + help_and_exit +fi + +# Clear the keys, since they should be newly generated for the iso +green "Wiping known_hosts of $target_destination" +sed -i "/$target_hostname/d; /$target_destination/d" ~/.ssh/known_hosts + +if yes_or_no "Do you want to run nixos-anywhere installation?"; then + nixos_anywhere +fi + +if yes_or_no "Do you want to run age key generation?"; then + generate_age_keys +fi + +if yes_or_no "Do you want to add ssh host fingerprints for gitlab and github? If this is the first time running this script on $target_hostname, this will be required for the following steps?"; then + if [ "$target_user" == "root" ]; then + home_path="/root" + else + home_path="/home/$target_user" + fi + green "Adding ssh host fingerprints for gitlab and github" + $ssh_cmd "mkdir -p $home_path/.ssh/; ssh-keyscan -t ssh-ed25519 gitlab.com github.com >>$home_path/.ssh/known_hosts" +fi + +if yes_or_no "Do you want to copy your full nix-config and private keys to $target_hostname?"; then + echo "Adding ssh host fingerprint at $target_destination to ~/.ssh/known_hosts" + # This will fail if we already know the host, but that's fine + ssh-keyscan -p "$ssh_port" "$target_destination" >>~/.ssh/known_hosts || true + green "Copying full nix-config to $target_hostname" + sync "$target_user" "$PWD" + green "Copying full nix-secrets to $target_hostname" + sync "$target_user" ../nix-secrets + + if yes_or_no "Do you want to rebuild immediately?"; then + green "Rebuilding nix-config on $target_hostname" + $ssh_cmd "cd nix-config && sudo nixos-rebuild --show-trace switch --flake .#$target_hostname" + fi +else + echo + green "NixOS was succcefully installed!" + echo "Post-install config build instructions:" + echo "To copy nix-config from this machine to the $target_hostname, run the following command from ~/nix-config" + echo "just sync $target_user $target_destination" + echo "To rebuild, sign into $target_hostname and run the following command from ~/nix-config" + echo "cd nix-config" + echo "just rebuild" + echo +fi + +if yes_or_no "You can now commit and push the nix-config, which includes the hardware-configuration.nix for $target_hostname?"; then + (pre-commit run --all-files 2>/dev/null || true) && + git add hosts/"$target_hostname"/hardware-configuration.nix && (git commit -m "feat: hardware-configuration.nix for $target_hostname" || true) && git push +fi + +#TODO prune all previous generations? + +green "Success!" diff --git a/scripts/check-sops.sh b/scripts/check-sops.sh new file mode 100644 index 0000000..58221d8 --- /dev/null +++ b/scripts/check-sops.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +# FIXME: Make this better +sops_result=$(journalctl --no-pager --no-hostname --since "10 minutes ago" | + tac | + awk '!flag; /Starting sops-nix activation/{flag = 1};' | + tac | + grep sops) + +# If we don't have "Finished sops-nix activation." in the logs, then we failed +if [[ ! $sops_result =~ "Finished sops-nix activation" ]]; then + echo "sops-nix failed to activate" + echo "$sops_result" + exit 1 +fi diff --git a/scripts/system-flake-rebuild-trace.sh b/scripts/system-flake-rebuild-trace.sh new file mode 100644 index 0000000..aa3bb08 --- /dev/null +++ b/scripts/system-flake-rebuild-trace.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if [ ! -z $1 ]; then + export HOST=$1 +else + export HOST=$(hostname) +fi + +sudo nixos-rebuild --show-trace --impure --flake .#$HOST switch diff --git a/scripts/system-flake-rebuild.sh b/scripts/system-flake-rebuild.sh new file mode 100644 index 0000000..8e14ae0 --- /dev/null +++ b/scripts/system-flake-rebuild.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if [ ! -z $1 ]; then + export HOST=$1 +else + export HOST=$(hostname) +fi + +sudo nixos-rebuild --impure --flake .#$HOST switch diff --git a/scripts/system-install.sh b/scripts/system-install.sh new file mode 100644 index 0000000..d48c5d4 --- /dev/null +++ b/scripts/system-install.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if [ -e $1 ]; then + HOST=$1 +else + HOST=$(hostname) +fi + +sudo nixos-rebuild --flake .#$HOST install diff --git a/scripts/system-rebuild.sh b/scripts/system-rebuild.sh new file mode 100644 index 0000000..00d0374 --- /dev/null +++ b/scripts/system-rebuild.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo nixos-rebuild switch -I nixos-config=configuration.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..424425a --- /dev/null +++ b/shell.nix @@ -0,0 +1,35 @@ +#################### DevShell #################### +# +# Custom shell for bootstrapping on new hosts, modifying nix-config, and secrets management + +{ pkgs ? # If pkgs is not defined, instantiate nixpkgs from locked commit + let + lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; + nixpkgs = fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; + sha256 = lock.narHash; + }; + in + import nixpkgs { overlays = [ ]; } +, ... +}: { + default = pkgs.mkShell { + NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake"; + nativeBuildInputs = builtins.attrValues { + inherit (pkgs) + # Required for pre-commit hook 'nixpkgs-fmt' only on Darwin + # REF: + libiconv + + nix + home-manager + git + just + pre-commit + + age + ssh-to-age + sops; + }; + }; +} diff --git a/systems/common/core/auto-upgrade.nix b/systems/common/core/auto-upgrade.nix new file mode 100644 index 0000000..8c28236 --- /dev/null +++ b/systems/common/core/auto-upgrade.nix @@ -0,0 +1,35 @@ +{ + config, + inputs, + pkgs, + lib, + ... +}: let + inherit (config.networking) hostName; + # Only enable auto upgrade if current config came from a clean tree + # This avoids accidental auto-upgrades when working locally. + isClean = inputs.self ? rev; +in { + system.autoUpgrade = { + enable = isClean; + dates = "hourly"; + flags = [ + "--refresh" + ]; + # flake = "git://m7.rs/nix-config?ref=release-${hostName}"; + # TODO: public? + flake = "git://git.mattmor.in/Madmin/nix-config-priv"; + }; + + # Only run if current config (self) is older than the new one. + systemd.services.nixos-upgrade = lib.mkIf config.system.autoUpgrade.enable { + serviceConfig.ExecCondition = lib.getExe ( + pkgs.writeShellScriptBin "check-date" '' + lastModified() { + nix flake metadata "$1" --refresh --json | ${lib.getExe pkgs.jq} '.lastModified' + } + test "$(lastModified "${config.system.autoUpgrade.flake}")" -gt "$(lastModified "self")" + '' + ); + }; +} diff --git a/systems/common/core/default.nix b/systems/common/core/default.nix new file mode 100644 index 0000000..b88aac0 --- /dev/null +++ b/systems/common/core/default.nix @@ -0,0 +1,64 @@ +# This file (and the global directory) holds config that i use on all hosts +{ + inputs, + outputs, + ... +}: { + imports = + [ + inputs.home-manager.nixosModules.home-manager + ./acme.nix + ./auto-upgrade.nix + ./fish.nix + ./locale.nix + ./nix.nix + ./openssh.nix + ./optin-persistence.nix + ./podman.nix + ./sops.nix + ./ssh-serve-store.nix + ./steam-hardware.nix + ./systemd-initrd.nix + ./tailscale.nix + ./gamemode.nix + ./nix-ld.nix + ./prometheus-node-exporter.nix + ] + ++ (builtins.attrValues outputs.nixosModules); + + home-manager.extraSpecialArgs = { + inherit inputs outputs; + }; + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays; + config = { + allowUnfree = true; + }; + }; + + # Fix for qt6 plugins + # TODO: maybe upstream this? + environment.profileRelativeSessionVariables = { + QT_PLUGIN_PATH = ["/lib/qt-6/plugins"]; + }; + + hardware.enableRedistributableFirmware = true; + networking.domain = "m7.rs"; + + # Increase open file limit for sudoers + security.pam.loginLimits = [ + { + domain = "@wheel"; + item = "nofile"; + type = "soft"; + value = "524288"; + } + { + domain = "@wheel"; + item = "nofile"; + type = "hard"; + value = "1048576"; + } + ]; +} diff --git a/systems/common/core/foot.nix b/systems/common/core/foot.nix new file mode 100644 index 0000000..bde8d1d --- /dev/null +++ b/systems/common/core/foot.nix @@ -0,0 +1,96 @@ +{ + pkgs, + theme, + ... +}: { + home.packages = with pkgs; [ + libsixel + # for displaying images + ]; + programs.foot = { + enable = true; + server.enable = false; + settings = { + main = { + app-id = "foot"; + title = "foot"; + locked-title = "no"; + term = "xterm-256color"; + font = "Geist Mono:size=10.5"; + vertical-letter-offset = "-0.75"; + pad = "12x21 center"; + resize-delay-ms = 100; + notify = "notify-send -a \${app-id} -i \${app-id} \${title} \${body}"; + selection-target = "primary"; + # box-drawings-uses-font-glyphs = "yes"; + dpi-aware = "yes"; + bold-text-in-bright = "no"; + word-delimiters = ",│`|:\"'()[]{}<>"; + }; + cursor = { + style = "beam"; + beam-thickness = 2; + }; + scrollback = { + lines = 10000; + multiplier = 3; + }; + + bell = { + urgent = "yes"; + notify = "yes"; + command = "notify-send bell"; + command-focused = "no"; + }; + url = { + launch = "xdg-open \${url}"; + label-letters = "sadfjklewcmpgh"; + osc8-underline = "url-mode"; + protocols = "http, https, ftp, ftps, file, gemini, gopher, irc, ircs"; + + uri-characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,~:;/?#@!$&%*+=\"'()[]"; + }; + colors = with theme.colors; { + alpha = "0.75"; + foreground = text; + background = base; + + regular0 = surface1; + regular1 = red; + regular2 = green; + regular3 = yellow; + regular4 = blue; + regular5 = pink; + regular6 = teal; + regular7 = subtext1; + + bright0 = surface2; + bright1 = red; + bright2 = green; + bright3 = yellow; + bright4 = blue; + bright5 = pink; + bright6 = teal; + bright7 = subtext0; + }; + mouse = { + hide-when-typing = "yes"; + }; + key-bindings = { + show-urls-launch = "Control+Shift+u"; + unicode-input = "Control+Shift+i"; + }; + mouse-bindings = { + selection-override-modifiers = "Shift"; + primary-paste = "BTN_MIDDLE"; + select-begin = "BTN_LEFT"; + select-begin-block = "Control+BTN_LEFT"; + select-extend = "BTN_RIGHT"; + select-extend-character-wise = "Control+BTN_RIGHT"; + select-word = "BTN_LEFT-2"; + select-word-whitespace = "Control+BTN_LEFT-2"; + #select-row = "BTN_LEFT-3"; + }; + }; + }; +} diff --git a/systems/common/core/hyprland/default.nix b/systems/common/core/hyprland/default.nix new file mode 100644 index 0000000..5971c2f --- /dev/null +++ b/systems/common/core/hyprland/default.nix @@ -0,0 +1,23 @@ +{ + + programs.hyprland = { + enable = true; + nvidiaPatches = true; + xwayland.enable = true; + }; + + environment.sessionVariables = { + If # your cursor becomes invisible + WLR_NO_HARDWARE_CURSORS = "1"; + # Hint electron apps to use wayland + NIXOS_OZONE_WL = "1"; + }; + + hardware = { + Opengl + opengl.enable = true; + + # Most wayland compositors need this + nvidia.modesetting.enable = true; + }; +} diff --git a/systems/common/core/hyprland/somemodule.nix b/systems/common/core/hyprland/somemodule.nix new file mode 100644 index 0000000..e69de29 diff --git a/systems/common/core/nix-ld.nix b/systems/common/core/nix-ld.nix new file mode 100644 index 0000000..10f50a4 --- /dev/null +++ b/systems/common/core/nix-ld.nix @@ -0,0 +1,6 @@ +# https://github.com/Mic92/nix-ld +{ + programs.nix-ld = { + enable = true; + }; +} diff --git a/systems/common/core/nix.nix b/systems/common/core/nix.nix new file mode 100644 index 0000000..f84ca62 --- /dev/null +++ b/systems/common/core/nix.nix @@ -0,0 +1,61 @@ +{ + inputs, + lib, + pkgs, + ... +}: { + nix = { + # https://github.com/NixOS/nix/issues/9579 + # https://github.com/NixOS/nix/pull/9547 + package = pkgs.inputs.nix.nix; + + # Add each flake input as a registry + # To make nix3 commands consistent with the flake + registry = lib.mapAttrs (_: value: {flake = value;}) inputs; + + + # This will add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + settings = { + substituters = lib.mkAfter ["https://cache.great-hyperlobic-omnicognate-neutron-wrangler.space"]; + trusted-public-keys = ["cache.great-hyperlobic-omnicognate-neutron-wrangler.space:kszZ/NSwE/TjhOcPPQ16IuUiuRSisdiIwhKZCxguaWg="]; #TODO: Setup cache and change this + trusted-users = [ + "root" + "@wheel" + ]; + # Deduplicate and optimize nix store + auto-optimise-store = lib.mkDefault true; + + experimental-features = [ + "nix-command" + "flakes" + "repl-flake" + "ca-derivations" + ]; + + # See https://jackson.dev/post/nix-reasonable-defaults/ + connect-timeout = 5; + log-lines = 25; + min-free = 128000000; # 128MB + max-free = 1000000000; # 1GB + + warn-dirty = false; + system-features = [ + "kvm" + "big-parallel" + "nixos-test" + ]; + flake-registry = ""; # Disable global flake registry + }; + + # garbage collection + gc = { + automatic = true; + dates = "weekly"; + # Keep the last 3 generations + options = "--delete-older-than +3"; + }; + }; +} diff --git a/systems/common/core/services/auto-upgrade.nix b/systems/common/core/services/auto-upgrade.nix new file mode 100644 index 0000000..e932fde --- /dev/null +++ b/systems/common/core/services/auto-upgrade.nix @@ -0,0 +1,29 @@ +{ config, inputs, pkgs, lib, ... }: +let + inherit (config.networking) hostName; + # Only enable auto upgrade if current config came from a clean tree + # This avoids accidental auto-upgrades when working locally. + isClean = inputs.self ? rev; +in +{ + system.autoUpgrade = { + enable = isClean; + dates = "hourly"; + flags = [ + "--refresh" + ]; + flake = "git://github.com/EmergentMind/nix-config?ref=release-${hostName}"; + }; + + # Only run if current config (self) is older than the new one. + systemd.services.nixos-upgrade = lib.mkIf config.system.autoUpgrade.enable { + serviceConfig.ExecCondition = lib.getExe ( + pkgs.writeShellScriptBin "check-date" '' + lastModified() { + nix flake metadata "$1" --refresh --json | ${lib.getExe pkgs.jq} '.lastModified' + } + test "$(lastModified "${config.system.autoUpgrade.flake}")" -gt "$(lastModified "self")" + '' + ); + }; +} diff --git a/systems/common/core/services/default.nix b/systems/common/core/services/default.nix new file mode 100644 index 0000000..6ad8626 --- /dev/null +++ b/systems/common/core/services/default.nix @@ -0,0 +1,2 @@ +# FIXME this is intentionally empty and is a hack to get configLib.scanPaths not to barf when default.nix doesn't exist in this dir. Need to modify +{} diff --git a/systems/common/core/sops.nix b/systems/common/core/sops.nix new file mode 100644 index 0000000..4f05cb1 --- /dev/null +++ b/systems/common/core/sops.nix @@ -0,0 +1,72 @@ +# hosts level sops. see home/[user]/common/optional/sops.nix for home/user level + +{ pkgs, inputs, config, configVars, ... }: +let + secretsDirectory = builtins.toString inputs.nix-secrets; + + # FIXME: Switch to a configLib function + homeDirectory = + if pkgs.stdenv.isLinux + then "/home/${configVars.username}" + else "/Users/${configVars.username}"; +in +{ + imports = [ + inputs.sops-nix.nixosModules.sops + ]; + + sops = { + defaultSopsFile = "${secretsDirectory}/secrets.yaml"; + validateSopsFiles = false; + + age = { + # automatically import host SSH keys as age keys + sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + # this will use an age key that is expected to already be in the filesystem + keyFile = "/var/lib/sops-nix/key.txt"; + # generate a new key if the key specified above does not exist + generateKey = true; + }; + + # secrets will be output to /run/secrets + # e.g. /run/secrets/msmtp-password + # secrets required for user creation are handled in respective ./users/.nix files + # because they will be output to /run/secrets-for-users and only when the user is assigned to a host. + secrets = { + # For home-manager a separate age key is used to decrypt secrets and must be placed onto the host. This is because + # the user doesn't have read permission for the ssh service private key. However, we can bootstrap the age key from + # the secrets decrypted by the host key, which allows home-manager secrets to work without manually copying over + # the age key. + "age_keys/${config.networking.hostName}" = { + owner = config.users.users.${configVars.username}.name; + inherit (config.users.users.${configVars.username}) group; + # We need to ensure the entire directory structure is that of the user... + path = "${homeDirectory}/.config/sops/age/keys.txt"; + }; + + # ta-password to /run/secrets-for-users/ so it can be used to create the user + "${configVars.username}/password".neededForUsers = true; + + #FIXME move to mstmp.nix and also have host and address being assigned to configVars as per fidgetingbits + msmtp-host = { }; + msmtp-address = { }; + msmtp-password = { }; + + # extract to default pam-u2f authfile location for passwordless sudo. see ../optional/yubikey + "yubico/u2f_keys" = { + path = "/home/${configVars.username}/.config/Yubico/u2f_keys"; + }; + }; + }; + # The containing folders are created as root and if this is the first ~/.config/ entry, + # the ownership is busted and home-manager can't target because it can't write into .config... + # FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed + system.activationScripts.sopsSetAgeKeyOwnwership = let + ageFolder = "${homeDirectory}/.config/sops/age"; + user = config.users.users.${configVars.username}.name; + group = config.users.users.${configVars.username}.group; + in '' + mkdir -p ${ageFolder} || true + chown -R ${user}:${group} ${homeDirectory}/.config + ''; +} diff --git a/systems/common/core/systemd-initrd.nix b/systems/common/core/systemd-initrd.nix new file mode 100644 index 0000000..d395006 --- /dev/null +++ b/systems/common/core/systemd-initrd.nix @@ -0,0 +1 @@ +{boot.initrd.systemd.enable = true;} diff --git a/systems/common/core/zsh.nix b/systems/common/core/zsh.nix new file mode 100644 index 0000000..e69de29 diff --git a/systems/common/optional/pipewire.nix b/systems/common/optional/pipewire.nix new file mode 100644 index 0000000..8a52d93 --- /dev/null +++ b/systems/common/optional/pipewire.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: +{ + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + wireplumber.enable = true; + jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + # media-session.enable = true; + }; + environment.systemPackages = builtins.attrValues { + inherit (pkgs) + pamixer# pulseaudio sound mixer + pavucontrol; # pulseaudio volume control + }; +} diff --git a/systems/common/optional/quietboot.nix b/systems/common/optional/quietboot.nix new file mode 100644 index 0000000..31f2c95 --- /dev/null +++ b/systems/common/optional/quietboot.nix @@ -0,0 +1,31 @@ +{ + pkgs, + config, + ... +}: { + console = { + useXkbConfig = true; + earlySetup = false; + }; + + boot = { + plymouth = { + enable = true; + theme = "spinner-monochrome"; + themePackages = [ + (pkgs.plymouth-spinner-monochrome.override {inherit (config.boot.plymouth) logo;}) + ]; + }; + loader.timeout = 0; + kernelParams = [ + "quiet" + "loglevel=3" + "systemd.show_status=auto" + "udev.log_level=3" + "rd.udev.log_level=3" + "vt.global_cursor_default=0" + ]; + consoleLogLevel = 0; + initrd.verbose = false; + }; +} diff --git a/systems/common/optional/services/clamav.nix b/systems/common/optional/services/clamav.nix new file mode 100644 index 0000000..c20f3b3 --- /dev/null +++ b/systems/common/optional/services/clamav.nix @@ -0,0 +1,77 @@ +# +# FIXME check for dependency somehow? Requires the msmtp.nix option for email notifications +# + +{ pkgs, lib, config, ... }: +let + # FIXME + # isEnabled = name: predicate: { + # assertion = predicate; + # message = "${name} should be enabled for the clamav.nix config to work correctly."; + # }; + + # Function to notify users and admin when a suspicious file is detected + notify-all-users = pkgs.writeScript "notify-all-users-of-sus-file" + '' + #!/usr/bin/env bash + ALERT="Signature detected by clamav: $CLAM_VIRUSEVENT_VIRUSNAME in $CLAM_VIRUSEVENT_FILENAME" + # Send an alert to all graphical users. + for ADDRESS in /run/user/*; do + USERID=''${ADDRESS#/run/user/} + /run/wrappers/bin/sudo -u "#$USERID" DBUS_SESSION_BUS_ADDRESS="unix:path=$ADDRESS/bus" ${pkgs.libnotify}/bin/notify-send -i dialog-warning "Suspicious file" "$ALERT" + done + + echo -e "To:$(hostname).alerts.net@hexagon.cx\n\nSubject: Suspicious file on $(hostname)\n\n$ALERT" | msmtp -a default alerts.net@hexagon.cx + ''; +in +{ + # FIXME + # assertions = lib.mapAttrsToList isEnabled { + # "hosts/common/optional/msmtp" = config.msmtp.enable; + # }; + + security.sudo = { + extraConfig = + '' + clamav ALL = (ALL) NOPASSWD: SETENV: ${pkgs.libnotify}/bin/notify-send + ''; + }; + + services = { + clamav = { + daemon = { + enable = true; + settings = { + # ClamAV configuration. Refer to , for details on supported values. + OnAccessPrevention = false; + OnAccessExtraScanning = true; + OnAccessExcludeUname = "clamav"; + VirusEvent = "${notify-all-users}"; + User = "clamav"; + }; + }; + updater = { + enable = true; + interval = "daily"; + frequency = 2; + settings = { + # Refer to ,for details on supported values. + }; + }; + # # TODO stage 3 checkback - this isn't currently available in stable but looks to be coming down the pipe https://github.com/NixOS/nixpkgs/commits/master/nixos/modules/services/security/clamav.nix + # fangfrisch = { + # enable = true; + # interval = "daily"; + # }; + # scanner = { + # # By default his runs using 10 cores, be sure + # enable = true; + # interval = "*-*-* 04:00:00"; # default + # scanDirectories = [ + # # these are currently defaults from the nixos pkg maintainer for everything he thought was valid for nixos + # "/home" "/var/lib" "/tmp" "/etc" "/var/tmp" + # ]; + # }; + }; + }; +} diff --git a/systems/common/optional/services/openssh.nix b/systems/common/optional/services/openssh.nix new file mode 100644 index 0000000..112b6bb --- /dev/null +++ b/systems/common/optional/services/openssh.nix @@ -0,0 +1,44 @@ +{ lib, config, ... }: +let + #FIXME: switch this to 10022 at some point. leaving it as 22 for now becuase I don't have time + # to add all the required matchblock entries + sshPort = 22; + + # Sops needs access to the keys before the persist dirs are even mounted; so + # just persisting the keys won't work, we must point at /persist + hasOptinPersistence = false; +in + +{ + services.openssh = { + enable = true; + ports = [ sshPort ]; + + settings = { + # Harden + PasswordAuthentication = false; + PermitRootLogin = "no"; + # Automatically remove stale sockets + StreamLocalBindUnlink = "yes"; + # Allow forwarding ports to everywhere + GatewayPorts = "clientspecified"; + }; + + hostKeys = [{ + path = "${lib.optionalString hasOptinPersistence "/persist"}/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + }]; + # Fix LPE vulnerability with sudo use SSH_AUTH_SOCK: https://github.com/NixOS/nixpkgs/issues/31611 + authorizedKeysFiles = lib.mkForce ["/etc/ssh/authorized_keys.d/%u"]; + }; + # yubikey login / sudo + # this potentially causes a security issue that we mitigated above + security.pam = { + sshAgentAuth.enable = true; + services = { + sudo.u2fAuth = true; + }; + }; + + networking.firewall.allowedTCPPorts = [ sshPort ]; +} diff --git a/systems/common/optional/services/sddm.nix b/systems/common/optional/services/sddm.nix new file mode 100644 index 0000000..392141c --- /dev/null +++ b/systems/common/optional/services/sddm.nix @@ -0,0 +1,37 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.autoLogin; +in +{ + # Declare custom options for conditionally enabling auto login + options.autoLogin = { + enable = lib.mkEnableOption "Enable automatic login"; + + username = lib.mkOption { + type = lib.types.str; + default = "guest"; + description = "User to automatically login"; + }; + }; + + config = { + # environment.systemPackages = with pkgs; [ greetd.tuigreet ]; + services.greetd = { + enable = true; + + restart = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --asterisks --time --time-format '%I:%M %p | %a • %h | %F' --cmd Hyprland"; + user = "ta"; + }; + + initial_session = lib.mkIf cfg.enable { + command = "${pkgs.hyprland}/bin/Hyprland"; + user = "${cfg.username}"; + }; + }; + }; + }; +} diff --git a/systems/common/optional/systemdboot.nix b/systems/common/optional/systemdboot.nix new file mode 100644 index 0000000..40d04b2 --- /dev/null +++ b/systems/common/optional/systemdboot.nix @@ -0,0 +1,9 @@ +{ + boot.loader = { + systemd-boot = { + enable = true; + consoleMode = "max"; + }; + efi.canTouchEfiVariables = true; + }; +} diff --git a/systems/common/users/laozi.nix b/systems/common/users/laozi.nix new file mode 100644 index 0000000..5d93449 --- /dev/null +++ b/systems/common/users/laozi.nix @@ -0,0 +1,25 @@ +# +# Basic user for viewing media on gusto +# + +{ pkgs, inputs, config, ... }: +{ + # Decrypt media-password to /run/secrets-for-users/ so it can be used to create the user + sops.secrets.media-password.neededForUsers = true; + users.mutableUsers = false; #Required for password to be set via sops during system activation! + + users.users.${configVars.username} = { + isNormalUser = true; + hashedPasswordFile = config.sops.secrets.media-password.path; + shell = pkgs.zsh; #default shell + extraGroups = [ + "audio" + "video" + ]; + + packages = [ pkgs.home-manager ]; + }; + + # Import this user's personal/home configurations + home-manager.users.media = import ../../../../home/media/${config.networking.hostName}.nix; +} diff --git a/systems/common/users/sunzi.nix b/systems/common/users/sunzi.nix new file mode 100644 index 0000000..82d79ad --- /dev/null +++ b/systems/common/users/sunzi.nix @@ -0,0 +1,36 @@ +{ pkgs, inputs, config, lib, configVars, configLib, ... }: +let + ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; + sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops" inputs) config.sops.secrets."${configVars.username}/password".path; + pubKeys = lib.filesystem.listFilesRecursive (configLib.relativeToRoot "keys/"); +in +{ + # Decrypt ta-password to /run/secrets-for-users/ so it can be used to create the user + sops.secrets."${configVars.username}/password".neededForUsers = true; + users.mutableUsers = false; # Required for password to be set via sops during system activation! + + users.users.${configVars.username} = { + name = configVars.username; + isNormalUser = true; + hashedPasswordFile = sopsHashedPasswordFile; + extraGroups = [ + "wheel" + ] ++ ifTheyExist [ + "audio" + "video" + "docker" + "git" + "networkmanager" + ]; + # These get placed into /etc/ssh/authorized_keys.d/ on nixos + openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key); + + shell = pkgs.zsh; # default shell + + packages = [ pkgs.home-manager ]; + }; + + # Import this user's personal/home configurations + home-manager.users.${configVars.username} = import (configLib.relativeToRoot "home/${configVars.username}/${config.networking.hostName}.nix"); + +} diff --git a/systems/jeroboam/README.md b/systems/jeroboam/README.md new file mode 100644 index 0000000..e69de29 diff --git a/systems/jeroboam/default.nix b/systems/jeroboam/default.nix new file mode 100644 index 0000000..1510c74 --- /dev/null +++ b/systems/jeroboam/default.nix @@ -0,0 +1,21 @@ + +programs.hyprland = { + enable = true; + nvidiaPatches = false; + xwayland.enable = true; +}; + +environment.sessionVariables = { + If # your cursor becomes invisible + WLR_NO_HARDWARE_CURSORS = "1"; + # Hint electron apps to use wayland + NIXOS_OZONE_WL = "1"; +}; + +hardware = { + Opengl + opengl.enable = true; + + # Most wayland compositors need this + nvidia.modesetting.enable = false; +}; diff --git a/systems/rehoboam/README.md b/systems/rehoboam/README.md new file mode 100644 index 0000000..e69de29 diff --git a/systems/rehoboam/default.nix b/systems/rehoboam/default.nix new file mode 100644 index 0000000..0a2939d --- /dev/null +++ b/systems/rehoboam/default.nix @@ -0,0 +1,79 @@ + + +############################################################# +# +# Grief - Dev Lab +# NixOS running on VirtualBox VM +# +############################################################### + +{ inputs, configLib, ... }: { + imports = [ + #################### Hardware Modules #################### + inputs.hardware.nixosModules.common-cpu-amd + inputs.hardware.nixosModules.common-gpu-amd + inputs.hardware.nixosModules.common-pc-ssd + + #################### Required Configs #################### + ./hardware-configuration.nix + (configLib.relativeToRoot "hosts/common/core") + + #################### Host-specific Optional Configs #################### + (configLib.relativeToRoot "hosts/common/optional/yubikey") + (configLib.relativeToRoot "hosts/common/optional/services/clamav.nix") # depends on optional/msmtp.nix + (configLib.relativeToRoot "hosts/common/optional/msmtp.nix") # required for emailing clamav alerts + (configLib.relativeToRoot "hosts/common/optional/services/openssh.nix") + + # Desktop + (configLib.relativeToRoot "hosts/common/optional/services/greetd.nix") # display manager + (configLib.relativeToRoot "hosts/common/optional/hyprland.nix") # window manager + + #################### Users to Create #################### + (configLib.relativeToRoot "hosts/common/users/sunzi") + (configLib.relativeToRoot "hosts/common/users/laozi") + + ]; + # set custom autologin options. see greetd.nix for details + # TODO is there a better spot for this? + autoLogin.enable = true; + autoLogin.username = "sunzi"; + + services.gnome.gnome-keyring.enable = true; + # TODO enable and move to greetd area? may need authentication dir or something? + # services.pam.services.greetd.enableGnomeKeyring = true; + + networking = { + hostName = "sunzi"; + # networkmanager.enable = true; + enableIPv6 = false; + }; + + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + timeout = 3; + }; + }; + + # ================ HYPRLAND =================== # + environment.sessionVariables = { + # hack to get the cursor to become visible + WLR_NO_HARDWARE_CURSORS = "1"; + # WLR_RENDERER_ALLOW_SOFTWARE = "1"; + # WLR_DRM_DEVICES = "1"; + + # Hint electron apps to use wayland + NIXOS_OZONE_WL = "1"; + } + + + hardware + + # Fix to enable VSCode to successfully remote SSH on a client to a NixOS host + # https://nixos.wiki/wiki/Visual_Studio_Code # Remote_SSH + # programs.nix-ld.enable = true; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "23.11"; +} diff --git a/systems/rehoboam/hardware-configuration.nix b/systems/rehoboam/hardware-configuration.nix new file mode 100644 index 0000000..8855cf1 --- /dev/null +++ b/systems/rehoboam/hardware-configuration.nix @@ -0,0 +1,38 @@ +# 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 = [ ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "xhci_pci" "ahci" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/63cd8b28-aa46-484d-8b48-2cb9f641f21a"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/6E05-2AB6"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/8b1fd3ff-0589-4fa3-8d5d-af2afc60b2b7"; }]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + # virtualisation.virtualbox.guest.enable = true; +} diff --git a/vars/default.nix b/vars/default.nix new file mode 100644 index 0000000..2b48d48 --- /dev/null +++ b/vars/default.nix @@ -0,0 +1,11 @@ +{ inputs, lib }: +{ + username = "laozi"; + domain = inputs.nix-secrets.domain; + userFullName = inputs.nix-secrets.full-name; + handle = "madmin42"; + userEmail = inputs.nix-secrets.user-email; + gitEmail = "72525251+madmin42@users.noreply.github.com"; + workEmail = inputs.nix-secrets.work-email; + networking = import ./networking.nix { inherit lib; }; +} diff --git a/vars/networking.nix b/vars/networking.nix new file mode 100644 index 0000000..4b63cb4 --- /dev/null +++ b/vars/networking.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + firewall.allowPing = true; +}