diff --git a/.gitignore b/.gitignore index 619d00a..ee0c388 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *.qcow2 result -.direnv diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index d282180..0000000 --- a/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[submodule "nvim"] - path = src/user/modules/utils/modules/neovim/config/nvim - url = https://github.com/itme-brain/nvim.git - -[submodule "vim"] - path = src/user/modules/utils/modules/vim/vim - url = https://github.com/itme-brain/vim.git - -[submodule "git"] - path = src/user/modules/git/git - url = https://github.com/itme-brain/git.git - -[submodule "bash"] - path = src/user/modules/bash/config/bash - url = https://github.com/itme-brain/bash.git diff --git a/README.md b/README.md index cc8dc2d..12d1907 100644 --- a/README.md +++ b/README.md @@ -1,145 +1,38 @@ # My Nix Configurations πŸ’» -My modular Nix configs πŸ”₯ - -## Requirements βš™οΈ +My modular Nix configsπŸ”₯ +## Requirements βš™οΈ - [Nix 2.0 & Flakes enabled](https://nixos.wiki/wiki/Flakes#Enable_flakes_permanently_in_NixOS) -- [NixOS](https://www.nixos.org/) for system configurations -- [Nix Home-Manager](https://nix-community.github.io/home-manager/index.xhtml#sec-flakes-standalone) for user configurations -## Flake Endpoints ❄️ +### NixOS Configurations +- [NixOS](https://www.nixos.org/) +### Home-Manager Configuration +- [Nix Home-Manager](https://nix-community.github.io/home-manager/index.xhtml#sec-flakes-standalone) -NixOS Configurations: `desktop` Β· `workstation` Β· `server` (wip) Β· `vm` Β· `wsl` +# Flake End-Points Exposed ❄️ +NixOS Configurations: + - desktop + - wsl + - server (wip) + - vm -## Fresh Install πŸš€ +Home-Manager Configurations: + - workstation -From the NixOS live installer: +Fork this repo, take inspiration, borrow ideas and create your own NixOS configs & modules -```bash -# Enable flakes (not enabled by default on installer) -echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf - -# Clone repo -nix run nixpkgs#git -- clone --recurse-submodules https://github.com/itme-brain/nixos.git -cd nixos - -# Enter dev shell and install -nix develop -just install desktop -``` - -Replace `desktop` with `workstation` or `vm` as needed. - -## Getting Started πŸ”§ - -```bash -git clone --recurse-submodules git@github.com:itme-brain/nixos.git -``` - -Enter the dev shell with `nix develop`, then run `just` to see available project scripts. - -Useful resources: +## Developing & Customizing πŸ”§ +If you need a list of available packages and options: - [nixpkgs Packages](https://search.nixos.org/packages) πŸ“¦οΈ - [nixpkgs Options](https://search.nixos.org/options?) πŸ”οΈ - [Home-Manager Options](https://mipmip.github.io/home-manager-option-search/) β˜•οΈ -⚠️ Be sure to tailor any hardware settings to your own β€” replace the `hardware.nix` in `src/system/machines/` with output from `nixos-generate-config` +Invoke `nix develop` to enter a development shell powered by [`just`](https://github.com/casey/just) +Invoke `just` in order to view an available list of project scripts -## Submodules πŸ”— +`user.configs.nix` is a symlink to conveniently access centrally defined common user variables from the repo root -Standalone portable configurations maintained as separate repos. Each can be cloned independently on any system β€” NixOS or not. - -| Submodule | Purpose | Repo | Standalone Install | -|-----------|---------|------|--------------------| -| **nvim** | Full IDE (LSP, treesitter, telescope) | [itme-brain/nvim](https://github.com/itme-brain/nvim) | `git clone git@github.com:itme-brain/nvim.git ~/.config/nvim` | -| **vim** | Lightweight editor for headless servers | [itme-brain/vim](https://github.com/itme-brain/vim) | `git clone git@github.com:itme-brain/vim.git ~/.vim` | - -```bash -# Update a submodule -cd -git add . && git commit -m "your changes" && git push -cd /path/to/nixos -git add && git commit -m "Update submodule" - -# Pull submodule updates from remote -git submodule update --remote -git add && git commit -m "Update submodule" -``` - -## Directory Structure πŸ—‚οΈ - -``` -. -β”œβ”€β”€ flake.nix # Flake entrypoint - defines all NixOS configurations -β”œβ”€β”€ flake.lock -β”œβ”€β”€ justfile # Project scripts (via `just`) -β”œβ”€β”€ system.configs -> src/system/machines/ # Symlink for quick access -β”œβ”€β”€ user.configs -> src/user/config/ # Symlink for quick access -└── src/ - β”œβ”€β”€ system/ # System-level (NixOS) configuration - β”‚ β”œβ”€β”€ machines/ # Per-machine NixOS configurations - β”‚ β”‚ β”œβ”€β”€ desktop/ # Desktop config (flake: nixosConfigurations.desktop) - β”‚ β”‚ β”‚ β”œβ”€β”€ default.nix # Machine entry point - β”‚ β”‚ β”‚ β”œβ”€β”€ hardware.nix # Machine-specific hardware config - β”‚ β”‚ β”‚ β”œβ”€β”€ system.nix # System-level settings - β”‚ β”‚ β”‚ └── modules/ - β”‚ β”‚ β”‚ β”œβ”€β”€ disko/ # Disk partitioning (disko) - β”‚ β”‚ β”‚ └── home-manager/ # Home-manager integration + home.nix - β”‚ β”‚ β”œβ”€β”€ workstation/ # Workstation config (same structure as desktop) - β”‚ β”‚ β”œβ”€β”€ server/ # Server config (no disko) - β”‚ β”‚ β”œβ”€β”€ vm/ # VM config - β”‚ β”‚ β”œβ”€β”€ wsl/ # WSL config (includes wsl module) - β”‚ β”‚ └── laptop/ # Laptop config (stub) - β”‚ └── modules/ # Shared system modules (imported by machines) - β”‚ β”œβ”€β”€ default.nix - β”‚ β”œβ”€β”€ bitcoin/ # Bitcoin node + electrum server - β”‚ β”œβ”€β”€ forgejo/ # Self-hosted Forgejo - β”‚ └── nginx/ # Nginx reverse proxy - β”‚ - └── user/ # User-level (home-manager) configuration - β”œβ”€β”€ default.nix # User module entry point - β”œβ”€β”€ config/ # User identity & settings - β”‚ β”œβ”€β”€ default.nix # Common user variables (username, email, etc.) - β”‚ β”œβ”€β”€ bookmarks/ # Browser bookmarks - β”‚ β”œβ”€β”€ keys/ # Public keys - β”‚ β”‚ β”œβ”€β”€ pgp/ # PGP public keys - β”‚ β”‚ └── ssh/ # SSH public keys - β”‚ β”œβ”€β”€ nvim # Symlink to neovim submodule config - β”‚ └── vim # Symlink to vim submodule config - └── modules/ # Home-manager modules - β”œβ”€β”€ bash/ # Shell config (aliases, prompt, bashrc) - β”œβ”€β”€ git/ # Git config + helper scripts - β”œβ”€β”€ tmux/ # Tmux config - β”œβ”€β”€ security/ # Security tools (GPG) - β”œβ”€β”€ utils/ # CLI utilities - β”‚ └── modules/ - β”‚ β”œβ”€β”€ dev/ # Dev tools (penpot, PCB design) - β”‚ β”œβ”€β”€ email/ # Email client (aerc) - β”‚ β”œβ”€β”€ irc/ # IRC client - β”‚ β”œβ”€β”€ neovim/ # Neovim (config is a git submodule) - β”‚ └── vim/ # Vim lightweight (config is a git submodule) - └── gui/ # GUI applications - β”œβ”€β”€ modules/ - β”‚ β”œβ”€β”€ alacritty/ # Terminal emulator - β”‚ β”œβ”€β”€ browsers/ # Firefox & Chromium - β”‚ β”œβ”€β”€ corn/ # Corn app - β”‚ β”œβ”€β”€ fun/ # Discord, etc. - β”‚ β”œβ”€β”€ utils/ # GUI utilities - β”‚ └── writing/ # Writing tools - └── wm/ # Window managers - β”œβ”€β”€ hyprland/ # Hyprland (Wayland) + waybar, rofi - β”œβ”€β”€ sway/ # Sway (Wayland) + rofi - β”œβ”€β”€ i3/ # i3 (X11) + rofi - └── shared/ # Shared WM config (mimeapps) -``` - -### How it works - -**flake.nix** defines NixOS configurations (desktop, workstation, server, wsl) that each reference a machine under `src/system/machines/`. Each machine's `default.nix` pulls in its own `hardware.nix`, `system.nix`, and per-machine modules (disko, home-manager). - -The **system layer** (`src/system/`) handles NixOS-level concerns: hardware, bootloader, networking, and system services. Shared modules in `src/system/modules/` can be imported by any machine. - -The **user layer** (`src/user/`) handles home-manager configuration. `src/user/config/` defines user identity (name, email, keys), while `src/user/modules/` contains modular home-manager configs for individual tools. Each machine's `home-manager/home.nix` selects which user modules to enable. - -Root symlinks `system.configs` and `user.configs` provide quick access to machine definitions and user config from the repo root. +⚠️ Be sure to tailor any hardware settings to your own +⚠️ Replace the `hardware.nix` found in the `src/system/machines/` directory +⚠️ Run `nixos-generate-config` to generate a `hardware-configuration.nix` for your current system diff --git a/flake.lock b/flake.lock index 7875441..6238a49 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1773025010, - "narHash": "sha256-khlHllTsovXgT2GZ0WxT4+RvuMjNeR5OW0UYeEHPYQo=", + "lastModified": 1721007199, + "narHash": "sha256-Gof4Lj1rgTrX59bNu5b/uS/3X/marUGM7LYw31NoXEA=", "owner": "nix-community", "repo": "disko", - "rev": "7b9f7f88ab3b339f8142dc246445abb3c370d3d3", + "rev": "bad376945de7033c7adc424c02054ea3736cf7c4", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -36,24 +36,21 @@ "type": "github" } }, - "flake-parts": { + "flake-utils": { "inputs": { - "nixpkgs-lib": [ - "nur", - "nixpkgs" - ] + "systems": "systems" }, "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", + "owner": "numtide", + "repo": "flake-utils", "type": "github" } }, @@ -64,16 +61,16 @@ ] }, "locked": { - "lastModified": 1772985280, - "narHash": "sha256-FdrNykOoY9VStevU4zjSUdvsL9SzJTcXt4omdEDZDLk=", + "lastModified": 1720042825, + "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", "owner": "nix-community", "repo": "home-manager", - "rev": "8f736f007139d7f70752657dff6a401a585d6cbc", + "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-25.11", + "ref": "release-24.05", "repo": "home-manager", "type": "github" } @@ -81,68 +78,49 @@ "nixos-wsl": { "inputs": { "flake-compat": "flake-compat", + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1739577062, - "narHash": "sha256-u/trdPzJO8UotNq48RbG7m6Pe8761IEMCOY0QidNjY4=", + "lastModified": 1702823833, + "narHash": "sha256-Sreo1VEMSwS/T83QxXeN1cDtgXWXPMibGYfQ8pLLSVc=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "0b2b8b31f69f24e9a75b4b18a32c771a48612d5e", + "rev": "34eda458bd3f6bad856a99860184d775bc1dd588", "type": "github" }, "original": { "owner": "nix-community", - "ref": "2411.6.0", + "ref": "2311.5.3", "repo": "NixOS-WSL", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1772822230, - "narHash": "sha256-yf3iYLGbGVlIthlQIk5/4/EQDZNNEmuqKZkQssMljuw=", + "lastModified": 1720954236, + "narHash": "sha256-1mEKHp4m9brvfQ0rjCca8P1WHpymK3TOr3v34ydv9bs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "71caefce12ba78d84fe618cf61644dce01cf3a96", + "rev": "53e81e790209e41f0c1efa9ff26ff2fd7ab35e27", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1772963539, - "narHash": "sha256-9jVDGZnvCckTGdYT53d/EfznygLskyLQXYwJLKMPsZs=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, "nur": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2" - }, "locked": { - "lastModified": 1773108757, - "narHash": "sha256-3BAoe2R6YA6Xjdsgx3urZ4Ns3LeTy0E/w5d1wPny910=", + "lastModified": 1730795826, + "narHash": "sha256-5eUMYntBzgV2EPdPWY4acON2vc4zWrRR7rOJifTqrIE=", "owner": "nix-community", "repo": "NUR", - "rev": "9f2c583704f122828e6f9893416ca3b007464ee6", + "rev": "689c78bc78b5a3aa0e86a2f5cd25a266015791ee", "type": "github" }, "original": { @@ -159,6 +137,21 @@ "nixpkgs": "nixpkgs", "nur": "nur" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 500ef39..1a33f20 100644 --- a/flake.nix +++ b/flake.nix @@ -1,19 +1,17 @@ { description = "My Nix Configs"; - inputs = - { - self.submodules = true; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; nur = { url = "github:nix-community/NUR"; }; home-manager = { - url = "github:nix-community/home-manager/release-25.11"; + url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; }; nixos-wsl = { - url = "github:nix-community/NixOS-WSL/2411.6.0"; + url = "github:nix-community/NixOS-WSL/2311.5.3"; inputs.nixpkgs.follows = "nixpkgs"; }; disko = { @@ -22,7 +20,7 @@ }; }; - outputs = { nixpkgs, nur, home-manager, nixos-wsl, disko, ... }: + outputs = { self, nixpkgs, nur, home-manager, nixos-wsl, disko }: let system = "x86_64-linux"; pkgs = import nixpkgs { @@ -31,7 +29,7 @@ allowUnfree = true; }; overlays = [ - nur.overlays.default + nur.overlay ]; }; @@ -42,26 +40,17 @@ desktop = nixpkgs.lib.nixosSystem { inherit system pkgs; modules = [ - disko.nixosModules.disko ./src/system/machines/desktop home-manager.nixosModules.home-manager (import ./src/system/machines/desktop/modules/home-manager) - ]; - }; - - workstation = nixpkgs.lib.nixosSystem { - inherit system pkgs; - modules = [ - ./src/system/machines/workstation - home-manager.nixosModules.home-manager - (import ./src/system/machines/workstation/modules/home-manager) + #disko.nixosModules.disko + # (import ./src/system/machines/desktop/modules/disko) ]; }; server = nixpkgs.lib.nixosSystem { inherit system pkgs; modules = [ - disko.nixosModules.disko ./src/system/machines/server home-manager.nixosModules.home-manager (import ./src/system/machines/server/modules/home-manager) @@ -73,18 +62,33 @@ modules = [ ./src/system/machines/wsl nixos-wsl.nixosModules.wsl - (import ./src/system/machines/wsl/modules/wsl) + (import ./src/system/machines/wsl/wsl.nix) home-manager.nixosModules.home-manager - (import ./src/system/machines/wsl/modules/home-manager) + (import ./src/system/machines/wsl/home.nix) ]; }; + + vm = nixpkgs.lib.nixosSystem { + inherit system pkgs; + modules = [ + ./src/system/machines/vm + home-manager.nixosModules.home-manager + (import ./src/system/machines/vm/modules/home-manager) + disko.nixosModules.disko + (import ./src/system/machines/vm/modules/disko) + ]; + }; + }; + + homeConfigurations."work" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ ./src/system/machines/workstation ]; }; devShells.${system}.default = mkShell { name = "devShell"; packages = [ just - age ]; }; }; diff --git a/justfile b/justfile index dedac40..68900c1 100644 --- a/justfile +++ b/justfile @@ -1,240 +1,205 @@ SYSTEM := "$(echo $HOSTNAME)" -VALID_SYSTEMS := "desktop workstation server wsl vm laptop" # Print this list default: @just --list -# Validate system argument -[private] -_validate SYSTEM: - #!/usr/bin/env bash - case "{{SYSTEM}}" in - desktop|workstation|server|wsl|vm|laptop) ;; - *) echo "Error: Unknown system '{{SYSTEM}}'. Use one of: {{VALID_SYSTEMS}}"; exit 1 ;; - esac - -# Helper to parse submodules from .gitmodules -[private] -_subs_init := ''' - declare -A SUBS - while read -r key path; do - name="${key#submodule.}"; name="${name%.path}" - SUBS[$name]="$path" - done < <(git config -f .gitmodules --get-regexp 'submodule\..*\.path') -''' - # Clean up build artifacts -[group('nix')] clean: #!/usr/bin/env bash set -euo pipefail echo "Cleaning build artifacts" - rm -f result - rm -f ./*.qcow2 - echo "Done" + if [ -d result ]; then + echo "Removing result directory..." + rm ./result; + fi + if ls *.qcow2 1> /dev/null 2>&1; then + echo "Removing virtual disk..." + rm ./*.qcow2; + fi + echo "All clean!" # Output what derivations will be built -[group('nix')] -out SYSTEM="desktop": (_validate SYSTEM) - @echo "Outputting derivations to be built for {{SYSTEM}}..." - @nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L - -# Test switch into the next generation -[group('nixos')] -test SYSTEM="desktop": (_validate SYSTEM) - @echo "Testing switching to next NixOS generation for {{SYSTEM}}..." - @sudo nixos-rebuild test --flake .#{{SYSTEM}} - -# Build the nix expression and hydrate the results directory -[group('nix')] -build SYSTEM="desktop": (_validate SYSTEM) - @echo "Building NixOS configuration for {{SYSTEM}}..." - @nix build .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L - @echo -e "\033[32mBuild success - result directory hydrated\033[0m" - -# Deploy a vm of the defined system -[group('nixos')] -vm SYSTEM: (_validate SYSTEM) +out TYPE SYSTEM="desktop": #!/usr/bin/env bash set -euo pipefail - echo "Building VM for {{SYSTEM}}..." - nixos-rebuild build-vm --flake .#{{SYSTEM}} - if [[ -f result/bin/run-{{SYSTEM}}-vm ]]; then + case "{{TYPE}}" in + "nix") + if + [ "{{SYSTEM}}" = "desktop" ] || \ + [ "{{SYSTEM}}" = "server" ] || \ + [ "{{SYSTEM}}" = "wsl" ] || \ + [ "{{SYSTEM}}" = "vm" ] || \ + [ "{{SYSTEM}}" = "laptop" ] + then + echo "Testing NixOS configuration for {{SYSTEM}}..." + nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L + exit 0 + else + echo "Error: Unknown argument - '{{SYSTEM}}'" + echo "Use one of:" + echo " desktop" + echo " server" + echo " laptop" + echo " wsl" + echo " vm" + exit 1 + fi + ;; + "home") + echo "Testing home configuration..." + nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L + exit 0 + ;; + *) + echo "Invalid usage: {{TYPE}}."; + echo "Use one of:" + echo " nix" + echo " home" + exit 1 + ;; + esac + +# Test switch into the next generation +test TYPE SYSTEM="desktop": + #!/usr/bin/env bash + set -euo pipefail + case "{{TYPE}}" in + "nix") + if + [ "{{SYSTEM}}" = "desktop" ] || \ + [ "{{SYSTEM}}" = "server" ] || \ + [ "{{SYSTEM}}" = "wsl" ] || \ + [ "{{SYSTEM}}" = "vm" ] || \ + [ "{{SYSTEM}}" = "laptop" ] + then + echo "Testing next NixOS generation for {{SYSTEM}}..." + sudo nixos-rebuild test --flake .#{{SYSTEM}} + exit 0 + else + echo "Error: Unknown argument - '{{SYSTEM}}'" + echo "Use one of:" + echo " desktop" + echo " server" + echo " laptop" + echo " wsl" + echo " vm" + exit 1 + fi + ;; + "home") + echo "Testing home configuration..." + nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L + exit 0 + ;; + *) + echo "Invalid usage: {{TYPE}}."; + echo "Use one of:" + echo " nix" + echo " home" + exit 1 + ;; + esac + +# Build the nix expression and hydrate the results directory +make TYPE SYSTEM="desktop": + #!/usr/bin/env bash + set -euo pipefail + case "{{TYPE}}" in + "nix") + if + [ "{{SYSTEM}}" = "desktop" ] || \ + [ "{{SYSTEM}}" = "server" ] || \ + [ "{{SYSTEM}}" = "wsl" ] || \ + [ "{{SYSTEM}}" = "vm" ] || \ + [ "{{SYSTEM}}" = "laptop" ] + then + echo "Hydrating resulting NixOS configuration for {{SYSTEM}}..." + nix build .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L + exit 0 + else + echo "Error: Unknown argument - '{{SYSTEM}}'" + echo "Use one of:" + echo " desktop" + echo " server" + echo " laptop" + echo " wsl" + echo " vm" + exit 1 + fi + ;; + "home") + echo "Hydrating resulting home configuration..." + nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L + exit 0 + ;; + *) + echo "Invalid usage: {{TYPE}}." + echo "Use one of:" + echo " nix" + echo " home" + exit 1 + ;; + esac + +# Deploy a vm of the defined system +vm SYSTEM: + #!/usr/bin/env bash + set -euo pipefail + if + [ "{{SYSTEM}}" = "desktop" ] || \ + [ "{{SYSTEM}}" = "server" ] || \ + [ "{{SYSTEM}}" = "wsl" ] || \ + [ "{{SYSTEM}}" = "vm" ] || \ + [ "{{SYSTEM}}" = "laptop" ] + then + echo "Building VM for {{SYSTEM}}..." + nixos-rebuild build-vm --flake .#{{SYSTEM}} result/bin/run-{{SYSTEM}}-vm + exit 0 else - echo "Error: VM build failed!" + echo "Error: Unknown argument - '{{SYSTEM}}'" + echo "Use one of:" + echo " desktop" + echo " server" + echo " laptop" + echo " vm" + echo " wsl" exit 1 fi # grep nixpkgs for PKG -[group('nix')] search PKG: nix search nixpkgs {{PKG}} # Open nixos packages in the browser -[group('nix')] pkgs: @xdg-open https://search.nixos.org/packages # Open nixos options in the browser -[group('nix')] options: @xdg-open https://search.nixos.org/options # NixOS-rebuild switch for the current system -[group('nixos')] switch: @echo -e "\033[32m->> Switching to next generation ->>\033[0m" @sudo nixos-rebuild switch --flake .#{{SYSTEM}} # Rollback to previous generation -[group('nixos')] -rollback: - @sudo nixos-rebuild switch --rollback +rollback SYSTEM="nixos": + #!/usr/bin/env bash + set -euo pipefail + if [ {{SYSTEM}} = "nixos" ]; then + sudo nixos-rebuild switch --rollback + fi # NixOS-rebuild boot for the current system -[group('nixos')] boot: @echo -e "\033[34m->> Reboot to new generation ->>\033[0m" + @echo "Switching to next generation on reboot" @sudo nixos-rebuild boot --flake .#{{SYSTEM}} -# Partition disk only (interactive disk selection) -[group('nixos')] -partition SYSTEM: - #!/usr/bin/env bash - set -euo pipefail - - DISKO_CONFIG="./src/system/machines/{{SYSTEM}}/modules/disko/default.nix" - - if [[ ! -f "$DISKO_CONFIG" ]]; then - echo "Error: No disko config for '{{SYSTEM}}'" - exit 1 - fi - - # Build array of disk options with readable info - declare -a DISK_IDS - declare -a DISK_OPTIONS - - for id in /dev/disk/by-id/*; do - name=$(basename "$id") - [[ "$name" =~ part ]] && continue - [[ ! "$name" =~ ^(ata|nvme|scsi)- ]] && continue - - dev=$(readlink -f "$id") - dev_name=$(basename "$dev") - size=$(lsblk -dn -o SIZE "$dev" 2>/dev/null) || continue - model=$(lsblk -dn -o MODEL "$dev" 2>/dev/null | xargs) || model="" - - DISK_IDS+=("$id") - DISK_OPTIONS+=("$dev_name $size $model") - done - - if [[ ${#DISK_IDS[@]} -eq 0 ]]; then - echo "No disks found!" - exit 1 - fi - - echo "Select a disk:" - select opt in "${DISK_OPTIONS[@]}"; do - if [[ -n "$opt" ]]; then - idx=$((REPLY - 1)) - DISK="${DISK_IDS[$idx]}" - break - else - echo "Invalid selection" - fi - done - - echo "" - echo -e "\033[31m!! WARNING: This will DESTROY all data on $DISK !!\033[0m" - read -p "Continue? [y/N]: " confirm - case "${confirm,,}" in - y|yes) ;; - *) echo "Aborted."; exit 1 ;; - esac - - echo "Writing disk '$DISK' to disko config..." - sed -i "s|device = \"/dev/disk/by-id/[^\"]*\";|device = \"$DISK\";|" "$DISKO_CONFIG" - - echo "Partitioning $DISK..." - sudo nix \ - --extra-experimental-features "nix-command flakes" \ - run github:nix-community/disko -- \ - --mode destroy,format,mount \ - "$DISKO_CONFIG" - - echo -e "\033[32mPartitioning complete. Disk mounted at /mnt.\033[0m" - -# Install NixOS (partition + install in one shot) -[group('nixos')] -install SYSTEM: - #!/usr/bin/env bash - set -euo pipefail - - DISKO_CONFIG="./src/system/machines/{{SYSTEM}}/modules/disko/default.nix" - - if [[ ! -f "$DISKO_CONFIG" ]]; then - echo "Error: No disko config for '{{SYSTEM}}'" - exit 1 - fi - - # Build array of disk options with readable info - declare -a DISK_IDS - declare -a DISK_OPTIONS - - for id in /dev/disk/by-id/*; do - name=$(basename "$id") - [[ "$name" =~ part ]] && continue - [[ ! "$name" =~ ^(ata|nvme|scsi)- ]] && continue - - dev=$(readlink -f "$id") - dev_name=$(basename "$dev") - size=$(lsblk -dn -o SIZE "$dev" 2>/dev/null) || continue - model=$(lsblk -dn -o MODEL "$dev" 2>/dev/null | xargs) || model="" - - DISK_IDS+=("$id") - DISK_OPTIONS+=("$dev_name $size $model") - done - - if [[ ${#DISK_IDS[@]} -eq 0 ]]; then - echo "No disks found!" - exit 1 - fi - - echo "Select a disk:" - select opt in "${DISK_OPTIONS[@]}"; do - if [[ -n "$opt" ]]; then - idx=$((REPLY - 1)) - DISK="${DISK_IDS[$idx]}" - break - else - echo "Invalid selection" - fi - done - - echo "" - echo -e "\033[31m!! WARNING: This will DESTROY all data on $DISK !!\033[0m" - read -p "Continue? [y/N]: " confirm - case "${confirm,,}" in - y|yes) ;; - *) echo "Aborted."; exit 1 ;; - esac - - echo "Writing disk '$DISK' to disko config..." - sed -i "s|device = \"/dev/disk/by-id/[^\"]*\";|device = \"$DISK\";|" "$DISKO_CONFIG" - - echo "Partitioning and installing NixOS..." - sudo nix \ - --extra-experimental-features "nix-command flakes" \ - run github:nix-community/disko/latest#disko-install -- \ - --flake .#{{SYSTEM}} \ - --disk main "$DISK" - - echo -e "\033[32mDone! Reboot to start NixOS.\033[0m" - # Commit all changes and push to upstream -[group('git')] gh COMMIT_MESSAGE: #!/usr/bin/env bash set -euo pipefail @@ -242,125 +207,17 @@ gh COMMIT_MESSAGE: git commit -m "{{COMMIT_MESSAGE}}" git push -# Show status of submodules with changes -[group('submodule')] -sstatus: - #!/usr/bin/env bash - {{_subs_init}} - for name in "${!SUBS[@]}"; do - status=$(git -C "${SUBS[$name]}" status -s) - [[ -n "$status" ]] && echo -e "\033[34m$name:\033[0m" && echo "$status" - done - -# Pull all submodules and parent -[group('submodule')] -spull: - #!/usr/bin/env bash - set -euo pipefail - {{_subs_init}} - git pull - for name in "${!SUBS[@]}"; do - echo -e "\033[34m$name:\033[0m" - git -C "${SUBS[$name]}" pull - done - -# Push submodules and parent -[group('submodule')] -spush NAME="": - #!/usr/bin/env bash - set -euo pipefail - {{_subs_init}} - if [[ -n "{{NAME}}" ]]; then - path="${SUBS[{{NAME}}]:-}" - [[ -z "$path" ]] && echo "Unknown: {{NAME}}. Available: ${!SUBS[*]}" && exit 1 - git -C "$path" push - else - for path in "${SUBS[@]}"; do git -C "$path" push; done - fi - git push - -# Commit submodule changes and update parent -[group('submodule')] -scommit NAME="": - #!/usr/bin/env bash - set -euo pipefail - {{_subs_init}} - MSGS=() - - commit_sub() { - local name="$1" path="$2" - [[ -z "$(git -C "$path" status -s)" ]] && return 0 - echo -e "\033[34m$name:\033[0m" - git -C "$path" status -s - read -p "Commit message: " MSG - [[ -z "$MSG" ]] && return 0 - git -C "$path" add -A && git -C "$path" commit -m "$MSG" - git add "$path" - MSGS+=("$name: $MSG") - } - - if [[ -n "{{NAME}}" ]]; then - path="${SUBS[{{NAME}}]:-}" - [[ -z "$path" ]] && echo "Unknown: {{NAME}}. Available: ${!SUBS[*]}" && exit 1 - commit_sub "{{NAME}}" "$path" - else - for name in "${!SUBS[@]}"; do commit_sub "$name" "${SUBS[$name]}"; done - fi - - if ! git diff --cached --quiet; then - COMMIT_MSG="updated submodules"$'\n' - for m in "${MSGS[@]}"; do COMMIT_MSG+="- $m"$'\n'; done - git commit -m "$COMMIT_MSG" - fi - -# Commit and push submodules + parent -[group('submodule')] -ssync NAME="": - #!/usr/bin/env bash - set -euo pipefail - {{_subs_init}} - MSGS=() - - sync_sub() { - local name="$1" path="$2" - [[ -z "$(git -C "$path" status -s)" ]] && return 0 - echo -e "\033[34m$name:\033[0m" - git -C "$path" status -s - read -p "Commit message: " MSG - [[ -z "$MSG" ]] && return 0 - git -C "$path" add -A && git -C "$path" commit -m "$MSG" - git -C "$path" push - git add "$path" - MSGS+=("$name: $MSG") - } - - if [[ -n "{{NAME}}" ]]; then - path="${SUBS[{{NAME}}]:-}" - [[ -z "$path" ]] && echo "Unknown: {{NAME}}. Available: ${!SUBS[*]}" && exit 1 - sync_sub "{{NAME}}" "$path" - else - for name in "${!SUBS[@]}"; do sync_sub "$name" "${SUBS[$name]}"; done - fi - - if ! git diff --cached --quiet; then - COMMIT_MSG="updated submodules"$'\n' - for m in "${MSGS[@]}"; do COMMIT_MSG+="- $m"$'\n'; done - git commit -m "$COMMIT_MSG" - fi - git push - -# Fetch resources and compute sha256 hash -[group('nix')] +#Fetch resources and compute sha256 hash hash URL: #!/usr/bin/env bash set -euo pipefail - if [[ "{{URL}}" =~ \.(tar(\.gz)?|tgz|gz|zip)$ ]]; then - CONTENTS=$(nix-prefetch-url --unpack {{URL}}) + if echo "{{URL}}" | grep -E '\.(tar\.gz|tgz|zip)$'; then + CONTENTS=$(nix-prefetch-url --unpack {{URL}} | tail -n 1) else - CONTENTS=$(nix-prefetch-url {{URL}}) + CONTENTS=$(nix-prefetch-url {{URL}} | tail -n 1) fi - HASH=$(nix hash convert --hash-algo sha256 "$CONTENTS") + HASH=$(nix hash to-sri --type sha256 "$CONTENTS") echo -e "\033[32m$HASH\033[0m" diff --git a/src/system/config/default.nix b/src/system/config/default.nix deleted file mode 100644 index 4bb4315..0000000 --- a/src/system/config/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib, pkgs, config, ... }: - -with lib; -{ - options = { - machines = mkOption { - description = "Machine Configurations"; - type = types.attrs; - default = { - keys = import ./keys { inherit lib; }; - }; - }; - }; -} diff --git a/src/system/config/keys/default.nix b/src/system/config/keys/default.nix deleted file mode 100644 index e3f3aaf..0000000 --- a/src/system/config/keys/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ lib }: - -with builtins; -let - extractName = filename: - let - # Remove .key extension - noKey = lib.removeSuffix ".key" filename; - # Remove .pub/.priv/.public/.private markers - noMarkers = replaceStrings - [ ".pub" ".priv" ".public" ".private" ] - [ "" "" "" "" ] - noKey; - in noMarkers; - - constructKeys = dir: ( - listToAttrs ( - map (subdir: { - name = subdir; - value = listToAttrs ( - map (file: { - name = extractName file; - value = readFile "${dir}/${subdir}/${file}"; - }) (filter (file: - (readDir "${dir}/${subdir}").${file} == "regular" && - lib.hasSuffix ".key" file - ) (attrNames (readDir "${dir}/${subdir}"))) - ); - }) (filter (node: (readDir dir).${node} == "directory") (attrNames (readDir dir))) - ) - ); -in - constructKeys ./. diff --git a/src/system/config/keys/desktop/README.md b/src/system/config/keys/desktop/README.md deleted file mode 100644 index 355d803..0000000 --- a/src/system/config/keys/desktop/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Desktop Keys - -ssh.pub.key - ~/.ssh/id_rsa diff --git a/src/system/config/keys/desktop/ssh.pub.key b/src/system/config/keys/desktop/ssh.pub.key deleted file mode 100644 index 4604ca9..0000000 --- a/src/system/config/keys/desktop/ssh.pub.key +++ /dev/null @@ -1 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOYXfu4Jc/HtdyhOfAdCXYzhqCubIq3Bz6Kl9NDUov76 bryan@desktop diff --git a/src/system/machines/desktop/README.md b/src/system/machines/desktop/README.md deleted file mode 100644 index 92c75d7..0000000 --- a/src/system/machines/desktop/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## Hardware - -| Component | Model | -|-------------|------------------------------------| -| Motherboard | MSI B760 GAMING PLUS WIFI | -| CPU | Intel Core i7-12700KF (12th Gen) | -| GPU | NVIDIA GeForce GTX 1650 | -| Storage | 2x 2TB Crucial MX500 SSD | - -## Memory - -| Slot | Size | Manufacturer | Part Number | Speed | -|---------|------|----------------|-------------|------------| -| DIMM A1 | - | - | - | - | -| DIMM A2 | 16GB | Team Group Inc | UD5-6000 | 4800 MT/s | -| DIMM B1 | - | - | - | - | -| DIMM B2 | 16GB | Team Group Inc | UD5-6000 | 4800 MT/s | - -**Total: 32GB DDR5** diff --git a/src/system/machines/desktop/default.nix b/src/system/machines/desktop/default.nix index 99a49af..6e64b71 100644 --- a/src/system/machines/desktop/default.nix +++ b/src/system/machines/desktop/default.nix @@ -3,9 +3,7 @@ { imports = [ ../../../user/config - ../../config ./hardware.nix ./system.nix - ./modules/disko ]; } diff --git a/src/system/machines/desktop/hardware.nix b/src/system/machines/desktop/hardware.nix index 3d41249..5d4b3bd 100644 --- a/src/system/machines/desktop/hardware.nix +++ b/src/system/machines/desktop/hardware.nix @@ -1,83 +1,84 @@ { config, lib, pkgs, modulesPath, ... }: -with lib; { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - options.monitors = mkOption { - type = types.listOf (types.submodule { - options = { - name = mkOption { type = types.str; example = "HDMI-A-1"; }; - width = mkOption { type = types.int; }; - height = mkOption { type = types.int; }; - x = mkOption { type = types.int; }; - y = mkOption { type = types.int; }; - scale = mkOption { type = types.float; }; - refreshRate = mkOption { type = types.int; }; - }; - }); - default = []; - description = "System monitor configuration"; + boot = { + initrd = { + availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + kernelModules = [ "dm-snapshot" ]; + }; + extraModulePackages = [ ]; + kernelPackages = pkgs.linuxPackages_zen; + kernelParams = [ "intel_iommu=on" ]; + kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ]; }; - config = { - monitors = [ - { name = "HDMI-A-1"; width = 1920; height = 1080; x = 0; y = 0; scale = 1.0; refreshRate = 60; } - { name = "DP-1"; width = 1920; height = 1080; x = 1920; y = 0; scale = 1.0; refreshRate = 60; } - ]; + environment.systemPackages = with pkgs; [ + linuxHeaders - boot = { - initrd = { - availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; - kernelModules = [ "dm-snapshot" ]; - }; - extraModulePackages = [ ]; - kernelPackages = pkgs.linuxPackages_zen; - kernelParams = [ "intel_iommu=on" ]; - kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ]; + vulkan-headers + vulkan-loader + vulkan-tools + vulkan-extension-layer + glxinfo + mesa + + cudaPackages.cudatoolkit + cudaPackages.cudnn + ]; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/8a323092-39b9-4913-8839-452156e48922"; + fsType = "ext4"; }; - environment.systemPackages = with pkgs; [ - linuxHeaders - - vulkan-headers - vulkan-loader - vulkan-tools - vulkan-extension-layer - - mesa - mesa-demos - - cudaPackages.cudatoolkit - cudaPackages.cudnn - ]; - - hardware = { - cpu = { - intel = { - updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - }; - }; - nvidia = { - open = true; - modesetting.enable = true; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - graphics = { - enable = true; - enable32Bit = true; - }; + "/home" = { + device = "/dev/disk/by-uuid/84474517-05eb-45aa-880e-c18301483b53"; + fsType = "ext4"; }; - virtualisation.libvirtd = { + "/boot" = { + device = "/dev/disk/by-uuid/B4B2-C898"; + fsType = "vfat"; + }; + }; + + services.xserver.videoDrivers = ["nvidia"]; + + hardware = { + cpu = { + intel = { + updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; + }; + nvidia = { + modesetting.enable = true; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.mkDriver { + version = "550.90.07"; + sha256_64bit = "sha256-Uaz1edWpiE9XOh0/Ui5/r6XnhB4iqc7AtLvq4xsLlzM="; + openSha256 = "sha256-mRUTEWVsbjq+psVe+kAT6MjyZuLkG2yRDxCMvDJRL1I="; + settingsSha256 = "sha256-sX9dHEp9zH9t3RWp727lLCeJLo8QRAGhVb8iN6eX49g="; + persistencedSha256 = "sha256-11tLSY8uUIl4X/roNnxf5yS2PQvHvoNjnd2CB67e870="; + }; + }; + opengl = { enable = true; - qemu = { - runAsRoot = true; - }; + driSupport = true; + driSupport32Bit = true; }; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; }; + + virtualisation.libvirtd = { + enable = true; + qemu = { + runAsRoot = true; + ovmf.enable = true; + }; + }; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; } diff --git a/src/system/machines/desktop/modules/disko/default.nix b/src/system/machines/desktop/modules/disko/default.nix index fd39485..3dc5c09 100644 --- a/src/system/machines/desktop/modules/disko/default.nix +++ b/src/system/machines/desktop/modules/disko/default.nix @@ -1,50 +1,99 @@ +{ disks ? [ "/dev/nvme0n1" "/dev/sdb" ], ... }: + { disko.devices = { disk = { - main = { + one = { type = "disk"; - device = "/dev/disk/by-id/ata-CT2000MX500SSD1_2137E5D2D47D"; + device = builtins.elemAt disks 0; content = { - type = "gpt"; - partitions = { - boot = { - size = "1G"; - type = "EF00"; + type = "table"; + format = "gpt"; + partitions = [ + { + name = "boot"; + start = "0"; + end = "200M"; + fs-type = "fat32"; + bootable = true; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; }; - }; - primary = { - size = "100%"; + } + { + start = "200M"; + end = "100%FREE"; content = { type = "lvm_pv"; - vg = "nix"; + vg = "stick"; }; - }; - }; + } + ]; + }; + }; + }; + disk = { + two = { + type = "disk"; + device = builtins.elemAt disks 1; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + start = "0"; + end = "100%FREE"; + content = { + type = "lvm_pv"; + vg = "ssd"; + }; + } + ]; }; }; }; lvm_vg = { - nix = { + stick = { type = "lvm_vg"; lvs = { + aaa = { + size = "1M"; + }; + zzz = { + size = "1M"; + }; root = { - size = "5%"; + size = "100%"; content = { + name = "NixOS"; type = "filesystem"; format = "ext4"; mountpoint = "/"; - mountOptions = [ "defaults" ]; + mountOptions = [ + "defaults" + ]; }; }; + }; + }; + }; + lvm_vg = { + ssd = { + type = "lvm_vg"; + lvs = { + aaa = { + size = "1M"; + }; + zzz = { + size = "1M"; + }; home = { - size = "100%FREE"; + size = "200G"; content = { + name = "home"; type = "filesystem"; format = "ext4"; mountpoint = "/home"; diff --git a/src/system/machines/desktop/modules/home-manager/home.nix b/src/system/machines/desktop/modules/home-manager/home.nix index c4ff09d..997e52f 100644 --- a/src/system/machines/desktop/modules/home-manager/home.nix +++ b/src/system/machines/desktop/modules/home-manager/home.nix @@ -3,9 +3,6 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - monitors = config.monitors; - }; home-manager.users.${config.user.name} = { imports = [ ../../../../../user ]; diff --git a/src/system/machines/desktop/system.nix b/src/system/machines/desktop/system.nix index ba97169..44c4321 100644 --- a/src/system/machines/desktop/system.nix +++ b/src/system/machines/desktop/system.nix @@ -1,11 +1,5 @@ { pkgs, lib, config, ... }: -let - gpgEnabled = lib.any - (user: user.modules.user.security.gpg.enable or false) - (lib.attrValues config.home-manager.users); - -in { system.stateVersion = "23.11"; users.users = { @@ -13,13 +7,13 @@ in isNormalUser = true; extraGroups = config.user.groups ++ [ "video" "audio" "kvm" "libvirtd" "dialout" ]; - openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.graphone}" ]; + openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.android}" ]; }; }; nix = { channel.enable = false; - package = pkgs.nixVersions.stable; + package = pkgs.nixFlakes; extraOptions = '' experimental-features = nix-command flakes keep-going = true @@ -38,32 +32,29 @@ in }; boot.loader = { - systemd-boot = { + timeout = null; + grub = { enable = true; - configurationLimit = 5; - #memtest86.enable = true; + devices = [ "nodev" ]; + efiSupport = true; + configurationLimit = 3; + splashImage = null; }; efi = { canTouchEfiVariables = true; }; - #timeout = null; }; - environment = { - systemPackages = with pkgs; [ - vim - git - usbutils - ]; - pathsToLink = [ - "/share/applications" - "/share/xdg-desktop-portal" - ]; - }; + environment.systemPackages = with pkgs; [ + vim + git + usbutils + ]; fonts.packages = with pkgs; [ - nerd-fonts.terminess-ttf + terminus_font + terminus-nerdfont ]; security = { @@ -94,11 +85,9 @@ in enable = true; allowedTCPPorts = [ 22 80 443 ]; }; - nameservers = [ "192.168.0.154" ]; }; services = { - pcscd.enable = gpgEnabled; timesyncd = lib.mkDefault { enable = true; servers = [ @@ -124,7 +113,7 @@ in startWhenNeeded = false; settings = { X11Forwarding = false; - PasswordAuthentication = false; + PasswordAuthentication = true; }; }; }; diff --git a/src/system/machines/server/README.md b/src/system/machines/server/README.md deleted file mode 100644 index 56c6cb5..0000000 --- a/src/system/machines/server/README.md +++ /dev/null @@ -1,20 +0,0 @@ -## Hardware - -| Component | Model | -|-----------|--------------------------------| -| System | HP Z230 SFF Workstation | -| CPU | Intel Core i7-4770 @ 3.40GHz | -| GPU | Integrated | -| Storage | 6TB Seagate ST6000NM0024 | -| Network | Intel (onboard) | - -## Memory - -| Slot | Size | Manufacturer | Part Number | Speed | -|-------|------|---------------|-------------------|-----------| -| DIMM1 | 4GB | Hynix/Hyundai | HMT451U6AFR8C-PB | 1600 MT/s | -| DIMM2 | 4GB | Hynix/Hyundai | HMT451U6AFR8C-PB | 1600 MT/s | -| DIMM3 | 4GB | Hynix/Hyundai | HMT451U6AFR8C-PB | 1600 MT/s | -| DIMM4 | 4GB | Hynix/Hyundai | HMT451U6AFR8C-PB | 1600 MT/s | - -**Total: 16GB DDR3** diff --git a/src/system/machines/server/default.nix b/src/system/machines/server/default.nix index c71ec8a..6e64b71 100644 --- a/src/system/machines/server/default.nix +++ b/src/system/machines/server/default.nix @@ -3,7 +3,6 @@ { imports = [ ../../../user/config - ../../config ./hardware.nix ./system.nix ]; diff --git a/src/system/machines/server/hardware.nix b/src/system/machines/server/hardware.nix index 8a9ebe5..7f31eed 100644 --- a/src/system/machines/server/hardware.nix +++ b/src/system/machines/server/hardware.nix @@ -1,22 +1,26 @@ { config, lib, modulesPath, ... }: { - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - ./modules/disko - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot = { - initrd = { - availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "sd_mod" "sr_mod" ]; - kernelModules = [ ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/0fviSz-6z7Q-oH7Y-JOzH-nRxW-c029-2LxSqo"; + fsType = "ext4"; + }; + + "/boot" = { + device = "/dev/disk/by-uuid/3BAA-D9DC"; + fsType = "vfat"; }; - kernelModules = [ "kvm-intel" ]; - extraModulePackages = [ ]; }; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/src/system/machines/server/modules/disko/default.nix b/src/system/machines/server/modules/disko/default.nix deleted file mode 100644 index 8f5d43e..0000000 --- a/src/system/machines/server/modules/disko/default.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ lib, ... }: - -{ - disko.devices = { - disk = { - main = { - type = "disk"; - device = "/dev/sda"; - content = { - type = "gpt"; - partitions = { - ESP = { - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - lvm = { - size = "100%"; - content = { - type = "lvm_pv"; - vg = "vg0"; - }; - }; - }; - }; - }; - }; - - lvm_vg = { - vg0 = { - type = "lvm_vg"; - lvs = { - root = { - size = "200G"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - }; - data = { - size = "1T"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/data"; - }; - }; - bitcoin = { - size = "1T"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/var/lib/bitcoin"; - }; - }; - frigate = { - size = "3T"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/var/lib/frigate"; - }; - }; - # ~300GB left unallocated for future growth - }; - }; - }; - }; -} diff --git a/src/system/machines/server/modules/home-manager/default.nix b/src/system/machines/server/modules/home-manager/default.nix index d3a7e46..1d99c4d 100644 --- a/src/system/machines/server/modules/home-manager/default.nix +++ b/src/system/machines/server/modules/home-manager/default.nix @@ -8,7 +8,7 @@ programs.home-manager.enable = true; - home.stateVersion = "25.11"; + home.stateVersion = "23.11"; home.username = "${config.user.name}"; home.homeDirectory = "/home/${config.user.name}"; @@ -17,7 +17,6 @@ user = { bash.enable = true; git.enable = true; - tmux.enable = true; security = { gpg.enable = true; diff --git a/src/system/machines/server/system.nix b/src/system/machines/server/system.nix index 20feaed..1186d31 100644 --- a/src/system/machines/server/system.nix +++ b/src/system/machines/server/system.nix @@ -1,30 +1,19 @@ { pkgs, lib, config, ... }: -{ system.stateVersion = "25.11"; +{ system.stateVersion = "23.11"; imports = [ ../../modules ]; - modules.system = { - nginx.enable = true; - forgejo.enable = true; - frigate.enable = false; - immich.enable = true; - bitcoin = { - enable = true; - electrum.enable = true; - clightning.enable = true; - }; - - backup = { - enable = true; - recipients = [ - "${config.user.keys.age.yubikey}" - "${config.machines.keys.desktop.ssh}" - ]; - paths = [ "/root/.config/rclone" ]; - destination = "gdrive:backups/server"; - schedule = "daily"; - keepLast = 2; + modules = { + system = { + bitcoin = { + enable = true; + electrum.enable = true; + clightning = { + enable = true; + rest.enable = true; + }; + }; }; }; @@ -32,15 +21,13 @@ ${config.user.name} = { isNormalUser = true; extraGroups = config.user.groups; - openssh.authorizedKeys.keys = [ - "${config.machines.keys.desktop.ssh}" - ]; + openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ]; }; }; nix = { channel.enable = false; - package = pkgs.nixVersions.stable; + package = pkgs.nixFlakes; extraOptions = "experimental-features = nix-command flakes"; settings = { auto-optimise-store = true; @@ -54,9 +41,10 @@ }; boot.loader = { - timeout = 3; + timeout = null; grub = { enable = true; + useOSProber = true; devices = [ "nodev" ]; efiSupport = true; configurationLimit = 5; @@ -72,7 +60,11 @@ wget git vim - htop + ]; + + fonts.packages = with pkgs; [ + terminus_font + terminus-nerdfont ]; security.sudo = { @@ -97,58 +89,27 @@ i18n.defaultLocale = "en_US.UTF-8"; - console.font = "Lat2-Terminus16"; + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; + }; networking = { hostName = "server"; - useDHCP = false; - interfaces.eno1 = { - ipv4.addresses = [{ - address = "192.168.0.154"; - prefixLength = 24; - }]; - }; - defaultGateway = "192.168.0.1"; - nameservers = [ "1.1.1.1" "8.8.8.8" ]; + useDHCP = lib.mkDefault true; + networkmanager.enable = true; firewall = { enable = true; - allowedTCPPorts = [ 22 ]; + allowedTCPPorts = [ 22 80 443 ]; }; }; - services.dnsmasq = { - enable = true; - settings = { - # All *.ramos.codes subdomains -> local server - address = "/.ramos.codes/192.168.0.154"; - # Except www, http, https and bare domain -> forward to upstream - server = [ - "/www.ramos.codes/1.1.1.1" - "/http.ramos.codes/1.1.1.1" - "/https.ramos.codes/1.1.1.1" - "/ramos.codes/1.1.1.1" - "1.1.1.1" - "8.8.8.8" - ]; - cache-size = 1000; - }; - }; - - networking.firewall.allowedUDPPorts = [ 53 ]; - - services.fail2ban = { - enable = true; - maxretry = 5; - bantime = "1h"; - }; - services.openssh = { enable = true; startWhenNeeded = true; settings = { X11Forwarding = false; PasswordAuthentication = false; - PermitRootLogin = "no"; }; }; } diff --git a/src/system/machines/vm/default.nix b/src/system/machines/vm/default.nix index c71ec8a..6e64b71 100644 --- a/src/system/machines/vm/default.nix +++ b/src/system/machines/vm/default.nix @@ -3,7 +3,6 @@ { imports = [ ../../../user/config - ../../config ./hardware.nix ./system.nix ]; diff --git a/src/system/machines/vm/modules/disko/default.nix b/src/system/machines/vm/modules/disko/default.nix index 5376126..398129c 100644 --- a/src/system/machines/vm/modules/disko/default.nix +++ b/src/system/machines/vm/modules/disko/default.nix @@ -1,10 +1,11 @@ -{ disk ? "/dev/vda" }: +{ disks ? [ "/dev/vda" ], ... }: + { disko.devices = { disk = { one = { + device = builtins.elemAt disks 0; type = "disk"; - device = disk; content = { type = "gpt"; partitions = { @@ -16,6 +17,8 @@ format = "vfat"; mountpoint = "/boot"; }; + bootable = true; + priority = 1; }; primary = { size = "100%"; @@ -33,6 +36,12 @@ vm = { type = "lvm_vg"; lvs = { + aaa = { + size = "1M"; + }; + zzz = { + size = "1M"; + }; root = { size = "100%"; content = { diff --git a/src/system/machines/vm/system.nix b/src/system/machines/vm/system.nix index 444b180..172c029 100644 --- a/src/system/machines/vm/system.nix +++ b/src/system/machines/vm/system.nix @@ -8,13 +8,13 @@ ${config.user.name} = { isNormalUser = true; extraGroups = config.user.groups; - openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.yubikey}" ]; + openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ]; }; }; nix = { channel.enable = false; - package = pkgs.nixVersions.stable; + package = pkgs.nixFlakes; extraOptions = "experimental-features = nix-command flakes"; settings = { auto-optimise-store = true; diff --git a/src/system/machines/workstation/default.nix b/src/system/machines/workstation/default.nix index c71ec8a..f68b744 100644 --- a/src/system/machines/workstation/default.nix +++ b/src/system/machines/workstation/default.nix @@ -1,10 +1 @@ -{ ... }: - -{ - imports = [ - ../../../user/config - ../../config - ./hardware.nix - ./system.nix - ]; -} +{ imports = [ ./home.nix ]; } diff --git a/src/system/machines/workstation/hardware.nix b/src/system/machines/workstation/hardware.nix deleted file mode 100644 index 65039d1..0000000 --- a/src/system/machines/workstation/hardware.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - - boot = { - initrd = { - availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; - kernelModules = [ "dm-snapshot" ]; - }; - extraModulePackages = [ ]; - kernelParams = [ "intel_iommu=on" ]; - kernelModules = [ - "kvm-intel" - "virtio" - "vfio-pci" - "coretemp" - - "ipmi_devintf" - "ipmi_si" - ]; - }; - - environment.systemPackages = with pkgs; [ - ipmitool - ipmicfg - ipmiutil - ipmiview - - linuxHeaders - - vulkan-headers - vulkan-loader - vulkan-tools - vulkan-extension-layer - - mesa - mesa-demos - - libGL - ]; - - fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/6e964c61-ea77-48cc-b495-6a8516b8e756"; - fsType = "xfs"; - }; - - "/home" = { - device = "/dev/disk/by-uuid/db504fb8-14f8-4292-b745-32d6255c4893"; - fsType = "xfs"; - }; - - "/boot" = { - device = "/dev/disk/by-uuid/61E7-6E56"; - fsType = "vfat"; - }; - - "/var/lib/libvirt/images" = { - device = "/home/VMs"; - options = [ "bind" ]; - }; - }; - - systemd.tmpfiles.rules = [ - "d /home/VMs 0755 root root" - ]; - - virtualisation.libvirtd = { - enable = true; - qemu = { - runAsRoot = true; - }; - }; - - services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ]; - - hardware = { - graphics = { - enable = true; - enable32Bit = true; - }; - nvidia = { - open = false; - powerManagement.enable = false; - powerManagement.finegrained = false; - modesetting.enable = true; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - }; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/src/system/machines/workstation/home.nix b/src/system/machines/workstation/home.nix new file mode 100644 index 0000000..7e4c153 --- /dev/null +++ b/src/system/machines/workstation/home.nix @@ -0,0 +1,56 @@ +{ config, pkgs, ... }: + +{ + imports = [ ./user ]; + + programs.home-manager.enable = true; + + home = { + stateVersion = "23.11"; + username = "${config.user.name}"; + homeDirectory = "/home/${config.user.name}"; + + file.".config/home-manager" = { + source = ../../../..; + recursive = true; + }; + }; + + nix = { + package = pkgs.nixFlakes; + extraOptions = "experimental-features = nix-command flakes"; + settings = { + auto-optimise-store = true; + trusted-users = [ "${config.user.name}" ]; + }; + }; + + user = { + bash.enable = true; + git.enable = true; + + security= { + gpg.enable = true; + }; + + gui = { + alacritty.enable = true; + browsers.enable = true; + neovim.enable = true; + }; + + utils = { + enable = true; + dev.enable = true; + email.enable = true; + irc.enable = true; + vim.enable = true; + }; + }; + + programs.bash = { + initExtra = + import ./scripts/guiControl + ; + }; +} diff --git a/src/system/machines/workstation/modules/disko/default.nix b/src/system/machines/workstation/modules/disko/default.nix deleted file mode 100644 index d9943db..0000000 --- a/src/system/machines/workstation/modules/disko/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ disk }: -{ - disko.devices = { - disk = { - one = { - type = "disk"; - device = disk; - content = { - type = "gpt"; - partitions = { - boot = { - size = "1G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - primary = { - size = "100%"; - content = { - type = "lvm_pv"; - vg = "nix"; - }; - }; - }; - }; - }; - }; - - lvm_vg = { - nix = { - type = "lvm_vg"; - lvs = { - root = { - size = "5%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - mountOptions = [ "defaults" ]; - }; - }; - home = { - size = "100%FREE"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/home"; - }; - }; - }; - }; - }; - }; -} diff --git a/src/system/machines/workstation/modules/home-manager/home.nix b/src/system/machines/workstation/modules/home-manager/home.nix deleted file mode 100644 index 3720ca5..0000000 --- a/src/system/machines/workstation/modules/home-manager/home.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, ... }: - -{ - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.${config.user.name} = { - imports = [ ../../../../../user ]; - - programs.home-manager.enable = true; - - home.stateVersion = "23.11"; - - home.username = "${config.user.name}"; - home.homeDirectory = "/home/${config.user.name}"; - - modules = { - user = { - bash.enable = true; - git.enable = true; - - security = { - enable = true; - gpg.enable = true; - }; - - tmux.enable = true; - - utils = { - enable = true; - dev = { - enable = true; - }; - email.enable = true; - neovim.enable = true; - vim.enable = true; - }; - - gui = { - wm.i3.enable = true; - - browser = { - chromium.enable = true; - }; - - alacritty.enable = true; - utils.enable = true; - writing.enable = true; - }; - }; - }; - }; -} diff --git a/src/system/machines/workstation/scripts/guiControl.nix b/src/system/machines/workstation/scripts/guiControl.nix new file mode 100644 index 0000000..02f33bb --- /dev/null +++ b/src/system/machines/workstation/scripts/guiControl.nix @@ -0,0 +1,17 @@ +'' +function ui() { + case $1 in + on) + sudo systemctl set-default graphical.target + sudo systemctl start graphical.target + ;; + off) + sudo systemctl set-default multi-user.target + sudo systemctl isolate multi-user.target + ;; + *) + echo "Usage: $0 {on|off}" + ;; + esac +} +'' diff --git a/src/system/machines/workstation/system.nix b/src/system/machines/workstation/system.nix deleted file mode 100644 index e26e5ea..0000000 --- a/src/system/machines/workstation/system.nix +++ /dev/null @@ -1,131 +0,0 @@ -{ pkgs, lib, config, home-manager, ... }: - -with lib; -{ - system.stateVersion = "23.11"; - - users.users = { - ${config.user.name} = { - isNormalUser = true; - extraGroups = config.user.groups - ++ [ "video" "audio" "kvm" "libvirtd" "dialout" ]; - openssh.authorizedKeys.keys = [ - "${config.user.keys.ssh.yubikey}" - "${config.user.keys.ssh.work}" - ]; - }; - }; - - nix = { - channel.enable = false; - package = pkgs.nixVersions.stable; - extraOptions = '' - experimental-features = nix-command flakes - keep-going = true - ''; - settings = { - auto-optimise-store = true; - trusted-users = [ "${config.user.name}" ]; - substitute = true; - max-jobs = "auto"; - }; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - }; - - boot.loader = { - systemd-boot = { - enable = true; - configurationLimit = 5; - memtest86.enable = true; - }; - timeout = null; - }; - - environment.systemPackages = with pkgs; [ - vim - git - usbutils - ]; - - fonts.packages = with pkgs; [ - terminus_font - terminus-nerdfont - ]; - - security = { - sudo = { - wheelNeedsPassword = false; - execWheelOnly = true; - }; - polkit.enable = true; - }; - - time = { - timeZone = "America/New_York"; - hardwareClockInLocalTime = true; - }; - - i18n.defaultLocale = "en_US.UTF-8"; - - console = { - font = "Lat2-Terminus16"; - useXkbConfig = true; - }; - - networking = { - hostName = "workstation"; - useDHCP = lib.mkDefault true; - networkmanager.enable = true; - firewall = { - enable = true; - allowedTCPPorts = [ 22 80 443 ]; - }; - }; - - programs.i3lock = { - enable = true; - package = pkgs.i3lock-fancy; - }; - - services = { - xserver.enable = true; - displayManager.ly.enable = true; - - teamviewer.enable = true; - - timesyncd = lib.mkDefault { - enable = true; - servers = [ - "0.pool.ntp.org" - "1.pool.ntp.org" - "2.pool.ntp.org" - "3.pool.ntp.org" - ]; - }; - - pipewire = { - enable = true; - audio.enable = true; - - wireplumber.enable = true; - - pulse.enable = true; - jack.enable = true; - alsa.enable = true; - alsa.support32Bit = true; - }; - - openssh = { - enable = true; - startWhenNeeded = false; - settings = { - X11Forwarding = false; - PasswordAuthentication = true; - }; - }; - }; -} diff --git a/src/system/machines/workstation/user b/src/system/machines/workstation/user new file mode 120000 index 0000000..0b7ce2d --- /dev/null +++ b/src/system/machines/workstation/user @@ -0,0 +1 @@ +../../../user/ \ No newline at end of file diff --git a/src/system/machines/wsl/default.nix b/src/system/machines/wsl/default.nix index 9af8cf1..97c4a4c 100644 --- a/src/system/machines/wsl/default.nix +++ b/src/system/machines/wsl/default.nix @@ -3,7 +3,6 @@ { imports = [ ../../../user/config - ../../config ./system.nix ]; } diff --git a/src/system/machines/wsl/modules/home-manager/home.nix b/src/system/machines/wsl/home.nix similarity index 86% rename from src/system/machines/wsl/modules/home-manager/home.nix rename to src/system/machines/wsl/home.nix index 1977ae0..43a445d 100644 --- a/src/system/machines/wsl/modules/home-manager/home.nix +++ b/src/system/machines/wsl/home.nix @@ -4,7 +4,9 @@ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.${config.user.name} = { - imports = [ ../../../../../user ]; + imports = [ + ../../../user + ]; programs.home-manager.enable = true; @@ -23,14 +25,12 @@ gpg.enable = true; }; - tmux.enable = true; - utils = { enable = true; dev.enable = true; email.enable = true; irc.enable = true; - neovim.enable = true; + vim.enable = true; }; }; }; diff --git a/src/system/machines/wsl/modules/home-manager/default.nix b/src/system/machines/wsl/modules/home-manager/default.nix deleted file mode 100644 index f31f0ea..0000000 --- a/src/system/machines/wsl/modules/home-manager/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - imports = [ -<<<<<<<< HEAD:src/system/machines/wsl/modules/home-manager/default.nix - ./home.nix -======== - ./c-lightning-REST ->>>>>>>> lightning:src/system/modules/bitcoin/modules/clightning/plugins/default.nix - ]; -} diff --git a/src/system/machines/wsl/modules/wsl/default.nix b/src/system/machines/wsl/modules/wsl/default.nix deleted file mode 100644 index 3cceea6..0000000 --- a/src/system/machines/wsl/modules/wsl/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./wsl.nix - ]; -} diff --git a/src/system/machines/wsl/system.nix b/src/system/machines/wsl/system.nix index 729213f..e5355a1 100644 --- a/src/system/machines/wsl/system.nix +++ b/src/system/machines/wsl/system.nix @@ -1,45 +1,62 @@ { pkgs, lib, config, ... }: -{ - system.stateVersion = "23.11"; - boot.isContainer = true; +{ system.stateVersion = "23.11"; +# Users users.users = { ${config.user.name} = { isNormalUser = true; extraGroups = config.user.groups; - openssh.authorizedKeys.keys = [ - "${config.user.keys.ssh.yubikey}" - ]; + openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ]; }; }; + boot.isContainer = true; +# Nix nix = { channel.enable = false; - package = pkgs.nixVersions.stable; - extraOptions = '' - experimental-features = nix-command flakes - ''; + package = pkgs.nixFlakes; + extraOptions = "experimental-features = nix-command flakes"; settings = { auto-optimise-store = true; trusted-users = [ "${config.user.name}" ]; }; gc = { automatic = true; - dates = "daily"; - options = "--delete-older-than 7d"; + dates = "weekly"; + options = "--delete-older-than 30d"; }; }; +# Sudo Options security.sudo = { wheelNeedsPassword = false; execWheelOnly = true; }; +# System Services + services = { + cron = { + enable = true; + systemCronJobs = []; + }; + }; + +# Locale time = { timeZone = "America/New_York"; }; + services.timesyncd = lib.mkDefault { + enable = true; + servers = [ + "0.pool.ntp.org" + "1.pool.ntp.org" + "2.pool.ntp.org" + "3.pool.ntp.org" + ]; + }; + i18n.defaultLocale = "en_US.UTF-8"; console = { @@ -47,8 +64,8 @@ useXkbConfig = true; }; +# Networking networking = { - hostName = "wsl"; useDHCP = lib.mkDefault true; firewall = { enable = true; @@ -56,20 +73,12 @@ }; }; - services = { - openssh = { - enable = true; - startWhenNeeded = true; - settings = { - X11Forwarding = false; - PasswordAuthentication = false; - }; - }; - timesyncd = lib.mkDefault { - enable = true; - servers = [ - "time.windows.com" - ]; + services.openssh = { + enable = true; + startWhenNeeded = true; + settings = { + X11Forwarding = false; + PasswordAuthentication = false; }; }; } diff --git a/src/system/machines/wsl/modules/wsl/wsl.nix b/src/system/machines/wsl/wsl.nix similarity index 55% rename from src/system/machines/wsl/modules/wsl/wsl.nix rename to src/system/machines/wsl/wsl.nix index e2a4ea8..15a7de6 100644 --- a/src/system/machines/wsl/modules/wsl/wsl.nix +++ b/src/system/machines/wsl/wsl.nix @@ -1,19 +1,19 @@ { config, lib, ... }: { - imports = [ ../../../../../user/config ]; + imports = [ + ../../../user + ]; - wsl = rec { + wsl = { enable = true; defaultUser = lib.mkDefault config.user.name; nativeSystemd = true; - useWindowsDriver = true; wslConf = { - user.default = lib.mkDefault defaultUser; boot.command = "cd"; network = { - hostname = "${config.networking.hostName}"; + hostname = "wsl"; generateHosts = true; }; }; diff --git a/src/system/modules/backup/default.nix b/src/system/modules/backup/default.nix deleted file mode 100644 index 07a3895..0000000 --- a/src/system/modules/backup/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.backup; - - recipientArgs = concatMapStrings (r: "-r '${lib.strings.trim r}' ") cfg.recipients; - - # Convert absolute paths to relative for tar, preserving structure - # e.g., /var/lib/forgejo -> var/lib/forgejo - tarPaths = map (p: removePrefix "/" p) cfg.paths; - - backupScript = pkgs.writeShellScript "backup" '' - set -euo pipefail - - TIMESTAMP=$(date +%Y%m%d-%H%M%S) - BACKUP_NAME="backup-$TIMESTAMP.tar.age" - TEMP_DIR=$(mktemp -d) - trap "rm -rf $TEMP_DIR" EXIT - - echo "Starting backup: $BACKUP_NAME" - echo "Paths: ${concatStringsSep " " cfg.paths}" - - export PATH="${pkgs.age-plugin-yubikey}/bin:$PATH" - ${pkgs.gnutar}/bin/tar -C / -cf - ${concatStringsSep " " tarPaths} | \ - ${pkgs.age}/bin/age ${recipientArgs} -o "$TEMP_DIR/$BACKUP_NAME" - - ${pkgs.rclone}/bin/rclone --config /root/.config/rclone/rclone.conf copy "$TEMP_DIR/$BACKUP_NAME" "${cfg.destination}" - - # Prune old backups - ${pkgs.rclone}/bin/rclone --config /root/.config/rclone/rclone.conf lsf "${cfg.destination}" | \ - sort -r | \ - tail -n +$((${toString cfg.keepLast} + 1)) | \ - while read -r old; do - ${pkgs.rclone}/bin/rclone --config /root/.config/rclone/rclone.conf delete "${cfg.destination}/$old" - done - - echo "Backup complete" - ''; - -in -{ - options.modules.system.backup = { - enable = mkEnableOption "Encrypted backups"; - - paths = mkOption { - type = types.listOf types.str; - default = []; - description = "Absolute paths to include in backup (structure preserved)"; - }; - - recipients = mkOption { - type = types.listOf types.str; - default = []; - description = "Age public keys for encryption"; - }; - - destination = mkOption { - type = types.str; - default = ""; - description = "Rclone destination"; - }; - - schedule = mkOption { - type = types.str; - default = "daily"; - description = "Systemd calendar expression"; - }; - - keepLast = mkOption { - type = types.int; - default = 3; - description = "Number of backups to keep"; - }; - }; - - config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.rclone ]; - - systemd.services.backup = { - description = "Encrypted backup"; - serviceConfig = { - Type = "oneshot"; - ExecStart = backupScript; - }; - }; - - systemd.timers.backup = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnCalendar = cfg.schedule; - Persistent = true; - }; - }; - }; -} diff --git a/src/system/modules/bitcoin/config/bitcoin.conf b/src/system/modules/bitcoin/config/bitcoin.conf index 756bfc1..641827a 100644 --- a/src/system/modules/bitcoin/config/bitcoin.conf +++ b/src/system/modules/bitcoin/config/bitcoin.conf @@ -1,12 +1,14 @@ server=1 -rpccookiefile=/var/lib/bitcoin/.cookie -rpccookieperms=group +mempoolfullrbf=1 +v2transport=1 + +rpcauth= + rpcbind=127.0.0.1 rpcallowip=127.0.0.1 dnsseed=0 -onlynet=onion bind=127.0.0.1 proxy=127.0.0.1:9050 @@ -14,5 +16,4 @@ proxy=127.0.0.1:9050 listen=1 listenonion=1 torcontrol=127.0.0.1:9051 - -txindex=1 +torenablecircuit=1 diff --git a/src/system/modules/bitcoin/default.nix b/src/system/modules/bitcoin/default.nix index e7e12a0..d03da3e 100644 --- a/src/system/modules/bitcoin/default.nix +++ b/src/system/modules/bitcoin/default.nix @@ -3,9 +3,8 @@ with lib; let cfg = config.modules.system.bitcoin; - nginx = config.modules.system.nginx; - home = "/var/lib/bitcoin"; + home = "/var/lib/bitcoind"; bitcoinConf = pkgs.writeTextFile { name = "bitcoin.conf"; @@ -15,7 +14,19 @@ let in { options.modules.system.bitcoin = { enable = mkEnableOption "Bitcoin Server"; }; config = mkIf cfg.enable { - modules.system.tor.enable = true; + #nixpkgs.overlays = [ + # (final: prev: { + # bitcoind = prev.bitcoind.overrideAttrs (old: rec { + # version = "v28.0"; + # src = pkgs.fetchFromGitHub { + # owner = "bitcoin"; + # repo = "bitcoin"; + # rev = "${version}"; + # sha256 = "sha256-LLtw6pMyqIJ3IWHiK4P3XoifLojB9yMNMo+MGNFGuRY="; + # }; + # }); + # }) + #]; environment.systemPackages = with pkgs; [ bitcoind @@ -28,31 +39,26 @@ in description = "Bitcoin Core system user"; isSystemUser = true; group = "bitcoin"; - extraGroups = [ "tor" ]; createHome = true; }; - "nginx" = { - extraGroups = mkIf nginx.enable [ - "bitcoin" - ]; - }; }; groups = { "bitcoin" = { members = [ "btc" - config.user.name ]; }; }; }; programs.bash.shellAliases = { - btc = "bitcoin-cli"; + btc = "bitcoind"; }; + networking.firewall.allowedTCPPorts = [ 8333 ]; + services.bitcoind = { - "mainnet" = { + "btc" = { enable = true; user = "btc"; group = "bitcoin"; @@ -61,20 +67,5 @@ in pidFile = "${home}/bitcoind.pid"; }; }; - - # Make data dir group-accessible so electrs/clightning can read cookie - systemd.tmpfiles.rules = [ - "d ${home} 0750 btc bitcoin -" - ]; - - systemd.services.bitcoind-mainnet = { - wants = [ "tor.service" ]; - after = [ "tor.service" ]; - serviceConfig.ExecStartPre = "+${pkgs.coreutils}/bin/chmod 750 /var/lib/tor"; - }; - - modules.system.backup.paths = [ - "${home}/wallets" - ]; }; } diff --git a/src/system/modules/bitcoin/modules/clightning/config/lightning.conf b/src/system/modules/bitcoin/modules/clightning/config/lightning.conf index def24ec..9daeafb 100644 --- a/src/system/modules/bitcoin/modules/clightning/config/lightning.conf +++ b/src/system/modules/bitcoin/modules/clightning/config/lightning.conf @@ -1,31 +1 @@ -alias=OrdSux - -network=bitcoin -bitcoin-datadir=/var/lib/bitcoin -bitcoin-rpcconnect=127.0.0.1 -bitcoin-rpcport=8332 - -lightning-dir=/var/lib/clightning -plugin-dir=/var/lib/clightning/plugins - -log-file=/var/lib/clightning/lightningd.log -log-level=info -rpc-file-mode=0660 - -# Bind RPC locally only -bind-addr=127.0.0.1:9736 - -# Auto-create Tor hidden service for peer connections -addr=autotor:127.0.0.1:9051 - -# Route outbound through Tor -proxy=127.0.0.1:9050 -always-use-proxy=true - -large-channels -fee-base=1000 -fee-per-satoshi=10 -min-capacity-sat=10000 -htlc-minimum-msat=0 -funding-confirms=3 -max-concurrent-htlcs=30 +test diff --git a/src/system/modules/bitcoin/modules/clightning/default.nix b/src/system/modules/bitcoin/modules/clightning/default.nix index 1968e71..347d586 100644 --- a/src/system/modules/bitcoin/modules/clightning/default.nix +++ b/src/system/modules/bitcoin/modules/clightning/default.nix @@ -4,21 +4,35 @@ with lib; let cfg = config.modules.system.bitcoin.clightning; btc = config.modules.system.bitcoin; - nginx = config.modules.system.nginx; - home = "/var/lib/clightning"; - domain = "ramos.codes"; clnConfig = pkgs.writeTextFile { name = "lightning.conf"; - text = '' - ${builtins.readFile ./config/lightning.conf} - bitcoin-cli=${pkgs.bitcoind}/bin/bitcoin-cli - ''; + text = builtins.readFile ./config/lightning.conf; }; in { options.modules.system.bitcoin.clightning = { enable = mkEnableOption "Core Lightning Server"; }; + imports = [ ./plugins ]; config = mkIf (cfg.enable && btc.enable) { + #nixpkgs.overlays = [ + # (final: prev: { + # clightning = prev.electrs.overrideAttrs (old: rec { + # version = "24.08"; + # src = pkgs.fetchFromGitHub { + # owner = "ElementsProject"; + # repo = "lightning"; + # rev = "82f4ad68e34a2428c556e63fc2632d48a914968c"; + # hash = "sha256-MWU75e55Zt/P4aaIuMte7iRcrFGMw0P81b8VNHQBe2g"; + # }; + # cargoDeps = old.cargoDeps.overrideAttrs (lib.const { + # name = "lightning-vendor.tar.gz"; + # inherit src; + # outputHash = "sha256-MWU75e55Zt/P4aaIuMte7iRcrFGMw0P81b8VNHQBe2g="; + # }); + # }); + # }) + #]; + environment.systemPackages = with pkgs; [ clightning ]; @@ -26,11 +40,10 @@ in users = { users = { "clightning" = { - inherit home; + home = "/var/lib/clightning"; description = "Core Lightning system user"; isSystemUser = true; group = "bitcoin"; - extraGroups = [ "tor" ]; createHome = true; }; }; @@ -44,26 +57,25 @@ in }; programs.bash.shellAliases = { - cln = "lightning-cli"; + cln = "lightningd"; }; systemd.services.lightningd = { description = "Core Lightning Daemon"; - wantedBy = [ "multi-user.target" ]; - wants = [ "bitcoind-mainnet.service" "tor.service" ]; + script = "${pkgs.clightning}/bin/lightningd"; + scriptArgs = '' + --conf=${clnConfig} + ''; + after = [ - "bitcoind-mainnet.service" - "tor.service" - "network.target" + "bitcoind-btc.service" ]; serviceConfig = { - ExecStartPre = "+${pkgs.coreutils}/bin/chmod 750 /var/lib/bitcoin /var/lib/tor ${home} ${home}/bitcoin"; - ExecStart = "${pkgs.clightning}/bin/lightningd --conf=${clnConfig}"; + User = "clightning"; Group = "bitcoin"; - WorkingDirectory = home; Type = "simple"; KillMode = "process"; @@ -71,30 +83,10 @@ in Restart = "always"; RestartSec = 60; }; + requisite = [ + "bitcoind-btc.service" + "network.target" + ]; }; - - # Ensure data directory exists with correct permissions - systemd.tmpfiles.rules = mkAfter [ - "d ${home} 0750 clightning bitcoin -" - "d ${home}/plugins 0750 clightning bitcoin -" - "L+ /home/${config.user.name}/.lightning - - - - ${home}" - ]; - - modules.system.backup.paths = [ - "${home}/bitcoin/hsm_secret" - ]; - - # TODO: CLNRest not included in nixpkgs clightning build - # Need to package it separately or use an overlay - # services.nginx.virtualHosts."ln.${domain}" = mkIf nginx.enable { - # useACMEHost = domain; - # forceSSL = true; - # locations."/" = { - # proxyPass = "https://127.0.0.1:3010"; - # extraConfig = '' - # proxy_ssl_verify off; - # ''; - # }; - # }; }; } diff --git a/src/system/modules/bitcoin/modules/clightning/plugins/c-lightning-REST/default.nix b/src/system/modules/bitcoin/modules/clightning/plugins/c-lightning-REST/default.nix new file mode 100644 index 0000000..3c756a5 --- /dev/null +++ b/src/system/modules/bitcoin/modules/clightning/plugins/c-lightning-REST/default.nix @@ -0,0 +1,35 @@ +{ lib, pkgs, config, ... }: + +with lib; +let + cfg = config.modules.system.bitcoin.clightning.rest; + cln = config.modules.system.bitcoin.clightning; + +in +{ options.modules.system.bitcoin.clightning.rest = { enable = mkEnableOption "C-Lightning REST API Server"; }; + config = mkIf (cfg.enable && cln.enable) { + nixpkgs.overlays = [ + (final: prev: { + clightning-REST = prev.buildNpmPackage rec { + pname = "c-lightning-rest"; + version = "0.10.7"; + src = prev.fetchFromGitHub { + owner = "Ride-The-Lightning"; + repo = "c-lightning-REST"; + rev = "v${version}"; + hash = "sha256-Z3bLH/nqhO2IPE1N4TxYhEDh2wHR0nT801kztfYoj+s="; + }; + + npmDepsHash = "sha256-svt5hjhTriGhehxC36yGwrqcjax/9UqqVzxEhHnoM0M="; + dontNpmBuild = true; + + meta = with lib; { + description = "REST APIs for Core Lightning written with node.js "; + homepage = "https://github.com/Ride-The-Lightning/c-lightning-REST"; + license = licenses.mit; + }; + }; + }) + ]; + }; +} diff --git a/src/system/machines/workstation/modules/home-manager/default.nix b/src/system/modules/bitcoin/modules/clightning/plugins/default.nix similarity index 50% rename from src/system/machines/workstation/modules/home-manager/default.nix rename to src/system/modules/bitcoin/modules/clightning/plugins/default.nix index 86de83f..2b2fd49 100644 --- a/src/system/machines/workstation/modules/home-manager/default.nix +++ b/src/system/modules/bitcoin/modules/clightning/plugins/default.nix @@ -1,5 +1,5 @@ { imports = [ - ./home.nix + ./c-lightning-REST ]; } diff --git a/src/system/modules/bitcoin/modules/electrum/config/config.toml b/src/system/modules/bitcoin/modules/electrum/config/config.toml index 9f05fe2..c030e25 100644 --- a/src/system/modules/bitcoin/modules/electrum/config/config.toml +++ b/src/system/modules/bitcoin/modules/electrum/config/config.toml @@ -2,12 +2,13 @@ network = "bitcoin" electrum_rpc_addr = "127.0.0.1:50001" -cookie_file = "/var/lib/bitcoin/.cookie" +cookie-file = "/var/lib/bitcoind/.cookie" db_dir = "/var/lib/electrs" log_filters = "INFO" +timestamp = true -daemon_rpc_addr = "127.0.0.1:8332" -daemon_p2p_addr = "127.0.0.1:8333" -daemon_dir = "/var/lib/bitcoin" +daemon-rpc-addr = "127.0.0.1:8332" +daemon-p2p-addr = "127.0.0.1:8333" +daemon-dir = "/var/lib/bitcoind" diff --git a/src/system/modules/bitcoin/modules/electrum/default.nix b/src/system/modules/bitcoin/modules/electrum/default.nix index 6673f4f..3f4c2af 100644 --- a/src/system/modules/bitcoin/modules/electrum/default.nix +++ b/src/system/modules/bitcoin/modules/electrum/default.nix @@ -3,11 +3,7 @@ with lib; let cfg = config.modules.system.bitcoin.electrum; - nginx = config.modules.system.nginx; - home = "/var/lib/electrs"; - btc = config.modules.system.bitcoin; - domain = "ramos.codes"; electrsConfig = pkgs.writeTextFile { name = "config.toml"; @@ -17,27 +13,24 @@ let in { options.modules.system.bitcoin.electrum = { enable = mkEnableOption "Electrs Server"; }; config = mkIf (cfg.enable && btc.enable) { - #TODO: Fix the failing overlay due to `cargoHash/cargoSha256` - #nixpkgs.overlays = [ - # (final: prev: { - # electrs = prev.electrs.overrideAttrs (old: rec { - # pname = "electrs"; - # version = "0.10.8"; - # src = pkgs.fetchFromGitHub { - # owner = "romanz"; - # repo = pname; - # rev = "v${version}"; - # hash = "sha256-L26jzAn8vwnw9kFd6ciyYS/OLEFTbN8doNKy3P8qKRE="; - # }; - # #cargoDeps = old.cargoDeps.overrideAttrs (const { - # # name = "electrs-${version}.tar.gz"; - # # inherit src; - # # sha256 = ""; - # #}); - # cargoHash = "sha256-lBRcq73ri0HR3duo6Z8PdSjnC8okqmG5yWeHxH/LmcU="; - # }); - # }) - #]; + nixpkgs.overlays = [ + (final: prev: { + electrs = prev.electrs.overrideAttrs (old: rec { + version = "0.10.6"; + src = pkgs.fetchFromGitHub { + owner = "romanz"; + repo = "electrs"; + rev = "v${version}"; + hash = "sha256-yp9fKD7zH9Ne2+WQUupaxvUx39RWE8RdY4U6lHuDGSc="; + }; + cargoDeps = old.cargoDeps.overrideAttrs (lib.const { + name = "electrs-vendor.tar.gz"; + inherit src; + outputHash = "sha256-qQKAQHOAeYWQ5YVtx12hIAjNA7Aj1MW1m+WimlBWPv0="; + }); + }); + }) + ]; environment.systemPackages = with pkgs; [ electrs @@ -46,7 +39,7 @@ in users = { users = { "electrs" = { - inherit home; + home = "/var/lib/electrs"; description = "Electrs system user"; isSystemUser = true; group = "bitcoin"; @@ -65,20 +58,18 @@ in systemd.services.electrs = { description = "Electrs Bitcoin Indexer"; - wantedBy = [ "multi-user.target" ]; - wants = [ "bitcoind-mainnet.service" ]; + script = "${pkgs.electrs}/bin/electrs"; + scriptArgs = "--conf=${electrsConfig}"; + after = [ - "bitcoind-mainnet.service" - "network.target" + "bitcoind-btc.service" ]; serviceConfig = { - ExecStartPre = "+${pkgs.coreutils}/bin/chmod 750 /var/lib/bitcoin"; - ExecStart = "${pkgs.electrs}/bin/electrs --conf=${electrsConfig}"; + User = "electrs"; Group = "bitcoin"; - WorkingDirectory = home; Type = "simple"; KillMode = "process"; @@ -86,29 +77,10 @@ in Restart = "always"; RestartSec = 60; }; + requisite = [ + "bitcoind-btc.service" + "network.target" + ]; }; - - # Ensure db directory exists with correct permissions - systemd.tmpfiles.rules = [ - "d ${home} 0750 electrs bitcoin -" - ]; - - # Nginx SSL proxy for Electrum protocol (TCP) - networking.firewall.allowedTCPPorts = mkIf nginx.enable [ 50002 ]; - - services.nginx.streamConfig = mkIf nginx.enable '' - map $ssl_server_name $electrs_backend { - electrum.${domain} 127.0.0.1:50001; - default ""; - } - - server { - listen 50002 ssl; - proxy_pass $electrs_backend; - - ssl_certificate /var/lib/acme/${domain}/fullchain.pem; - ssl_certificate_key /var/lib/acme/${domain}/key.pem; - } - ''; }; } diff --git a/src/system/modules/forgejo/default.nix b/src/system/modules/forgejo/default.nix deleted file mode 100644 index 7c04407..0000000 --- a/src/system/modules/forgejo/default.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.forgejo; - nginx = config.modules.system.nginx; - domain = "ramos.codes"; - socketPath = "/run/forgejo/forgejo.sock"; - -in -{ - options.modules.system.forgejo = { - enable = mkEnableOption "Forgejo Server"; - }; - - config = mkIf cfg.enable { - users.groups.git = {}; - users.users.git = { - isSystemUser = true; - group = "git"; - home = "/var/lib/forgejo"; - shell = "${pkgs.bash}/bin/bash"; - }; - - users.users.nginx = mkIf nginx.enable { - extraGroups = [ "git" ]; - }; - - systemd.tmpfiles.rules = [ - "d /var/lib/forgejo 0750 git git -" - "d /var/lib/forgejo/.ssh 0700 git git -" - "d /var/lib/forgejo/custom 0750 git git -" - "d /var/lib/forgejo/data 0750 git git -" - ]; - - services.forgejo = { - enable = true; - user = "git"; - group = "git"; - stateDir = "/var/lib/forgejo"; - - settings = { - DEFAULT = { - APP_NAME = "Git Server"; - APP_SLOGAN = ""; - }; - - server = { - DOMAIN = "git.${domain}"; - ROOT_URL = "https://git.${domain}/"; - PROTOCOL = "http+unix"; - HTTP_ADDR = socketPath; - SSH_DOMAIN = "git.${domain}"; - SSH_PORT = 22; - START_SSH_SERVER = false; - LANDING_PAGE = "explore"; - }; - - service = { - REGISTER_MANUAL_CONFIRM = true; - DISABLE_REGISTRATION = false; - DEFAULT_ALLOW_CREATE_ORGANIZATION = false; - }; - - admin = { - DISABLE_REGULAR_ORG_CREATION = true; - }; - - auth = { - ENABLE_BASIC_AUTHENTICATION = true; - }; - }; - - database = { - type = "sqlite3"; - path = "/var/lib/forgejo/data/forgejo.db"; - }; - }; - - modules.system.backup.paths = [ - "/var/lib/forgejo" - ]; - - services.nginx.virtualHosts."git.${domain}" = mkIf nginx.enable { - useACMEHost = domain; - forceSSL = true; - locations."/" = { - proxyPass = "http://unix:${socketPath}"; - }; - }; - }; -} diff --git a/src/system/modules/frigate/default.nix b/src/system/modules/frigate/default.nix deleted file mode 100644 index 94e345c..0000000 --- a/src/system/modules/frigate/default.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.frigate; - nginx = config.modules.system.nginx; - domain = "ramos.codes"; - -in -{ - options.modules.system.frigate = { - enable = mkEnableOption "Enable Frigate NVR"; - }; - - config = mkIf cfg.enable { - services.frigate = { - enable = true; - hostname = "frigate.${domain}"; - settings = { - mqtt.enabled = false; - cameras = { - doorbell = { - detect.enabled = false; - ffmpeg.inputs = [{ - path = "rtsp://admin:ocu?u3Su@192.168.0.134/cam/realmonitor?channel=1&subtype=0"; - roles = [ "record" ]; - }]; - }; - living_room = { - detect.enabled = false; - ffmpeg.inputs = [{ - path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=1&subtype=0"; - roles = [ "record" ]; - }]; - }; - kitchen = { - detect.enabled = false; - ffmpeg.inputs = [{ - path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=2&subtype=0"; - roles = [ "record" ]; - }]; - }; - parking_lot = { - detect.enabled = false; - ffmpeg.inputs = [{ - path = "rtsp://admin:ocu?u3Su@192.168.0.59/cam/realmonitor?channel=1&subtype=0"; - roles = [ "record" ]; - }]; - }; - porch = { - detect.enabled = false; - ffmpeg.inputs = [{ - path = "rtsp://admin:ocu?u3Su@192.168.0.43/cam/realmonitor?channel=1&subtype=0"; - roles = [ "record" ]; - }]; - }; - }; - }; - }; - - # Add SSL to frigate's nginx virtualHost - services.nginx.virtualHosts."frigate.${domain}" = mkIf nginx.enable { - useACMEHost = domain; - forceSSL = true; - }; - - }; -} diff --git a/src/system/modules/immich/default.nix b/src/system/modules/immich/default.nix deleted file mode 100644 index 7ea2c54..0000000 --- a/src/system/modules/immich/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.immich; - nginx = config.modules.system.nginx; - domain = "ramos.codes"; - port = 2283; - -in -{ - options.modules.system.immich = { - enable = mkEnableOption "Immich Photo Server"; - }; - - config = mkIf cfg.enable { - services.immich = { - enable = true; - port = port; - host = "127.0.0.1"; - mediaLocation = "/var/lib/immich"; - machine-learning.enable = false; - }; - - modules.system.backup.paths = [ - "/var/lib/immich" - ]; - - services.nginx.virtualHosts."photos.${domain}" = mkIf nginx.enable { - useACMEHost = domain; - forceSSL = true; - locations."/" = { - proxyPass = "http://127.0.0.1:${toString port}"; - proxyWebsockets = true; - }; - }; - }; -} diff --git a/src/system/modules/nginx/default.nix b/src/system/modules/nginx/default.nix deleted file mode 100644 index 6db9d51..0000000 --- a/src/system/modules/nginx/default.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.nginx; - domain = "ramos.codes"; - -in -{ - options.modules.system.nginx = { - enable = mkEnableOption "Nginx Reverse Proxy"; - }; - - config = mkIf cfg.enable { - networking.firewall.allowedTCPPorts = [ 80 443 ]; - - systemd.services.nginx.serviceConfig.LimitNOFILE = 65536; - - security.acme = { - acceptTerms = true; - defaults.email = config.user.email; - - certs."${domain}" = { - domain = "*.${domain}"; - dnsProvider = "namecheap"; - environmentFile = "/var/lib/acme/namecheap.env"; - group = "nginx"; - }; - }; - - services.nginx = { - enable = true; - recommendedTlsSettings = true; - recommendedOptimisation = true; - recommendedGzipSettings = true; - eventsConfig = "worker_connections 4096;"; - - # Catch-all default - friendly error for unknown subdomains - virtualHosts."_" = { - default = true; - useACMEHost = domain; - forceSSL = true; - locations."/" = { - return = "404 'Not Found: This subdomain does not exist.'"; - extraConfig = '' - add_header Content-Type text/plain; - ''; - }; - }; - - virtualHosts."test.${domain}" = { - useACMEHost = domain; - forceSSL = true; - locations."/" = { - return = "200 'nginx is working'"; - extraConfig = '' - add_header Content-Type text/plain; - ''; - }; - }; - }; - }; -} diff --git a/src/system/modules/tor/default.nix b/src/system/modules/tor/default.nix deleted file mode 100644 index 37c2e95..0000000 --- a/src/system/modules/tor/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.system.tor; - -in -{ - options.modules.system.tor = { - enable = mkEnableOption "Tor"; - }; - - config = mkIf cfg.enable { - services.tor = { - enable = true; - - client = { - enable = true; - # SOCKS proxy on 127.0.0.1:9050 - }; - - settings = { - ControlPort = 9051; - CookieAuthentication = true; - CookieAuthFileGroupReadable = true; - DataDirectoryGroupReadable = true; - }; - }; - }; -} diff --git a/src/user/config/bash b/src/user/config/bash deleted file mode 120000 index 41f0b65..0000000 --- a/src/user/config/bash +++ /dev/null @@ -1 +0,0 @@ -../modules/bash/config/bash/ \ No newline at end of file diff --git a/src/user/config/default.nix b/src/user/config/default.nix index b539c79..85de61c 100644 --- a/src/user/config/default.nix +++ b/src/user/config/default.nix @@ -2,7 +2,7 @@ with lib; let - modules = config.modules.user; +modules = config.modules.user; in { @@ -10,13 +10,22 @@ in user = mkOption { description = "User Configurations"; type = types.attrs; - default = with pkgs; rec { + default = rec { name = "bryan"; email = "bryan@ramos.codes"; - shell = bash; - keys = import ./keys { inherit lib; }; + shell = pkgs.bash; + keys = import ./keys; groups = [ "wheel" "networkmanager" "home-manager" "input" ]; + gitConfig = optionalAttrs modules.git.enable { + userName = "Bryan Ramos"; + userEmail = email; + signing = optionalAttrs modules.security.gpg.enable { + key = "F1F3466458452B2DF351F1E864D12BA95ACE1F2D"; + signByDefault = true; + }; + }; + bookmarks = import ./bookmarks; }; }; diff --git a/src/user/config/git b/src/user/config/git deleted file mode 120000 index 753f800..0000000 --- a/src/user/config/git +++ /dev/null @@ -1 +0,0 @@ -../modules/git/git/ \ No newline at end of file diff --git a/src/user/config/keys/age/README.md b/src/user/config/keys/age/README.md deleted file mode 100644 index 92284a8..0000000 --- a/src/user/config/keys/age/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Age Keys - -yubikey.pub.key - Cold storage backup for age encryption diff --git a/src/user/config/keys/age/yubikey.pub.key b/src/user/config/keys/age/yubikey.pub.key deleted file mode 100644 index 559bc52..0000000 --- a/src/user/config/keys/age/yubikey.pub.key +++ /dev/null @@ -1 +0,0 @@ -age1yubikey1qfapxqnnkh92zkgayzzm9n0gtpkwaqcvrzy4d4xa4rxnjua8vjhy72hh9r9 diff --git a/src/user/config/keys/default.nix b/src/user/config/keys/default.nix index e3f3aaf..6808c06 100644 --- a/src/user/config/keys/default.nix +++ b/src/user/config/keys/default.nix @@ -1,17 +1,13 @@ -{ lib }: - with builtins; let - extractName = filename: + extractName = string: let - # Remove .key extension - noKey = lib.removeSuffix ".key" filename; - # Remove .pub/.priv/.public/.private markers - noMarkers = replaceStrings - [ ".pub" ".priv" ".public" ".private" ] - [ "" "" "" "" ] - noKey; - in noMarkers; + metadata = [ + "pub" "public" "priv" "private" + "key" "file" "." "_" "-" "pk" + ]; + in + replaceStrings metadata (builtins.map (_: "") metadata) string; constructKeys = dir: ( listToAttrs ( @@ -21,10 +17,7 @@ let map (file: { name = extractName file; value = readFile "${dir}/${subdir}/${file}"; - }) (filter (file: - (readDir "${dir}/${subdir}").${file} == "regular" && - lib.hasSuffix ".key" file - ) (attrNames (readDir "${dir}/${subdir}"))) + }) (filter (node: (readDir "${dir}/${subdir}").${node} == "regular") (attrNames (readDir "${dir}/${subdir}"))) ); }) (filter (node: (readDir dir).${node} == "directory") (attrNames (readDir dir))) ) diff --git a/src/user/config/keys/pgp/README.md b/src/user/config/keys/pgp/README.md deleted file mode 100644 index 50fb051..0000000 --- a/src/user/config/keys/pgp/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# PGP Keys - -yubikey.pub.key - -work.pub.key -> bryan.ramos@concurrent-rt.com -ccur.pub.key -> ? diff --git a/src/user/config/keys/pgp/ccur.pub.key b/src/user/config/keys/pgp/ccur.pub.key deleted file mode 100755 index 3ddf45c..0000000 --- a/src/user/config/keys/pgp/ccur.pub.key +++ /dev/null @@ -1,53 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -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 -uWsnbjV0Rg== -=56r2 ------END PGP PUBLIC KEY BLOCK----- diff --git a/src/user/config/keys/pgp/yubikey.pub.key b/src/user/config/keys/pgp/primary.pub.key similarity index 100% rename from src/user/config/keys/pgp/yubikey.pub.key rename to src/user/config/keys/pgp/primary.pub.key diff --git a/src/user/config/keys/pgp/work.pub.key b/src/user/config/keys/pgp/work.pub.key deleted file mode 100755 index 31e14fb..0000000 --- a/src/user/config/keys/pgp/work.pub.key +++ /dev/null @@ -1,121 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -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 -Vv2c5XcFneMcDVBQ28VlwQ2fbIoDokz3Iw== -=my/o ------END PGP PUBLIC KEY BLOCK----- diff --git a/src/user/config/keys/ssh/README.md b/src/user/config/keys/ssh/README.md deleted file mode 100644 index 2ebbe16..0000000 --- a/src/user/config/keys/ssh/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# SSH Keys - -yubikey.pub.key -> PGP derived from `pgp.yubikey.pub.key` -work.pub.key - ? -graphone.pub.key -> For Android `pass` diff --git a/src/user/config/keys/ssh/android.pub.key b/src/user/config/keys/ssh/android.pub.key new file mode 100644 index 0000000..190c93f --- /dev/null +++ b/src/user/config/keys/ssh/android.pub.key @@ -0,0 +1 @@ +"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJM1HutPcWXdeTaAXY7ha8SlgeZFtLJGwNa3Kd/DL/R38fq5+fkh3iCoHgv+iiKcordtVTMhbOsHhz3H+Jm274c=" diff --git a/src/user/config/keys/ssh/graphone.pub.key b/src/user/config/keys/ssh/graphone.pub.key deleted file mode 100644 index d07e510..0000000 --- a/src/user/config/keys/ssh/graphone.pub.key +++ /dev/null @@ -1 +0,0 @@ -ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJM1HutPcWXdeTaAXY7ha8SlgeZFtLJGwNa3Kd/DL/R38fq5+fkh3iCoHgv+iiKcordtVTMhbOsHhz3H+Jm274c= diff --git a/src/user/config/keys/ssh/primary.pub.key b/src/user/config/keys/ssh/primary.pub.key new file mode 100644 index 0000000..d031f50 --- /dev/null +++ b/src/user/config/keys/ssh/primary.pub.key @@ -0,0 +1 @@ +"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDl4895aB9P5p/lp8Hq5rHun4clvhyTSHFi3U2d6OOBoW5Fm+VcQnW/xbjmCBsXk5BdiowsBxQhwnzdfz/KJL7J5RobomUEaVRwb9UwT88eJveLp14BG8j2J3SjfyhrCX+4jkPx0bPQk1HGcuYY+tPEXf1q/ps88Dhu0CARBIzYQOTYY6b1qWzxpDoFZGHjKG8g5iY6FIu65yKKvvVy1f8IgZ3l3IpwBWVamxgkTcYY0QYSrmzo1n7TXxwrWbvenAqBsQ0cBPs+gVa3uIr+1TJl0Az5SElBVGu3LvUdlk58trtPUj6TQR3YUkg7Vjll7WHOdqhux5ZQNhjkOsHerf0Tw86e6cEzgeTuIbQHIb0LcsUunwKcuh2+au7RO599cvHn0+xZE5MZBxloDDaJ3JsiliM8kyPP/U3ERj03cWLW7BqbT+sfjAOl21RCzk0iQxk1wt/8VmtCr9Adv7IyrtaYvf/bwRP+g+9ldmzKGt8Mdb605uVzZ70H/LLm17f40Te+QHaex5by/6p6cuwEEZtgIg53Wpglu0rA6UxrBfQEHKl/Jt3FLeE0mnEyYkkR2MnHNtyWRIXtuqYZMAm2Ub1pFHH7jQV1gGiDVTw6a2eIwK21a/hXtRjFUpFd1nB1n+KNfJBE4zT3wm3Ud7mKw/6rWnoRyhYZvGXkFdp+iEs49Q==" diff --git a/src/user/config/keys/ssh/work.pub.key b/src/user/config/keys/ssh/work.pub.key deleted file mode 100644 index c4b3a55..0000000 --- a/src/user/config/keys/ssh/work.pub.key +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDXYU5c7AUD5tQQdpzQ73yy3ti3R7dArZ+f/wETN7L2Z2Hw6zo6hDid9/Q4yxdgM/FlTj/Ok2DHBWqxJsEe3S4shwsT9l2qJatjdcUK6zH3/0nFPxGYIaByj87aZ+5dwMoWNGlioPWciUdKeovvau1PwvdBxPabHHap6nwC9yPaSIVbZi4GgYv/zEvOB4LVYLuxLqr0pPdMNz1ddjmjsQCq5alC33jSZWkABERw3GlF02dNHbUq6cZlFq9BudbNWBQ8zFgj/C8amK4DHUSeU8w+ckTmO5PjDjINOnFr8kytDap+/5AQ6kr618evJ2JCwnBj6txb3SVGhcvn3/DJjf2H7flVhZEWIMEMu7452SXfz9mxp3Vu3UMJkjHUj6Lxl302M318k9j+w1fa8EHO7OQHQZajNKrEP5/UK2CDfpP2KIybX5HnEqBcEqoSKhRt7ytNX6VGzURk3/mmk9L+An5z7ve+zqlgNOA8uaIoebB4476+n5pGiNIedO3FRjPofEidYjf5NTZ9YDpqFc5KbfbhduuP63G/kqmgTxXMuTsWINY2xKEc0BPnlEGfezMN+eQpwWINOUxW1ZEk3OYMvC91EndbVwxVbm3aze9894T3+wVTipJ88xARCQeQpu1eaWDSaNduD+8LAouQiTA4whM+jBEeQoWZe6Wf6W4tBeCZ6Q== diff --git a/src/user/config/keys/ssh/yubikey.pub.key b/src/user/config/keys/ssh/yubikey.pub.key deleted file mode 100644 index a840349..0000000 --- a/src/user/config/keys/ssh/yubikey.pub.key +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDl4895aB9P5p/lp8Hq5rHun4clvhyTSHFi3U2d6OOBoW5Fm+VcQnW/xbjmCBsXk5BdiowsBxQhwnzdfz/KJL7J5RobomUEaVRwb9UwT88eJveLp14BG8j2J3SjfyhrCX+4jkPx0bPQk1HGcuYY+tPEXf1q/ps88Dhu0CARBIzYQOTYY6b1qWzxpDoFZGHjKG8g5iY6FIu65yKKvvVy1f8IgZ3l3IpwBWVamxgkTcYY0QYSrmzo1n7TXxwrWbvenAqBsQ0cBPs+gVa3uIr+1TJl0Az5SElBVGu3LvUdlk58trtPUj6TQR3YUkg7Vjll7WHOdqhux5ZQNhjkOsHerf0Tw86e6cEzgeTuIbQHIb0LcsUunwKcuh2+au7RO599cvHn0+xZE5MZBxloDDaJ3JsiliM8kyPP/U3ERj03cWLW7BqbT+sfjAOl21RCzk0iQxk1wt/8VmtCr9Adv7IyrtaYvf/bwRP+g+9ldmzKGt8Mdb605uVzZ70H/LLm17f40Te+QHaex5by/6p6cuwEEZtgIg53Wpglu0rA6UxrBfQEHKl/Jt3FLeE0mnEyYkkR2MnHNtyWRIXtuqYZMAm2Ub1pFHH7jQV1gGiDVTw6a2eIwK21a/hXtRjFUpFd1nB1n+KNfJBE4zT3wm3Ud7mKw/6rWnoRyhYZvGXkFdp+iEs49Q== diff --git a/src/user/config/nvim b/src/user/config/nvim deleted file mode 120000 index de5a93f..0000000 --- a/src/user/config/nvim +++ /dev/null @@ -1 +0,0 @@ -../modules/utils/modules/neovim/config/nvim \ No newline at end of file diff --git a/src/user/config/vim b/src/user/config/vim deleted file mode 120000 index 2ab4c21..0000000 --- a/src/user/config/vim +++ /dev/null @@ -1 +0,0 @@ -../modules/utils/modules/vim/vim/ \ No newline at end of file diff --git a/src/user/default.nix b/src/user/default.nix index ca18159..7c1eaf9 100644 --- a/src/user/default.nix +++ b/src/user/default.nix @@ -4,15 +4,10 @@ let entries = builtins.readDir dir; names = builtins.attrNames entries; - excludedDirs = [ "config" "scripts" ]; - isSubmodule = path: - builtins.pathExists "${path}/.git" && - builtins.readFileType "${path}/.git" == "regular"; - isModuleDir = path: + isModuleDir = path: builtins.pathExists path && builtins.readFileType path == "directory" && - !(builtins.elem (builtins.baseNameOf path) excludedDirs) && - !(isSubmodule path); + builtins.baseNameOf path != "config"; isModule = file: file == "default.nix"; isNix = file: builtins.match ".*\\.nix" file != null && file != "default.nix"; @@ -24,9 +19,9 @@ let if isModuleDir path then mkModules path false else if isModule name && !isRoot then - [ dir ] + [dir] else if isNix name then - [ path ] + [path] else [] ) names; diff --git a/src/user/modules/bash/config/alias.nix b/src/user/modules/bash/config/alias.nix new file mode 100644 index 0000000..321631d --- /dev/null +++ b/src/user/modules/bash/config/alias.nix @@ -0,0 +1,17 @@ +{ lib, config, ... }: + +with lib; +let + gui = config.modules.user.gui.wm; + wm = { + enable = builtins.any (mod: mod.enable or false) (builtins.attrValues gui); + }; + +in +{ + cd = "cd -L"; + grep = "grep --color"; + tree = "eza --tree --icons=never"; + lt = mkForce "eza --tree --icons=never"; + open = mkIf wm.enable "xdg-open"; +} diff --git a/src/user/modules/bash/config/bash b/src/user/modules/bash/config/bash deleted file mode 160000 index 79eb823..0000000 --- a/src/user/modules/bash/config/bash +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 79eb823bbb9ff88f284ae055fe1de954df8bf2e0 diff --git a/src/user/modules/bash/config/bashrc.nix b/src/user/modules/bash/config/bashrc.nix new file mode 100644 index 0000000..09dfa49 --- /dev/null +++ b/src/user/modules/bash/config/bashrc.nix @@ -0,0 +1,6 @@ +'' +set -o vi + +bind 'set completion-ignore-case on' +bind 'set completion-map-case on' +'' diff --git a/src/user/modules/bash/config/prompt.nix b/src/user/modules/bash/config/prompt.nix new file mode 100644 index 0000000..6396b0e --- /dev/null +++ b/src/user/modules/bash/config/prompt.nix @@ -0,0 +1,155 @@ +{ config, lib, ... }: + +with lib; +let + git = config.modules.user.git; + gui = config.modules.user.gui.alacritty; + +in +'' +check_ssh() { + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + ssh_PS1="\n\[\033[01;37m\]\u@\h:\[\033[00m\]\n" + return 0 + fi +} + +${optionalString git.enable '' +check_venv() { + add_icon() { + local icon=$1 + if [[ ! $venv_icons =~ $icon ]]; then + venv_icons+="$icon " + fi + } + + remove_icon() { + local icon=$1 + venv_icons=''${venv_icons//$icon/} + } + + py="py" + js="js" + nix="nix" + + ${if gui.enable then '' + if [ -n "$DISPLAY" ]; then + py="" + js="󰌞" + nix="οŒ“" + fi + '' else '' + ''} + + python_icon="\[\033[01;33m\]$py\[\033[00m\]" + node_icon="\[\033[01;93m\]$js\[\033[00m\]" + nix_icon="\[\033[01;34m\]$nix\[\033[00m\]" + + if [ -n "$IN_NIX_SHELL" ]; then + add_icon "$nix_icon" + else + remove_icon "$nix_icon" + fi + + if [ -n "$VIRTUAL_ENV" ]; then + add_icon "$python_icon" + else + remove_icon "$python_icon" + fi + + if [ -d "''${git_root}/node_modules" ]; then + add_icon "$node_icon" + else + remove_icon "$node_icon" + fi +} + +set_git_dir() { + ${if gui.enable then '' + if [ -n "$DISPLAY" ]; then + project_icon="ξ­… " + else + project_icon="../" + fi + '' else '' + project_icon="../" + ''} + local superproject_root=$(git rev-parse --show-superproject-working-tree 2>/dev/null) + if [[ -n "$superproject_root" ]]; then + local submodule_name=$(basename "$git_root") + + working_dir="\[\033[01;34m\]$project_icon''${superproject_root##*/}/$submodule_name$git_curr_dir\[\033[00m\]" + elif [ "$git_curr_dir" == "." ]; then + working_dir="\[\033[01;34m\]$project_icon$git_root_dir\[\033[00m\]" + return 0 + else + working_dir="\[\033[01;34m\]$project_icon$git_root_dir$git_curr_dir\[\033[00m\]" + return 0 + fi +} + +relative_path() { + local absolute_target=$(readlink -f "$1") + local absolute_base=$(readlink -f "$2") + echo "''${absolute_target#$absolute_base}" +} + +check_project() { + local git_root=$(git rev-parse --show-toplevel 2>/dev/null) + + if [ -n "$git_root" ]; then + local git_branch=$(git branch --show-current 2>/dev/null) + + if [ -z "$git_branch" ]; then + git_branch=$(git describe --tags --exact-match 2>/dev/null) + git_branch=''${git_branch:-$(git rev-parse --short HEAD 2>/dev/null)} + fi + + local git_curr_dir=$(relative_path "." "$git_root") + local git_root_dir=$(basename "$git_root") + + ${if gui.enable then '' + if [ -n "$DISPLAY" ]; then + git_branch_PS1="\[\033[01;31m\]$git_branch 󰘬:\[\033[00m\]" + else + git_branch_PS1="\[\033[01;31m\]$git_branch:\[\033[00m\]" + fi + '' else '' + git_branch_PS1="\[\033[01;31m\]$git_branch:\[\033[00m\]" + ''} + + set_git_dir + check_venv + + return 0 + fi +} +''} + +function set_prompt() { + local green_arrow="\[\033[01;32m\]>> " + local white_text="\[\033[00m\]" + local working_dir="\[\033[01;34m\]\w\[\033[00m\]" + + local ssh_PS1 + + check_ssh + + ${optionalString git.enable '' + local venv_icons + local git_branch_PS1 + + check_project + ''} + + ${if git.enable + then + ''PS1="$ssh_PS1$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"'' + else + ''PS1="$ssh_PS1$working_dir\n$green_arrow$white_text"'' + } + return 0 +} + +PROMPT_COMMAND="set_prompt" +'' diff --git a/src/user/modules/bash/config/shellHook.nix b/src/user/modules/bash/config/shellHook.nix index a252b83..be94e35 100644 --- a/src/user/modules/bash/config/shellHook.nix +++ b/src/user/modules/bash/config/shellHook.nix @@ -29,7 +29,7 @@ case $- in fi ''} ${optionalString tmux.enable '' - if [ -z "$DISPLAY" ] && [ -z "$TMUX" ] && [ -z "$SSH_TTY" ]; then + if [ -z "$DISPLAY" ] && [ -z "$TMUX" ]; then exec tmux fi ''} diff --git a/src/user/modules/bash/default.nix b/src/user/modules/bash/default.nix index 1dc7110..601d69a 100644 --- a/src/user/modules/bash/default.nix +++ b/src/user/modules/bash/default.nix @@ -9,15 +9,13 @@ in config = mkIf cfg.enable { programs.bash = { enable = true; - initExtra = "source ~/.config/bash/bashrc"; + enableCompletion = true; + + initExtra = import ./config/prompt.nix { inherit lib config; }; + bashrcExtra = import ./config/bashrc.nix; + shellAliases = import ./config/alias.nix { inherit lib config; }; profileExtra = import ./config/shellHook.nix { inherit lib config; }; }; - - # .bashrc - home.file.".config/bash" = { - source = ./config/bash; - recursive = true; - }; programs = { ripgrep.enable = true; diff --git a/src/user/modules/git/scripts/cdg.nix b/src/user/modules/git/config/bashScripts/cdg.nix similarity index 100% rename from src/user/modules/git/scripts/cdg.nix rename to src/user/modules/git/config/bashScripts/cdg.nix diff --git a/src/user/modules/git/default.nix b/src/user/modules/git/default.nix index 26baea5..cb02bbd 100644 --- a/src/user/modules/git/default.nix +++ b/src/user/modules/git/default.nix @@ -10,23 +10,44 @@ in programs = { git = { enable = true; - }; + package = pkgs.gitSVN; + extraConfig = { + init = { defaultBranch = "master"; }; + #format = { pretty = "oneline"; }; + #log = { abbrevCommit = true; }; + mergetool = { + vimdiff = { + trustExitCode = true; + }; + }; + merge = { tool = "vimdiff"; }; + safe = { + directory = [ + "/etc/nixos" + "/boot" + ]; + }; + }; + ignores = [ + "node_modules" + ".direnv" + "dist-newstyle" + ".nuxt/" + ".output/" + "dist" + "result" + ]; + } // config.user.gitConfig; gh = { enable = true; settings.git_protocol = "ssh"; }; }; - home = { - packages = with pkgs; [ - git-crypt - ]; - file.".config/git" = { - source = ./git; - recursive = true; - }; - }; + home.packages = with pkgs; [ + git-crypt + ]; - programs.bash.initExtra = import ./scripts/cdg.nix; + programs.bash.initExtra = import ./config/bashScripts/cdg.nix; }; } diff --git a/src/user/modules/git/git b/src/user/modules/git/git deleted file mode 160000 index d394ee0..0000000 --- a/src/user/modules/git/git +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d394ee0594e8b1162f05547c3f7da817b6fcb62a diff --git a/src/user/modules/gui/modules/alacritty/config/alacritty.nix b/src/user/modules/gui/modules/alacritty/config/alacritty.nix index b396d7c..7e7ea9b 100644 --- a/src/user/modules/gui/modules/alacritty/config/alacritty.nix +++ b/src/user/modules/gui/modules/alacritty/config/alacritty.nix @@ -54,22 +54,22 @@ in font = { size = 12; normal = { - family = "Terminess Nerd Font Propo"; + family = "Terminus"; style = "Regular"; }; bold = { - family = "Terminess Nerd Font Propo"; + family = "Terminus"; style = "Bold"; }; italic = { - family = "Terminess Nerd Font Propo"; + family = "Terminus"; style = "Italic"; }; bold_italic = { - family = "Terminess Nerd Font Propo"; + family = "Terminus"; style = "Bold Italic"; }; }; diff --git a/src/user/modules/gui/modules/browsers/chromium/config/extensions/browserpass.crx b/src/user/modules/gui/modules/browsers/chromium/config/extensions/browserpass.crx new file mode 100644 index 0000000..de1cdbc Binary files /dev/null and b/src/user/modules/gui/modules/browsers/chromium/config/extensions/browserpass.crx differ diff --git a/src/user/modules/gui/modules/browsers/chromium/config/extensions/ublock.crx b/src/user/modules/gui/modules/browsers/chromium/config/extensions/ublock.crx new file mode 100644 index 0000000..83b75ae Binary files /dev/null and b/src/user/modules/gui/modules/browsers/chromium/config/extensions/ublock.crx differ diff --git a/src/user/modules/gui/modules/browsers/chromium/config/extensions/vimium.crx b/src/user/modules/gui/modules/browsers/chromium/config/extensions/vimium.crx new file mode 100644 index 0000000..bdcead1 Binary files /dev/null and b/src/user/modules/gui/modules/browsers/chromium/config/extensions/vimium.crx differ diff --git a/src/user/modules/gui/modules/browsers/chromium/default.nix b/src/user/modules/gui/modules/browsers/chromium/default.nix index bf9c59c..ec67982 100644 --- a/src/user/modules/gui/modules/browsers/chromium/default.nix +++ b/src/user/modules/gui/modules/browsers/chromium/default.nix @@ -8,40 +8,24 @@ in { options.modules.user.gui.browser.chromium = { enable = mkEnableOption "Enable Chromium browser"; }; config = mkIf cfg.enable { programs = { - chromium = rec { + chromium = { enable = true; package = pkgs.ungoogled-chromium; - extensions = - let - vrs = package.version; - in - [ - rec { + extensions = [ + { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; - crxPath = builtins.fetchurl { - url = "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=${vrs}&acceptformat=crx2,crx3&x=id%3D${id}%26uc"; - name = "ublock_${version}.crx"; - sha256 = "0ycnkna72n969crgxfy2lc1qbndjqrj46b9gr5l9b7pgfxi5q0ll"; - }; - version = "1.62.0"; + crxPath = /home/${config.user.name}/.config/chromium/Extensions/ublock.crx; + version = "1.58.0"; } - rec { + { id = "dbepggeogbaibhgnhhndojpepiihcmeb"; - crxPath = builtins.fetchurl { - url = "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=${vrs}&acceptformat=crx2,crx3&x=id%3D${id}%26uc"; - name = "vimium_${version}.crx"; - sha256 = "0m8xski05w2r8igj675sxrlkzxlrl59j3a7m0r6c8pwcvka0r88d"; - }; + crxPath = /home/${config.user.name}/.config/chromium/Extensions/vimium.crx; version = "2.1.2"; } - rec { + { id = "naepdomgkenhinolocfifgehidddafch"; - crxPath = builtins.fetchurl { - url = "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=${vrs}&acceptformat=crx2,crx3&x=id%3D${id}%26uc"; - name = "browserpass_${version}.crx"; - sha256 = "074sc9hxh7vh5j79yjhsrnhb5k4dv3bh5vip0jr30hkkni7nygbd"; - }; - version = "3.9.0"; + crxPath = /home/${config.user.name}/.config/chromium/Extensions/browserpass.crx; + version = "3.8.0"; } ]; }; @@ -49,5 +33,12 @@ in enable = true; }; }; + + home = { + file.".config/chromium/Extensions" = { + source = ./config/extensions; + recursive = true; + }; + }; }; } diff --git a/src/user/modules/gui/modules/browsers/firefox/default.nix b/src/user/modules/gui/modules/browsers/firefox/default.nix index d414e87..e9adec6 100644 --- a/src/user/modules/gui/modules/browsers/firefox/default.nix +++ b/src/user/modules/gui/modules/browsers/firefox/default.nix @@ -22,7 +22,7 @@ let }; assertions = let - pinentry = config.services.gpg-agent.pinentry.package; + pinentry = config.services.gpg-agent.pinentryPackage; in [ { @@ -41,29 +41,17 @@ in profiles = { "${config.user.name}" = { isDefault = true; - #bookmarks = config.user.bookmarks; - - extensions = { - packages = with pkgs.nur.repos.rycee.firefox-addons; [ - ublock-origin - tridactyl - #darkreader - tampermonkey - clearurls - passff - multi-account-containers - ]; - }; + bookmarks = config.user.bookmarks; search = { force = true; - default = "google"; + default = "Google"; engines = { "Startpage" = { urls = [{ template = "https://www.startpage.com/sp/search?q={searchTerms}"; }]; - icon = "https://www.startpage.com/sp/cdn/favicons/favicon--default.ico"; + iconUpdateURL = "https://www.startpage.com/sp/cdn/favicons/favicon--default.ico"; }; }; }; @@ -318,12 +306,15 @@ in "media.videocontrols.picture-in-picture.enabled" = false; }; - }; - }; - policies = { - WebsiteFilter = { - Block = [ - "*://*.pokemonshowdown.com/*" + + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + ublock-origin + tridactyl + #darkreader + tampermonkey + clearurls + passff + multi-account-containers ]; }; }; diff --git a/src/user/modules/gui/modules/corn/default.nix b/src/user/modules/gui/modules/corn/default.nix index 712c6fb..d28a00c 100644 --- a/src/user/modules/gui/modules/corn/default.nix +++ b/src/user/modules/gui/modules/corn/default.nix @@ -8,29 +8,29 @@ in { options.modules.user.gui.corn = { enable = mkEnableOption "Enable Bitcoin client applications"; }; config = mkIf cfg.enable { home.packages = with pkgs; [ - #trezor-suite - #trezorctl - #trezord + trezor-suite + trezorctl + trezord sparrow ]; - #systemd.user.services = { - # trezord = { - # Unit = { - # Description = "Trezor Bridge"; - # After = [ "network.target" ]; - # Wants = [ "network.target" ]; - # PartOf = [ "graphical-session.target" ]; - # }; - # Service = { - # ExecStart = "${pkgs.trezord}/bin/trezord-go"; - # Restart = "always"; - # }; - # Install = { - # WantedBy = [ "default.target" ]; - # }; - # }; - #}; + systemd.user.services = { + trezord = { + Unit = { + Description = "Trezor Bridge"; + After = [ "network.target" ]; + Wants = [ "network.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${pkgs.trezord}/bin/trezord-go"; + Restart = "always"; + }; + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; }; } diff --git a/src/user/modules/gui/modules/fun/default.nix b/src/user/modules/gui/modules/fun/default.nix index 8b3422c..e631657 100644 --- a/src/user/modules/gui/modules/fun/default.nix +++ b/src/user/modules/gui/modules/fun/default.nix @@ -7,17 +7,17 @@ let in { options.modules.user.gui.fun = { enable = mkEnableOption "Enable entertainment apps"; }; config = mkIf cfg.enable { - #programs.obs-studio = { - # enable = true; - # plugins = with pkgs.obs-studio-plugins; [ - # wlrobs - # obs-pipewire-audio-capture - # input-overlay - # ]; - #}; + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + wlrobs + obs-pipewire-audio-capture + input-overlay + ]; + }; home.packages = with pkgs; [ - ytmdesktop + spotify discordo webcord ]; diff --git a/src/user/modules/gui/modules/writing/default.nix b/src/user/modules/gui/modules/writing/default.nix index 664d5fe..96de412 100644 --- a/src/user/modules/gui/modules/writing/default.nix +++ b/src/user/modules/gui/modules/writing/default.nix @@ -9,9 +9,9 @@ in config = mkIf cfg.enable { home.packages = with pkgs; [ mdbook + texlive.combined.scheme-tetex pandoc asciidoctor - evince ]; }; } diff --git a/src/user/modules/gui/wm/hyprland/config/rofi/default.nix b/src/user/modules/gui/wm/hyprland/config/rofi/default.nix index 724fd55..6a6a5f4 100644 --- a/src/user/modules/gui/wm/hyprland/config/rofi/default.nix +++ b/src/user/modules/gui/wm/hyprland/config/rofi/default.nix @@ -5,7 +5,7 @@ let in { enable = true; - package = pkgs.rofi; + package = pkgs.rofi-wayland; location = "center"; terminal = "\${pkgs.alacritty}/bin/alacritty"; plugins = with pkgs; [ diff --git a/src/user/modules/gui/wm/hyprland/config/waybar/config b/src/user/modules/gui/wm/hyprland/config/waybar/config index 3bb7b94..451719f 100644 --- a/src/user/modules/gui/wm/hyprland/config/waybar/config +++ b/src/user/modules/gui/wm/hyprland/config/waybar/config @@ -2,7 +2,7 @@ "layer": "top", "position": "top", "output": "HDMI-A-1", - "modules-left": [ "custom/logo", "clock", "custom/blockheight", "custom/price", "memory", "cpu" ], + "modules-left": [ "custom/logo", "clock", "custom/weather", "custom/blockheight", "custom/price", "memory", "cpu" ], "modules-center": [ "hyprland/workspaces" ], "modules-right": [ "tray", "pulseaudio", "network" ], "reload_style_on_change":true, @@ -10,7 +10,7 @@ "custom/logo": { "format": "οŒ“", "tooltip": false, - "on-click": "alacritty --class sys-specs -e bash -c 'fastfetch; read -n 1'" + "on-click": "alacritty -e neofetch" }, "hyprland/workspaces": { @@ -75,7 +75,7 @@ "cpu": { "interval": 1, - "format": "ο’Ό {usage}%", + "format": "ο’Ό {usage}%", "min-length": 6, "max-length": 6, "format-icons": ["▁", "β–‚", "β–ƒ", "β–„", "β–…", "β–†", "β–‡", "β–ˆ"], @@ -108,7 +108,7 @@ "default": ["","ο€§",""] }, "justify": "center", - "on-click": "alacritty -e pulsemixer", + "on-click": "pavucontrol", "tooltip-format": "{volume}%" }, diff --git a/src/user/modules/gui/wm/hyprland/config/waybar/scripts/getPrice b/src/user/modules/gui/wm/hyprland/config/waybar/scripts/getPrice index 5d85c7f..18c24eb 100755 Binary files a/src/user/modules/gui/wm/hyprland/config/waybar/scripts/getPrice and b/src/user/modules/gui/wm/hyprland/config/waybar/scripts/getPrice differ diff --git a/src/user/modules/gui/wm/hyprland/config/waybar/style.css b/src/user/modules/gui/wm/hyprland/config/waybar/style.css index 06911c7..58e36c5 100644 --- a/src/user/modules/gui/wm/hyprland/config/waybar/style.css +++ b/src/user/modules/gui/wm/hyprland/config/waybar/style.css @@ -1,7 +1,7 @@ * { border: none; font-size: 14px; - font-family: "Terminus Nerd Font Propo" ; + font-family: "Terminus" ; min-height: 25px; } diff --git a/src/user/modules/gui/wm/hyprland/default.nix b/src/user/modules/gui/wm/hyprland/default.nix index e57625a..3c06190 100644 --- a/src/user/modules/gui/wm/hyprland/default.nix +++ b/src/user/modules/gui/wm/hyprland/default.nix @@ -1,19 +1,16 @@ -{ pkgs, lib, config, monitors ? [], ... }: +{ pkgs, lib, config, ... }: with lib; let cfg = config.modules.user.gui.wm.hyprland; - + wallpaper = builtins.fetchurl { url = "https://images6.alphacoders.com/117/1174033.png"; sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; }; - toHyprlandMonitor = m: - "${m.name}, ${toString m.width}x${toString m.height}@${toString m.refreshRate}, ${toString m.x}x${toString m.y}, ${toString m.scale}"; - in -{ options.modules.user.gui.wm.hyprland = { enable = mkEnableOption "Enable Hyprland WM"; }; +{ options.modules.user.gui.wm.hyprland = { enable = mkEnableOption "Enable hyprland module"; }; config = mkIf cfg.enable { wayland.windowManager.hyprland = { enable = true; @@ -24,13 +21,13 @@ in "$terminal" = "${pkgs.alacritty}/bin/alacritty"; "$menu" = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; - monitor = if monitors != [] - then map toHyprlandMonitor monitors - else [ ", preferred, auto, 1" ]; + monitor = [ + "HDMI-A-1, 1920x1080, 0x0, 1" + "DP-1, 1920x1080, 1920x0, 1" + ]; exec-once = [ "waybar" - "hyprctl setcursor Vanilla-DMZ 24" ]; bind = [ @@ -50,9 +47,9 @@ in "$mod, F, fullscreen" ", Print, exec, grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png" - "$mod&SHIFT, Print, exec, grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png" + "SHIFT, Print, exec, grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png" "$mod&SHIFT, F, exec, alacritty -e sh -c 'EDITOR=nvim ranger'" - ''SHIFT, Print, exec, grim -g "$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png'' + #''$mod&SHIFT, Print, exec, sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png'"'' "$mod, D, exec, $menu" "$mod&SHIFT, D, exec, rofi -modi emoji -show emoji" @@ -77,7 +74,6 @@ in windowrulev2 = [ "float, title:(Android Emulator)" "float, title: Extension: (PassFF)" - "float, size 400 600, stayfocused, class:sys-specs" ]; general = { @@ -98,21 +94,12 @@ in kb_layout = "us"; follow_mouse = 1; accel_profile = "flat"; - sensitivity = 0.35; - }; - - cursor = { - inactive_timeout = 0; - no_hardware_cursors = true; - hide_on_touch = false; - use_cpu_buffer = 0; - enable_hyprcursor = false; + sensitivity = 0; }; env = [ - "HYPRCURSOR_THEME,Vanilla-DMZ" - "HYPRCURSOR_SIZE,24" - "GTK_THEME,Juno" + "HYPRCURSOR_SIZE, 24" + "GTK_THEME, Juno-ocean" "LIBVA_DRIVER_NAME,nvidia" "XDG_SESSION_TYPE,wayland" @@ -124,7 +111,7 @@ in programs.rofi = { enable = true; - package = pkgs.rofi; + package = pkgs.rofi-wayland; location = "center"; terminal = "alacritty"; plugins = with pkgs; [ @@ -145,7 +132,7 @@ in }; packages = with pkgs; [ - pulsemixer + pavucontrol xdg-utils wl-clipboard cliphist @@ -159,9 +146,10 @@ in ranger highlight + terminus-nerdfont noto-fonts - noto-fonts-cjk-sans - noto-fonts-color-emoji + noto-fonts-cjk + noto-fonts-emoji ]; sessionVariables = { @@ -192,17 +180,13 @@ in gtk = { enable = true; theme = { - name = "Juno"; + name = "Juno-ocean"; package = pkgs.juno-theme; }; iconTheme = { name = "Qogir"; package = pkgs.qogir-icon-theme; }; - cursorTheme = { - package = pkgs.vanilla-dmz; - name = "Vanilla-DMZ"; - }; gtk3.extraConfig = { gtk-application-prefer-dark-theme = 1; }; @@ -214,20 +198,18 @@ in qt = { enable = true; style = { - name = "juno"; + name = "juno-ocean"; package = pkgs.juno-theme; }; platformTheme.name = "gtk"; }; - xdg = { - portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-hyprland - ]; - config.common.default = "*"; - }; + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-hyprland + ]; + config.common.default = "*"; }; programs = { diff --git a/src/user/modules/gui/wm/i3/config/rofi/config/config.rasi b/src/user/modules/gui/wm/i3/config/rofi/config/config.rasi deleted file mode 100644 index 2e38cf2..0000000 --- a/src/user/modules/gui/wm/i3/config/rofi/config/config.rasi +++ /dev/null @@ -1,7 +0,0 @@ -configuration { - font: "SF Pro Rounded 10"; - show-icons: true; - kb-cancel: "Escape,Alt+F1"; -} - -@theme "~/.config/rofi/material-ocean.rasi" diff --git a/src/user/modules/gui/wm/i3/config/rofi/config/material-ocean.rasi b/src/user/modules/gui/wm/i3/config/rofi/config/material-ocean.rasi deleted file mode 100644 index 3533a13..0000000 --- a/src/user/modules/gui/wm/i3/config/rofi/config/material-ocean.rasi +++ /dev/null @@ -1,95 +0,0 @@ -* { - background: #0f111a; - foreground: #f1f1f1; - selected: #ff4151; -} - -window { - transparency: "real"; - background-color: @background; - text-color: @foreground; -} - -prompt { - enabled: true; - padding: 4px 4px 6px 6px; - background-color: @background; - text-color: @foreground; -} - -textbox-prompt-colon { - expand: false; - background-color: @background; - padding: 4px 0px 0px 6px; -} - -inputbar { - children: [ textbox-prompt-colon, entry ]; - background-color: @background; - text-color: @foreground; - expand: false; - border: 0px 0px 0px 0px; - border-radius: 0px; - border-color: @selected; - margin: 0px 0px 0px 0px; - padding: 0px 0px 4px 0px; - position: center; -} - -entry { - background-color: @background; - text-color: @foreground; - placeholder-color: @foreground; - expand: true; - horizontal-align: 0; - blink: true; - padding: 4px 0px 0px 4px; -} - -case-indicator { - background-color: @background; - text-color: @foreground; - spacing: 0; -} - -listview { - background-color: @background; - columns: 1; - spacing: 5px; - cycle: true; - dynamic: true; - layout: vertical; -} - -mainbox { - background-color: @background; - children: [ inputbar, listview ]; - spacing: 5px; - padding: 5px 5px 5px 5px; -} - -element { - background-color: @background; - text-color: @foreground; - orientation: horizontal; - border-radius: 4px; - padding: 6px 6px 6px 6px; -} - -element-text, element-icon { - background-color: inherit; - text-color: inherit; -} - -element-icon { - size: 18px; - border: 4px; -} - -element selected { - background-color: @selected; - text-color: @background; - border: 0px; - border-radius: 0px; - border-color: @selected; -} diff --git a/src/user/modules/gui/wm/i3/config/rofi/default.nix b/src/user/modules/gui/wm/i3/config/rofi/default.nix deleted file mode 100644 index 724fd55..0000000 --- a/src/user/modules/gui/wm/i3/config/rofi/default.nix +++ /dev/null @@ -1,183 +0,0 @@ -{ pkgs, config, ... }: -let - inherit (config.lib.formats.rasi) mkLiteral; - -in -{ - enable = true; - package = pkgs.rofi; - location = "center"; - terminal = "\${pkgs.alacritty}/bin/alacritty"; - plugins = with pkgs; [ - rofi-emoji - ]; - - #theme = { - # "*" = { - # nord0 = mkLiteral "#2e3440"; - # nord1 = mkLiteral "#3b4252"; - # nord2 = mkLiteral "#434c5e"; - # nord3 = mkLiteral "#4c566a"; - # nord4 = mkLiteral "#d8dee9"; - # nord5 = mkLiteral "#e5e9f0"; - # nord6 = mkLiteral "#eceff4"; - # nord7 = mkLiteral "#8fbcbb"; - # nord8 = mkLiteral "#88c0d0"; - # nord9 = mkLiteral "#81a1c1"; - # nord10 = mkLiteral "#5e81ac"; - # nord11 = mkLiteral "#bf616a"; - # nord12 = mkLiteral "#d08770"; - # nord13 = mkLiteral "#ebcb8b"; - # nord14 = mkLiteral "#a3be8c"; - # nord15 = mkLiteral "#b48ead"; - # spacing = 2; - # background-color = mkLiteral "var(nord1)"; - # background = mkLiteral "var(nord1)"; - # foreground = mkLiteral "var(nord4)"; - # normal-background = mkLiteral "var(background)"; - # normal-foreground = mkLiteral "var(foreground)"; - # alternate-normal-background = mkLiteral "var(background)"; - # alternate-normal-foreground = mkLiteral "var(foreground)"; - # selected-normal-background = mkLiteral "var(nord8)"; - # selected-normal-foreground = mkLiteral "var(background)"; - # active-background = mkLiteral "var(background)"; - # active-foreground = mkLiteral "var(nord10)"; - # alternate-active-background = mkLiteral "var(background)"; - # alternate-active-foreground = mkLiteral "var(nord10)"; - # selected-active-background = mkLiteral "var(nord10)"; - # selected-active-foreground = mkLiteral "var(background)"; - # urgent-background = mkLiteral "var(background)"; - # urgent-foreground = mkLiteral "var(nord11)"; - # alternate-urgent-background = mkLiteral "var(background)"; - # alternate-urgent-foreground = mkLiteral "var(nord11)"; - # selected-urgent-background = mkLiteral "var(nord11)"; - # selected-urgent-foreground = mkLiteral "var(background)"; - # }; - # - # element = { - # padding = mkLiteral "0px 0px 0px 7px"; - # spacing = mkLiteral "5px"; - # border = 0; - # cursor = mkLiteral "pointer"; - # }; - - # "element normal.normal" = { - # background-color = mkLiteral "var(normal-background)"; - # text-color = mkLiteral "var(normal-foreground)"; - # }; - - # "element normal.urgent" = { - # background-color = mkLiteral "var(urgent-background)"; - # text-color = mkLiteral "var(urgent-foreground)"; - # }; - - # "element normal.active" = { - # background-color = mkLiteral "var(active-background)"; - # text-color = mkLiteral "var(active-foreground)"; - # }; - - # "element selected.normal" = { - # background-color = mkLiteral "var(selected-normal-background)"; - # text-color = mkLiteral "var(selected-normal-foreground)"; - # }; - - # "element selected.urgent" = { - # background-color = mkLiteral "var(selected-urgent-background)"; - # text-color = mkLiteral "var(selected-urgent-foreground)"; - # }; - - # "element selected.active" = { - # background-color = mkLiteral "var(selected-active-background)"; - # text-color = mkLiteral "var(selected-active-foreground)"; - # }; - - # "element alternate.normal" = { - # background-color = mkLiteral "var(alternate-normal-background)"; - # text-color = mkLiteral "var(alternate-normal-foreground)"; - # }; - - # "element alternate.urgent" = { - # background-color = mkLiteral "var(alternate-urgent-background)"; - # text-color = mkLiteral "var(alternate-urgent-foreground)"; - # }; - - # "element alternate.active" = { - # background-color = mkLiteral "var(alternate-active-background)"; - # text-color = mkLiteral "var(alternate-active-foreground)"; - # }; - - # "element-text" = { - # background-color = mkLiteral "rgba(0, 0, 0, 0%)"; - # text-color = mkLiteral "inherit"; - # highlight = mkLiteral "inherit"; - # cursor = mkLiteral "inherit"; - # }; - - # "element-icon" = { - # background-color = mkLiteral "rgba(0, 0, 0, 0%)"; - # size = mkLiteral "1.0000em"; - # text-color = mkLiteral "inherit"; - # cursor = mkLiteral "inherit"; - # }; - - # window = { - # padding = 0; - # border = 0; - # background-color = mkLiteral "var(background)"; - # }; - - # mainbox = { - # padding = 0; - # border = 0; - # }; - - # message = { - # margin = mkLiteral "0px 7px"; - # }; - - # textbox = { - # text-color = mkLiteral "var(foreground)"; - # }; - - # listview = { - # margin = mkLiteral "0px 0px 5px"; - # scrollbar = true; - # spacing = mkLiteral "2px"; - # fixed-height = 0; - # }; - - # scrollbar = { - # padding = 0; - # handle-width = mkLiteral "14px"; - # border = 0; - # handle-color = mkLiteral "var(nord3)"; - # }; - - # button = { - # spacing = 0; - # text-color = mkLiteral "var(normal-foreground)"; - # cursor = mkLiteral "pointer"; - # }; - - # "button selected" = { - # background-color = mkLiteral "var(selected-normal-background)"; - # text-color = mkLiteral "var(selected-normal-foreground)"; - # }; - - # inputbar = { - # padding = mkLiteral "7px"; - # margin = mkLiteral "7px"; - # spacing = 0; - # text-color = mkLiteral "var(normal-foreground)"; - # background-color = mkLiteral "var(nord3)"; - # children = [ "entry" ]; - # }; - - # entry = { - # spacing = 0; - # cursor = mkLiteral "text"; - # text-color = mkLiteral "var(normal-foreground)"; - # background-color = mkLiteral "var(nord3)"; - # }; - #}; -} diff --git a/src/user/modules/gui/wm/i3/default.nix b/src/user/modules/gui/wm/i3/default.nix deleted file mode 100644 index 4617ee3..0000000 --- a/src/user/modules/gui/wm/i3/default.nix +++ /dev/null @@ -1,144 +0,0 @@ -{ pkgs, lib, config, ... }: - -with lib; -let - cfg = config.modules.user.gui.wm.sway; - modifier = config.wayland.windowManager.sway.config.modifier; - - wallpaper = builtins.fetchurl { - url = "https://images6.alphacoders.com/117/1174033.png"; - sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; - }; - - barStatus = pkgs.writeShellScript "status.sh" '' - #!/usr/bin/env bash - while :; do - echo "$(ip -4 addr show eno1 | awk '/inet / {print $2}' | cut -d'/' -f1) | $(free -h | awk '/^Mem/ {print $3}') | $(date +'%I:%M:%S %p') | $(date +'%m-%d-%Y')"; sleep 1; - done - ''; - -in -{ options.modules.user.gui.wm.i3 = { enable = mkEnableOption "Enable i3 WM"; }; - config = mkIf cfg.enable { - xsession = { - enable = true; - windowManager.i3 = { - config = { - defaultWorkspace = "workspace number 1"; - - fonts = { - names = [ "Terminus" ]; - }; - - modifier = "Mod1"; - menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; - terminal = "${pkgs.alacritty}/bin/alacritty"; - - bars = [ - { - position = "top"; - statusCommand = "${barStatus}"; - fonts = { - names = [ "Terminus" ]; - size = 12.0; - }; - colors = { - background = "#0A0E14"; - statusline = "#FFFFFF"; - }; - } - ]; - - gaps = { - smartGaps = false; - inner = 10; - }; - - floating = { - titlebar = false; - border = 0; - criteria = [ - { - title = "Android Emulator"; - } - ]; - }; - - window = { - titlebar = false; - border= 0; - }; - - keybindings = lib.mkOptionDefault { - "${modifier}+q" = "kill"; - "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "${modifier}+Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; - "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; - "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; - }; - }; - - extraConfig = '' - exec_always ${pkgs.autotiling}/bin/autotiling -sr "1.61" - ''; - }; - }; - - programs.rofi = import ./config/rofi { inherit pkgs config lib; }; - - home.file.".config/rofi" = { - source = ./config/rofi/config; - recursive = true; - }; - - xdg = { - portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-gtk - ]; - config.common.default = "*"; - }; - }; - - gtk = { - enable = true; - theme.package = pkgs.juno-theme; - theme.name = "Juno-ocean"; - iconTheme.package = pkgs.qogir-icon-theme; - iconTheme.name = "Qogir"; - }; - - qt = { - enable = true; - style.package = pkgs.juno-theme; - platformTheme.name = "gtk"; - }; - - home.packages = with pkgs; [ - pavucontrol - xdg-utils - wl-clipboard - autotiling - - grim - jq - slurp - - ranger - highlight - - nerd-fonts.terminess-ttf - noto-fonts - noto-fonts-cjk-sans - noto-fonts-color-emoji - ]; - - programs = { - imv.enable = true; - }; - - fonts.fontconfig.enable = true; - }; -} diff --git a/src/user/modules/gui/wm/shared/mimeapps/default.nix b/src/user/modules/gui/wm/shared/mimeapps/default.nix deleted file mode 100644 index 7f94be9..0000000 --- a/src/user/modules/gui/wm/shared/mimeapps/default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - browser = config.programs; - - fileTypes = [ - "text/html" "application/pdf" "application/xml" - "image/png" "image/svg+xml" "image/jpg" - "image/jpeg" "image/gif" "image/webp" - "image/avif" "image/bmp" "image/tiff" - ]; - - defaultBrowser = if browser.firefox.enable then - "firefox.desktop" - else if browser.brave.enable then - "brave-browser.desktop" - else if browser.chromium.enable then - "chromium.desktop" - else null; - -in -{ - xdg.mimeApps = lib.optionalAttrs (defaultBrowser != null && config.xdg.portal.enable) { - enable = true; - defaultApplications = builtins.listToAttrs ( - map (type: { - name = type; - value = [ defaultBrowser ]; - }) fileTypes - ); - }; -} diff --git a/src/user/modules/gui/wm/sway/config/rofi/default.nix b/src/user/modules/gui/wm/sway/config/rofi/default.nix index 724fd55..6a6a5f4 100644 --- a/src/user/modules/gui/wm/sway/config/rofi/default.nix +++ b/src/user/modules/gui/wm/sway/config/rofi/default.nix @@ -5,7 +5,7 @@ let in { enable = true; - package = pkgs.rofi; + package = pkgs.rofi-wayland; location = "center"; terminal = "\${pkgs.alacritty}/bin/alacritty"; plugins = with pkgs; [ diff --git a/src/user/modules/gui/wm/sway/config/sway.nix b/src/user/modules/gui/wm/sway/config/sway.nix new file mode 100644 index 0000000..2c484da --- /dev/null +++ b/src/user/modules/gui/wm/sway/config/sway.nix @@ -0,0 +1,100 @@ +{ config, lib, pkgs, ... }: + +let + modifier = config.wayland.windowManager.sway.config.modifier; + + wallpaper = builtins.fetchurl { + url = "https://images6.alphacoders.com/117/1174033.png"; + sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; + }; + +in +{ enable = true; + xwayland = true; + #wrapperFeatures.gtk = true; + + extraSessionCommands = '' + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + + config = { + fonts = { + names = [ "Terminus" ]; + }; + + output = { + HDMI-A-1 = { + resolution = "1920x1080"; + position = "0,0"; + bg = "${wallpaper} fill"; + }; + DP-1 = { + resolution = "1920x1080"; + position = "1920,0"; + bg = "${wallpaper} fill"; + }; + }; + modifier = "Mod1"; + menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; + terminal = "${pkgs.alacritty}/bin/alacritty"; + + input = { + keyboard = { + xkb_numlock = "enabled"; + xkb_layout = "us"; + }; + pointer = { + accel_profile = "flat"; + pointer_accel = "0.65"; + }; + }; + + bars = [ + { + position = "top"; + statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done''; + fonts = { + names = [ "Terminus" ]; + size = 10.0; + }; + colors = { + background = "#0A0E14"; + statusline = "#FFFFFF"; + }; + } + ]; + + gaps = { + smartGaps = false; + inner = 10; + }; + + floating = { + titlebar = false; + border = 0; + criteria = [ + { + title = "Android Emulator"; + } + ]; + }; + + window = { + titlebar = false; + border= 0; + }; + + keybindings = lib.mkOptionDefault { + "${modifier}+q" = "kill"; + "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; + "Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; + "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; + "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; + "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; + }; + }; + + extraConfig = '' + exec_always ${pkgs.autotiling}/bin/autotiling + ''; +} diff --git a/src/user/modules/gui/wm/sway/default.nix b/src/user/modules/gui/wm/sway/default.nix index d06dc2c..041c047 100644 --- a/src/user/modules/gui/wm/sway/default.nix +++ b/src/user/modules/gui/wm/sway/default.nix @@ -1,139 +1,19 @@ -{ pkgs, lib, config, monitors ? [], ... }: +{ pkgs, lib, config, ... }: with lib; let cfg = config.modules.user.gui.wm.sway; - modifier = config.wayland.windowManager.sway.config.modifier; - - wallpaper = builtins.fetchurl { - url = "https://images6.alphacoders.com/117/1174033.png"; - sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16"; - }; - - barStatus = pkgs.writeShellScript "status.sh" '' - #!/usr/bin/env bash - while :; do - echo "$(ip -4 addr show eno1 | awk '/inet / {print $2}' | cut -d'/' -f1) | $(free -h | awk '/^Mem/ {print $3}') | $(date +'%I:%M:%S %p') | $(date +'%m-%d-%Y')"; sleep 1; - done - ''; - - toSwayOutput = m: { - "${m.name}" = { - resolution = "${toString m.width}x${toString m.height}@${toString m.refreshRate}Hz"; - position = "${toString m.x} ${toString m.y}"; - scale = toString m.scale; - bg = "${wallpaper} fill"; - }; - }; - - outputConfig = if monitors != [] - then lib.mkMerge (map toSwayOutput monitors) - else { - "*" = { bg = "${wallpaper} fill"; }; - }; in -{ options.modules.user.gui.wm.sway = { enable = mkEnableOption "Enable Sway WM"; }; +{ options.modules.user.gui.wm.sway = { enable = mkEnableOption "user.gui.wm.sway"; }; config = mkIf cfg.enable { - wayland.windowManager.sway = { - enable = true; - xwayland = true; - wrapperFeatures.gtk = true; - - extraSessionCommands = '' - export _JAVA_AWT_WM_NONREPARENTING=1 - export GTK_THEME=Adwaita-Dark - ''; - - config = { - defaultWorkspace = "workspace number 1"; - - fonts = { - names = [ "Terminus" ]; - }; - - output = outputConfig; - modifier = "Mod1"; - menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; - terminal = "${pkgs.alacritty}/bin/alacritty"; - - input = { - keyboard = { - xkb_numlock = "enabled"; - xkb_layout = "us"; - }; - pointer = { - accel_profile = "flat"; - pointer_accel = "0.65"; - }; - }; - - bars = [ - { - position = "top"; - statusCommand = "${barStatus}"; - fonts = { - names = [ "Terminus" ]; - size = 12.0; - }; - colors = { - background = "#0A0E14"; - statusline = "#FFFFFF"; - }; - } - ]; - - gaps = { - smartGaps = false; - inner = 10; - }; - - floating = { - titlebar = false; - border = 0; - criteria = [ - { - title = "Android Emulator"; - } - ]; - }; - - window = { - titlebar = false; - border= 0; - }; - - keybindings = lib.mkOptionDefault { - "${modifier}+q" = "kill"; - "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "${modifier}+Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; - "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; - "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; - }; - }; - - extraConfig = '' - exec_always ${pkgs.autotiling}/bin/autotiling -sr "1.61" - ''; - }; - + wayland.windowManager.sway = import ./config/sway.nix { inherit pkgs config lib; }; programs.rofi = import ./config/rofi { inherit pkgs config lib; }; home.file.".config/rofi" = { source = ./config/rofi/config; recursive = true; }; - - xdg = { - portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - ]; - config.common.default = "*"; - }; - }; #gtk = { # enable = true; @@ -162,10 +42,10 @@ in ranger highlight - nerd-fonts.terminess-ttf + terminus-nerdfont noto-fonts - noto-fonts-cjk-sans - noto-fonts-color-emoji + noto-fonts-cjk + noto-fonts-emoji ]; programs = { diff --git a/src/user/modules/security/default.nix b/src/user/modules/security/default.nix index 4b07f68..8478202 100644 --- a/src/user/modules/security/default.nix +++ b/src/user/modules/security/default.nix @@ -7,7 +7,7 @@ let pass-audit pass-otp pass-update - #pass-tomb + pass-tomb ]); in @@ -17,7 +17,6 @@ in pass wireguard-tools ipscan - yubikey-manager ]; }; } diff --git a/src/user/modules/security/modules/gpg/default.nix b/src/user/modules/security/modules/gpg/default.nix index 1751008..b808671 100644 --- a/src/user/modules/security/modules/gpg/default.nix +++ b/src/user/modules/security/modules/gpg/default.nix @@ -1,11 +1,11 @@ -{ pkgs, lib, config, osConfig, ... }: +{ pkgs, lib, config, ... }: with lib; let cfg = config.modules.user.security.gpg; - wm = config.modules.user.gui.wm; - gui = { - enable = builtins.any (mod: mod.enable or false) (builtins.attrValues wm); + gui = config.modules.user.gui.wm; + wm = { + enable = builtins.any (mod: mod.enable or false) (builtins.attrValues gui); }; in @@ -13,21 +13,9 @@ in config = mkIf cfg.enable { programs.gpg = { enable = true; - scdaemonSettings = { - disable-ccid = true; - }; publicKeys = [ { - text = "${config.user.keys.pgp.yubikey}"; - trust = 5; - } - ] ++ optionals (osConfig.networking.hostName == "workstation") [ - { - text = "${config.user.keys.pgp.work}"; - trust = 5; - } - { - text = "${config.user.keys.pgp.ccur}"; + text = "${config.user.keys.pgp.primary}"; trust = 5; } ]; @@ -39,8 +27,8 @@ in enableBashIntegration = true; enableScDaemon = true; - pinentry.package = - if gui.enable then + pinentryPackage = + if wm.enable then pkgs.pinentry-gnome3 else pkgs.pinentry-curses; diff --git a/src/user/modules/tmux/config/tmux.nix b/src/user/modules/tmux/config/tmux.nix index 9ad7ae4..d3ba11f 100644 --- a/src/user/modules/tmux/config/tmux.nix +++ b/src/user/modules/tmux/config/tmux.nix @@ -1,44 +1,10 @@ '' bind -n M-C source-file ~/.config/tmux/tmux.conf -# Navigation (matches hyprland Alt+hjkl) bind-key -n M-h select-pane -L bind-key -n M-j select-pane -D bind-key -n M-k select-pane -U bind-key -n M-l select-pane -R -# Move/swap pane (matches hyprland Alt+Shift+hjkl) -bind-key -n M-H swap-pane -s '{left-of}' -bind-key -n M-J swap-pane -s '{down-of}' -bind-key -n M-K swap-pane -s '{up-of}' -bind-key -n M-L swap-pane -s '{right-of}' - -# Actions bind-key -n M-q kill-pane -bind-key -n M-Return split-window -c "#{pane_current_path}" -bind-key -n M-f resize-pane -Z - -# Windows (like workspaces) -bind-key -n M-1 select-window -t 1 -bind-key -n M-2 select-window -t 2 -bind-key -n M-3 select-window -t 3 -bind-key -n M-4 select-window -t 4 -bind-key -n M-5 select-window -t 5 -bind-key -n M-6 select-window -t 6 -bind-key -n M-7 select-window -t 7 -bind-key -n M-8 select-window -t 8 -bind-key -n M-9 select-window -t 9 -bind-key -n M-0 select-window -t 10 - -# Move pane to window (like move to workspace) -bind-key -n M-! join-pane -t :1 -bind-key -n M-@ join-pane -t :2 -bind-key -n M-'#' join-pane -t :3 -bind-key -n M-'$' join-pane -t :4 -bind-key -n M-% join-pane -t :5 -bind-key -n M-^ join-pane -t :6 -bind-key -n M-& join-pane -t :7 -bind-key -n M-* join-pane -t :8 -bind-key -n M-( join-pane -t :9 -bind-key -n M-) join-pane -t :10 '' diff --git a/src/user/modules/utils/default.nix b/src/user/modules/utils/default.nix index e8d4b86..5a3a0f5 100644 --- a/src/user/modules/utils/default.nix +++ b/src/user/modules/utils/default.nix @@ -11,11 +11,6 @@ in wget curl fastfetch unzip fping calc fd pciutils rsync zip lshw wireshark - calcurse ]; - - programs.bash.shellAliases = { - calendar = "${pkgs.calcurse}/bin/calcurse"; - }; }; } diff --git a/src/user/modules/utils/modules/dev/default.nix b/src/user/modules/utils/modules/dev/default.nix index 1fdb8bd..933e615 100644 --- a/src/user/modules/utils/modules/dev/default.nix +++ b/src/user/modules/utils/modules/dev/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, osConfig, ... }: +{ pkgs, lib, config, ... }: with lib; let @@ -8,8 +8,6 @@ in { options.modules.user.utils.dev = { enable = mkEnableOption "user.utils.dev"; }; config = mkIf cfg.enable { home.packages = with pkgs; [ - claude-code - nix-init nix-prefetch-git nurl @@ -18,14 +16,13 @@ in qrencode docker - ] ++ optionals (osConfig.virtualisation.libvirtd.enable) [ virt-manager ]; programs = { - #bash = { - # initExtra = import ./config/penpot.nix; - #}; + bash = { + initExtra = import ./config/penpot.nix; + }; direnv = { enable = true; enableBashIntegration = true; @@ -33,18 +30,8 @@ in }; }; - home = { - sessionVariables = { - DIRENV_LOG_FORMAT = ""; - }; - - # Workaround for direnv_log bug - # https://github.com/direnv/direnv/issues/1418#issuecomment-2820125413 - file.".config/direnv/direnv.toml" = { - enable = true; - force = true; - text = ""; - }; + home.sessionVariables = { + DIRENV_LOG_FORMAT = ""; }; }; } diff --git a/src/user/modules/utils/modules/email/config/aerc.conf b/src/user/modules/utils/modules/email/config/aerc.conf index e7e0bda..af4f244 100644 --- a/src/user/modules/utils/modules/email/config/aerc.conf +++ b/src/user/modules/utils/modules/email/config/aerc.conf @@ -14,7 +14,7 @@ # keyring already exists, in which case the latter will be used. # # Default: auto -pgp-provider=auto +#pgp-provider=auto # By default, the file permissions of accounts.conf must be restrictive and # only allow reading by the file owner (0600). Set this option to true to @@ -41,7 +41,7 @@ pgp-provider=auto # Set the $TERM environment variable used for the embedded terminal. # # Default: xterm-256color -term=xterm-256color +#term=xterm-256color # Display OSC8 strings in the embedded terminal # diff --git a/src/user/modules/utils/modules/neovim/config/nvim b/src/user/modules/utils/modules/neovim/config/nvim deleted file mode 160000 index c341ac8..0000000 --- a/src/user/modules/utils/modules/neovim/config/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c341ac8840e8a19ab98bcc5084f51157ddaf8730 diff --git a/src/user/modules/utils/modules/neovim/config/nvim/init.lua b/src/user/modules/utils/modules/neovim/config/nvim/init.lua new file mode 100644 index 0000000..dd3b61d --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/init.lua @@ -0,0 +1,11 @@ +local function load_config_directory(directory) + local config_path = vim.fn.stdpath("config") .. "/lua/" .. directory + local files = vim.fn.glob(config_path .. "/*.lua", false, true) + + for _, file in ipairs(files) do + local file_name = vim.fn.fnamemodify(file, ":t:r") -- Extract filename without extension + require(directory .. "." .. file_name) + end +end + +load_config_directory("config") diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/config/keymaps.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..a12a224 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/keymaps.lua @@ -0,0 +1,23 @@ +-- Keep cursor centered while navigating document +vim.keymap.set("n", "", "zz", { silent = true }) +vim.keymap.set("n", "", "zz", { silent = true }) + +-- Remap Ctrl + J/K/H/L to navigate between windows +vim.keymap.set('n', '', 'j', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'k', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'h', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'l', { noremap = true, silent = true }) + +vim.keymap.set('n', '', ':vertical resize +10', { noremap = true, silent = true }) +vim.keymap.set('n', '', ':vertical resize -10', { noremap = true, silent = true }) +vim.keymap.set('n', '', ':horizontal resize +10', { noremap = true, silent = true }) +vim.keymap.set('n', '', ':horizontal resize -10', { noremap = true, silent = true }) + +-- Remap Shift + H/L to switch between buffers +vim.keymap.set('n', '', ':bprevious', { noremap = true, silent = true }) +vim.keymap.set('n', '', ':bnext', { noremap = true, silent = true }) + +vim.keymap.set("v", "<", "", ">gv") + +vim.keymap.set("n", "", ':nohlsearchlet @/=""', { noremap = true, silent = true}) diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/config/lazy.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..89c356d --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "onedark" } }, + -- automatically check for plugin updates + checker = { enabled = false }, +}) diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/config/options.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/options.lua new file mode 100644 index 0000000..06a94d8 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/config/options.lua @@ -0,0 +1,33 @@ +vim.o.clipboard = "unnamedplus" +vim.g.autoformat = false + +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true +vim.opt.termguicolors = true + +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 2 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.ignorecase = true +vim.opt.smartcase = false +vim.opt.incsearch = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undofile = true + +vim.o.termguicolors = false +vim.opt.guicursor = "n-v-c:block,i:block,r:block" + +vim.opt.fillchars = { eob = " " } + +vim.cmd([[ + autocmd FileType python,haskell,c,cpp setlocal tabstop=4 shiftwidth=4 softtabstop=4 +]]) + +vim.cmd([[ + au BufRead,BufNewFile *.purs set filetype=purescript +]]) diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/bufferline.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/bufferline.lua new file mode 100644 index 0000000..307cc1b --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/bufferline.lua @@ -0,0 +1,10 @@ +return { + { + "akinsho/bufferline.nvim", + version = "*", + dependencies = "nvim-tree/nvim-web-devicons", + config = function() + require("bufferline").setup{} + end + } +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/colorscheme.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..e1224a1 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,47 @@ +return { + { + "chriskempson/base16-vim", + config = function() + vim.cmd("colorscheme base16-onedark") + vim.cmd([[ + hi Normal guibg=NONE ctermbg=NONE guifg=#FFFFFF + hi Visual ctermbg=Gray ctermfg=Black guibg=Gray guifg=Black + hi NonText guibg=NONE ctermbg=NONE + hi LineNr guibg=NONE ctermbg=NONE + hi CursorLine guibg=NONE ctermbg=NONE + hi CursorLineNr guibg=NONE ctermbg=NONE guifg=#E5C07B ctermfg=Yellow cterm=bold + hi Search ctermfg=Black guifg=#000000 ctermbg=Gray guibg=#FFCC66 + hi Pmenu ctermbg=Black ctermfg=White cterm=NONE guibg=Black guifg=White gui=NONE + hi PmenuSel ctermbg=Green ctermfg=Black cterm=NONE guibg=Green guifg=Black gui=NONE + hi PmenuThumb ctermbg=Green guibg=Green + hi PmenuSbar ctermbg=Black guibg=Black + hi WinSeparator guibg=NONE ctermbg=NONE + + hi GitGutterChange guibg=NONE ctermbg=NONE + hi GitGutterAdd guibg=NONE ctermbg=NONE + hi GitGutterDelete guibg=NONE ctermbg=NONE + hi SignColumn ctermbg=NONE guibg=NONE + + hi TelescopeSelection guibg=Gray guifg=Green gui=bold ctermbg=Black ctermfg=Green cterm=bold + hi TelescopePreviewMatch ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black + + hi TreesitterContext guibg=NONE ctermbg=NONE + + hi LazyH1 ctermbg=Green ctermfg=Black guibg=Black guifg=Green + hi IblScope guibg=NONE guifg=Yellow ctermbg=NONE ctermfg=Yellow + ]]) + + vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() + vim.cmd("highlight YankHighlight ctermbg=yellow ctermfg=black guibg=yellow guifg=black") + vim.highlight.on_yank({ higroup = "YankHighlight", timeout = 150 }) + end, + }) + end, + }, + + { + "fei6409/log-highlight.nvim" + } + +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/disabled.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/disabled.lua new file mode 100644 index 0000000..cd3b799 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/disabled.lua @@ -0,0 +1,7 @@ +return { + { "williamboman/mason.nvim", enabled = false }, + { "williamboman/mason-lspconfig.nvim", enabled = false }, + { "jay-babu/mason-nvim-dap.nvim", enabled = false }, + { "catppuccin/nvim", enabled = false }, + { "folke/flash.nvim", enabled = false }, +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/gitsigns.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..b34952f --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,59 @@ +return { + { + "lewis6991/gitsigns.nvim", + config = function() + require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = 'β€Ύ' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = 'β€Ύ' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged_enable = true, + signcolumn = false, -- Toggle with `:Gitsigns toggle_signs` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 0, + ignore_whitespace = false, + virt_text_priority = 100, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + } + require("which-key").add({ + { "Gb", ":Gitsigns toggle_current_line_blame", desc = "Git blame" } + }) + end + } +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/indent-blankline.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..418ab88 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/indent-blankline.lua @@ -0,0 +1,15 @@ +return { + { + "lukas-reineke/indent-blankline.nvim", + config = function() + require("ibl").setup({ + --indent = { char = "β”‚" }, + --indent = { char = "⎸" }, + indent = { char = "┆" }, + scope = { + enabled = false + }, + }) + end, + } +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lsp.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..e068eaa --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,185 @@ +local servers = { + "ts_ls", + "pyright", + "nil_ls", + "cssls", + "html", + "lua_ls", + "marksman", + "tailwindcss", + "bashls", + "clangd", + "jsonls", + "vuels" + --"arduino-language-server" +} + +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require('nvim-treesitter.configs').setup ({ + ensure_installed = { + "lua", + "c", + "cpp", + "python", + "nix", + "rust", + "bash", + "markdown", + "html", + "javascript", + "css", + + "vim", + + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore" + }, + auto_install = true, + sync_install = true, + highlight = { + enable = true, + } + }) + end + }, + + { + "m4xshen/autoclose.nvim", + config = function () + require("autoclose").setup() + end + }, + + --{ + -- "nvim-treesitter/nvim-treesitter-context", + -- dependencies = { "nvim-treesitter/nvim-treesitter" }, + -- config = function() + -- require("treesitter-context").setup({ + -- enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + -- max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit. + -- min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + -- line_numbers = false, + -- multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line + -- trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + -- mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' + -- -- Separator between context and content. Should be a single character string, like '-'. + -- -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + -- separator = "=", + -- zindex = 20, -- The Z-index of the context window + -- on_attach = nil, -- (fun(buf: integer): boolean) rurn false to disable attaching + -- }) + -- end, + --}, + + { + "VonHeikemen/lsp-zero.nvim", + branch = "v2.x", + dependencies = { + { "neovim/nvim-lspconfig" }, + + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/cmp-nvim-lsp" }, + + { "L3MON4D3/LuaSnip" }, + }, + config = function () + local lsp = require('lsp-zero').preset({}) + lsp.setup_servers(servers) + lsp.setup() + end + }, + + { + "hrsh7th/nvim-cmp", + dependencies = { + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp" + }, + + config = function() + local cmp = require("cmp") + cmp.setup({ + enabled = function() + local context = require("cmp.config.context") + if vim.api.nvim_get_mode().mode == "c" then + return true + else + return not context.in_treesitter_capture("comment") and not context.in_syntax_group("comment") + end + end, + + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + + end + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm(), + [""] = cmp.mapping(function(fallback) + fallback() + end, { "i", "s" }), + }), + + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' } + }), + }) + end + }, + + { + "neovim/nvim-lspconfig", + config = function() + local lsp = require('lspconfig') + local navic = require('nvim-navic') + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + for _, server in ipairs(servers) do + lsp[server].setup { + capabilities = capabilities, + on_attach = function(client, bufnr) + if client.server_capabilities.documentSymbolProvider then + navic.attach(client,bufnr) + end + end, + } + end + lsp.lua_ls.setup{ + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } + } + require("which-key").add({ + { "cl", ":LspInfo", desc = "LSP Info" }, + }) + end + }, +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lualine.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..459ed04 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,61 @@ +return { + { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + "SmiteshP/nvim-navic" + }, + config = function() + local navic = require('nvim-navic') + require("lualine").setup ({ + options = { + icons_enabled = true, + theme = 'material', + component_separators = { left = '>', right = '|'}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = true, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = { + {'filename'}, + { function() return require("nvim-navic").get_location() end, cond = function() + return require("nvim-navic").is_available() + end, + }, + }, + lualine_x = {'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = { + 'lazy', + 'neo-tree', + } + }) + end + } +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/neotree.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..e04584f --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/neotree.lua @@ -0,0 +1,50 @@ +return { + { + "nvim-neo-tree/neo-tree.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function() + require("neo-tree").setup({ + enable_diagnostics = false, + window = { + position = "left", + width = 20, + }, + --filesystem = { + -- hijack_netrw_behavior = "disabled", + --}, + }) + + local function toggle_neotree() + local api = vim.api + local bufs = api.nvim_list_bufs() + + for _, buf in ipairs(bufs) do + local name = api.nvim_buf_get_name(buf) + if name:match("neo%-tree filesystem") then + api.nvim_command(":Neotree close") + return + end + end + + api.nvim_command(":Neotree") + end + + require("which-key").add({ + { "e", toggle_neotree, desc = "File Explorer" } + }) + + --vim.fn.sign_define("DiagnosticSignError", + -- {text = " ", texthl = "DiagnosticSignError"}) + --vim.fn.sign_define("DiagnosticSignWarn", + -- {text = " ", texthl = "DiagnosticSignWarn"}) + --vim.fn.sign_define("DiagnosticSignInfo", + -- {text = " ", texthl = "DiagnosticSignInfo"}) + --vim.fn.sign_define("DiagnosticSignHint", + -- {text = "󰌡", texthl = "DiagnosticSignHint"}) + end, + }, +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/telescope.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..5f4c935 --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,57 @@ +local function get_root() + local git_dir = vim.fn.systemlist("git rev-parse --show-toplevel")[1] + if git_dir and git_dir ~= "" then + return git_dir + else + return vim.fn.getcwd() -- Fallback to current working directory if not in a Git repo + end +end + +return { + { + "nvim-telescope/telescope.nvim", + brach = '0.1.x', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-tree/nvim-web-devicons' } + }, + config = function() + -- Custom Telescope command to grep from Git root + require("which-key").add({ + { "/", function() + require('telescope.builtin').live_grep({ cwd = get_root() }) + end, + desc = "grep" }, + { "/", ":Telescope live_grep", desc = "grep" }, + { "ff", ":Telescope fd", desc = "Search for Files" }, + { "fp", ":Telescope oldfiles", desc = "Oldfiles" }, + { "?", ":Telescope command_history", desc = "Command History" }, + { "cm", ":Telescope man_pages", desc = "Manpages" }, + + -- Code + { "gd", + function() + local attached = vim.lsp.buf_get_clients(0) + if next(attached) ~= nil then + require('telescope.builtin').lsp_definitions() + else + vim.api.nvim_command('normal! gd') + end + end, + mode = "n", + desc = "Go to Definition" + }, + { "gd", ":Telescope lsp_definitions", desc = "Go to Definition" }, + { "gr", ":Telescope lsp_references", desc = "Goto References" }, + { "gi", ":Telescope lsp_implementations", desc = "Go to Implementations" }, + { "gt", ":Telescope lsp_type_definitions", desc = "Go to Type Definition" }, + { "cv", ":Telescope treesitter", desc = "Function Names & Variables" }, + { "cd", ":Telescope diagnostics", desc = "Code Diagnostics" }, + + -- Git + { "Gt", ":Telescope git_branches", desc = "Git Branches" }, + { "Gc", ":Telescope git_commits", desc = "Git Commits" }, + }) + end + } +} diff --git a/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/which-key.lua b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..c3ce10d --- /dev/null +++ b/src/user/modules/utils/modules/neovim/config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,39 @@ +return { + { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + spec = { + { "l", ":Lazy", desc = "Lazy" }, + { "t", + function() + vim.cmd("botright new | setlocal nonumber norelativenumber | resize 10 | terminal") + vim.cmd("startinsert") + end, + mode = "n", + desc = "Open Terminal" + }, + + --{ "wd", "execute 'bd' | execute 'close'", desc = "Delete window & buffer" }, + -- Window & Buffer Management + { "w", group = "Windows"}, + { "wc", ":close", desc = "Close Window" }, + { "ws", ":split", desc = "Horizontal Window Split" }, + { "wv", ":vsplit", desc = "Vertial Window Split" }, + { "wm", "_", desc = "Maximize Window" }, + + { "b", group = "Buffers"}, + { "bd", ":bd", desc = "Delete Buffer" }, + { "bD", "execute 'close' | execute 'bd!'", desc = "Delete Window & Buffer" }, + + { "ca", vim.lsp.buf.code_action, desc = "Code Action" }, + { "cr", vim.lsp.buf.rename, desc = "Rename Variable" }, + + { "G", group = "Git"}, + { "f", group = "Files"}, + { "c", group = "Code"}, + { "g", group = "Goto"}, + }, + }, + } +} diff --git a/src/user/modules/utils/modules/neovim/config/pkgs.nix b/src/user/modules/utils/modules/neovim/config/pkgs.nix index 35b1e0d..e34740f 100644 --- a/src/user/modules/utils/modules/neovim/config/pkgs.nix +++ b/src/user/modules/utils/modules/neovim/config/pkgs.nix @@ -1,18 +1,21 @@ { pkgs, ... }: let - # Essential LSPs for config files (project-specific LSPs go in devShells) lsp = with pkgs; [ - nixd - lua-language-server + nil marksman - taplo # TOML + sumneko-lua-language-server stylua + nodePackages."@tailwindcss/language-server" + clang-tools + #arduino-language-server ]; lsp' = with pkgs.nodePackages; [ - vscode-langservers-extracted # jsonls, html, cssls + typescript-language-server + vscode-langservers-extracted bash-language-server - yaml-language-server + pyright + vls ]; extraPackages = with pkgs; [ diff --git a/src/user/modules/utils/modules/vim/config/vimrc b/src/user/modules/utils/modules/vim/config/vimrc new file mode 100644 index 0000000..3d69854 --- /dev/null +++ b/src/user/modules/utils/modules/vim/config/vimrc @@ -0,0 +1,104 @@ +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +if empty(glob('~/.vim/plugged')) + silent! :PlugInstall | q +endif + +autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | source $MYVIMRC + \| endif + +call plug#begin('~/.vim/plugged') + Plug 'chriskemson/base16-vim' + Plug 'tpope/vim-surround' + Plug 'jiangmiao/auto-pairs' + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } + Plug 'junegunn/fzf.vim' + Plug 'mtdl9/vim-log-highlighting' + Plug 'machakann/vim-highlightedyank' + Plug 'itchyny/lightline.vim' + Plug 'tpope/vim-fugitive' + Plug 'mhinz/vim-signify' + Plug 'osyo-manga/vim-anzu' +call plug#end() + +let mapleader = "\" +set background=dark +colorscheme base16-onedark + +highlight Normal ctermbg=NONE guibg=NONE +highlight NonText ctermbg=NONE guibg=NONE +highlight CursorLine ctermbg=NONE guibg=NONE +highlight CursorLineNr ctermfg=Yellow guifg=#FFCC66 ctermbg=NONE guibg=NONE cterm=bold +highlight HighlightedyankRegion ctermfg=Black guifg=#FFFFFF ctermbg=Yellow guibg=#FFA500 +highlight NormalNC ctermbg=NONE guibg=NONE +highlight Search ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=#FFCC66 +highlight LineNr ctermbg=NONE guibg=NONE +highlight Visual ctermbg=LightGray guibg=#E8E8E8 ctermfg=Black guifg=#000000 + +let g:highlightedyank_highlight_duration = 140 +let g:lightline = { 'colorscheme': 'deus', } + +let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down' +let g:fzf_layout = { 'window': 'enew' } + +set laststatus=2 + +set number +set relativenumber +set cursorline + +set noincsearch +set ignorecase + +set clipboard=unnamedplus +set noswapfile + +set tabstop=2 +set shiftwidth=2 +set expandtab + +set statusline=%{anzu#search_status()} + +nnoremap pu :PlugUpdate +nnoremap pd :PlugUpgrade +nnoremap ps :PlugStatus +nnoremap ps :PlugInstall + +nmap n (anzu-n-with-echo) +nmap N (anzu-N-with-echo) +nmap * (anzu-star-with-echo) +nmap # (anzu-sharp-with-echo) + +nmap (anzu-clear-search-status) + +vnoremap < >gv +nnoremap zz +nnoremap zz + +nnoremap gs :Git status +nnoremap gl :Git log +nnoremap ga :Git add +nnoremap gc :Git commit +nnoremap gd :Git diff + +nnoremap e :Ex +nnoremap / :Rg + +nnoremap bd :bd +nnoremap H :bprevious +nnoremap L :bnext + +nnoremap wh :split +nnoremap wv :vsplit +nnoremap wd :q +nnoremap ww :wincmd w +nnoremap wW :wincmd W + +nnoremap ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]') +nnoremap :noh diff --git a/src/user/modules/utils/modules/vim/default.nix b/src/user/modules/utils/modules/vim/default.nix index 61cafa1..8805e0f 100644 --- a/src/user/modules/utils/modules/vim/default.nix +++ b/src/user/modules/utils/modules/vim/default.nix @@ -16,7 +16,7 @@ in vim ]; file.".vim" = { - source = ./vim; + source = ./config; recursive = true; }; }; diff --git a/src/user/modules/utils/modules/vim/vim b/src/user/modules/utils/modules/vim/vim deleted file mode 160000 index 64b4c54..0000000 --- a/src/user/modules/utils/modules/vim/vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 64b4c545481b593d2859bfb3e1c10cd91742213f