diff --git a/.gitignore b/.gitignore index 962bdab..923827e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /live -.NixRoot* diff --git a/Makefile b/Makefile index 5175d71..b7ee8a7 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ fix-ulimit: # HACK: They broke switching in systemd service ffs. # https://github.com/NixOS/nixpkgs/issues/347315 fix-unlock: - pkill nixos-rebuild + pkill nixos-rebuild || true format: treefmt --no-cache --on-unmatched=info diff --git a/config/Wallpaper.nix b/config/Wallpaper.nix index e7de773..b49d1bd 100644 --- a/config/Wallpaper.nix +++ b/config/Wallpaper.nix @@ -1,9 +1,9 @@ { pkgs, lib, ... }: with lib; let - url = "https://i.imgur.com/iDuNPOQ.jpeg"; - sha256 = "1hyzc53jkmjkhabbzx4nxzg5bqrk2524dl167fs5aw58r8q6fr75"; - forceContrastText = true; + url = "https://i.imgur.com/7PoLqMb.jpeg"; + sha256 = "1vwhgdxsfn33pcyw06b2f5xikz6iwp4h54lr8515fqnnzbl06vjm"; + forceContrastText = false; in { options = { diff --git a/flake.lock b/flake.lock index 84d8b21..f751daa 100644 --- a/flake.lock +++ b/flake.lock @@ -609,22 +609,6 @@ "type": "github" } }, - "nvimOllama": { - "flake": false, - "locked": { - "lastModified": 1717906114, - "narHash": "sha256-8tW5tp2GiYw+PnR7rqiKfykLW/yqvGOtqauZCgEeQCg=", - "owner": "nomnivore", - "repo": "ollama.nvim", - "rev": "45e58779fecde7ac5b8f62800bbe7180d4b48507", - "type": "github" - }, - "original": { - "owner": "nomnivore", - "repo": "ollama.nvim", - "type": "github" - } - }, "nvimPlenary": { "flake": false, "locked": { @@ -762,7 +746,6 @@ "nvimGruvboxMaterial": "nvimGruvboxMaterial", "nvimIndentoMatic": "nvimIndentoMatic", "nvimLspconfig": "nvimLspconfig", - "nvimOllama": "nvimOllama", "nvimPlenary": "nvimPlenary", "nvimTelescope": "nvimTelescope", "nvimTodo": "nvimTodo", diff --git a/flake.nix b/flake.nix index 8ddbbb7..e5aceb1 100644 --- a/flake.nix +++ b/flake.nix @@ -82,10 +82,6 @@ url = "github:neovim/nvim-lspconfig"; flake = false; }; - nvimOllama = { - url = "github:nomnivore/ollama.nvim"; - flake = false; - }; nvimPlenary = { url = "github:nvim-lua/plenary.nvim"; flake = false; diff --git a/home/config/nvim/default.nix b/home/config/nvim/default.nix index 9b3d56e..5b3a16a 100644 --- a/home/config/nvim/default.nix +++ b/home/config/nvim/default.nix @@ -35,7 +35,6 @@ in "${inputs.nvimGruvboxMaterial}" "${inputs.nvimIndentoMatic}" "${inputs.nvimLspconfig}" - "${inputs.nvimOllama}" "${inputs.nvimPlenary}" "${inputs.nvimTelescope}" "${inputs.nvimTodo}" @@ -65,7 +64,6 @@ in ./module/plugin/Align.nix ./module/plugin/Treesitter.nix ./module/plugin/Fold.nix - ./module/plugin/Ollama.nix ./module/plugin/Colorizer.nix ./module/plugin/lsp/Haskell.nix ./module/plugin/lsp/Rust.nix @@ -79,7 +77,6 @@ in ./module/key/Filetree.nix ./module/key/Gitsigns.nix ./module/key/Navigation.nix - ./module/key/Ollama.nix ./module/key/Save.nix ./module/key/Sort.nix ./module/key/TabWidth.nix diff --git a/home/config/nvim/module/key/Ollama.nix b/home/config/nvim/module/key/Ollama.nix deleted file mode 100644 index 13c9b34..0000000 --- a/home/config/nvim/module/key/Ollama.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: -{ - text = '' - rekey_normal("p", ":lua require('ollama').prompt()") - rekey_visual("p", ":lua require('ollama').prompt()") - ''; -} diff --git a/home/config/nvim/module/plugin/Gruvbox.nix b/home/config/nvim/module/plugin/Gruvbox.nix index bf315f4..01edadf 100644 --- a/home/config/nvim/module/plugin/Gruvbox.nix +++ b/home/config/nvim/module/plugin/Gruvbox.nix @@ -8,7 +8,7 @@ ]]) vim.o.background = "dark" - vim.g.gruvbox_material_background = "hard" + vim.g.gruvbox_material_background = "medium" vim.g.gruvbox_material_foreground = "original" vim.g.gruvbox_material_transparent_background = 2 -- vim.g.gruvbox_material_better_performance = 1 -- NOTE: Broken on NixOS. diff --git a/home/config/nvim/module/plugin/Ollama.nix b/home/config/nvim/module/plugin/Ollama.nix deleted file mode 100644 index 01503fe..0000000 --- a/home/config/nvim/module/plugin/Ollama.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, ... }: -{ - text = '' - require("ollama").setup { - model = "${config.setting.ollama.primaryModel}", - url = "http://127.0.0.1:11434", - -- View the actual default prompts in ./lua/ollama/prompts.lua - prompts = { - -- Sample_Prompt = { - -- prompt = "This is a sample prompt that receives $input and $sel(ection), among others.", - -- input_label = "> ", - -- model = "mistral", - -- action = "display", - -- } - } - } - ''; -} diff --git a/home/config/sway/module/Launcher.nix b/home/config/sway/module/Launcher.nix index 6a3f0de..82b9949 100644 --- a/home/config/sway/module/Launcher.nix +++ b/home/config/sway/module/Launcher.nix @@ -1,18 +1,9 @@ -{ config, ... }: -let - fontName = config.style.font.serif.name; - fontSize = toString config.style.font.size.desktop; - - accent = config.style.color.accent; - bg = config.style.color.bg.dark; - fg = config.style.color.fg.light; -in +{ ... }: { text = '' # Application launcher. # Note: pass the final command to swaymsg so that the resulting window can be opened # on the original workspace that the command was run on. - # set $menu _dmenu_path_wrapped | wmenu -b -p 'Run:' -i -f "${fontName} ${fontSize}" -M ${bg}D9 -S ${bg}D9 -N ${bg}D9 -m ${accent} -s ${accent} -n ${fg} | xargs swaymsg exec -- set $menu fuzzel bindsym $mod+space exec $menu diff --git a/home/program/bash/module/Android.nix b/home/program/bash/module/Android.nix deleted file mode 100644 index 5ac5e21..0000000 --- a/home/program/bash/module/Android.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ ... }: -{ - text = '' - # Start an Android emulator. - # Default name is `main`. - # Usage: emulator [NAME] - function emulator() { - local name="$1" - - [[ "$name" = "" ]] && name="main" - - steam-run ~/.android/sdk/emulator/emulator -avd "$name" &> /dev/null & disown - } - - function _android_emulators() { - _autocomplete_first $(ls --classify ~/.android/avd/ | grep \/$ | sed -e "s/.avd\/$//") - } - - complete -F _android_emulators emulator - ''; -} diff --git a/home/program/bash/module/Ask.nix b/home/program/bash/module/Ask.nix deleted file mode 100644 index d1a9fe7..0000000 --- a/home/program/bash/module/Ask.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ ... }: -{ - text = '' - # Ask general AI. - # Usage: ask - function ask() { - curl http://localhost:11434/api/generate -d "{ - \"model\": \"''${OLLAMA_MODEL}\", - \"prompt\":\"''${*}\" - }" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'" - echo - } - - # Specify ask model. - function ask_model() { - export OLLAMA_MODEL="''${1}" - } - - function _complete_ask_model() { - local IFS=$'\n' - local models=($(ollama list | sed -e "1d" | cut -f1)) - _autocomplete_first ''${models[@]} - } - - complete -F _complete_ask_model ask_model - ''; -} diff --git a/home/program/bash/module/Calc.nix b/home/program/bash/module/Calc.nix deleted file mode 100644 index d1e230b..0000000 --- a/home/program/bash/module/Calc.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: -{ - text = '' - # Launch calculator app. - function calc() { - gnome-calculator - } - ''; -} diff --git a/home/program/bash/module/Checksum.nix b/home/program/bash/module/Checksum.nix deleted file mode 100644 index 2e1dcc7..0000000 --- a/home/program/bash/module/Checksum.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ ... }: -{ - text = '' - # Save file checksums. - # For file with a name `file` it will create a new file called `.file.sha1` with hash in it. - # All files by default. - # Usage: checksum_create [FILES] - function checksum_create() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - process() { - local hashfile=".''${target#./}.sha1" - - # Skip if hash exists. - [[ -f "''${hashfile}" ]] && return 0 - - # Calculate hash. - pv ''${target} | sha1sum > ''${hashfile} - } - - _iterate_targets process ''${targets[@]} - } - - # Check stored values against actual files. - # All files by default. - # Usage: checksum_check [FILES] - function checksum_check() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - process() { - local hashfile=".''${target#./}.sha1" - - # Skip if hash doesn't exist. - [[ -f "''${hashfile}" ]] || { _iterate_skip "No hash found."; return 0; } - - # Calculate hash. - local stored=$(cat "''${hashfile}" | cut -d\ -f1) - local actual=$(pv "''${target}" | sha1sum | cut -d\ -f1) - - if [[ "''${stored}" != "''${actual}" ]]; then - _error "Failed." - return 1 - fi - } - - _iterate_targets process ''${targets[@]} - } - - # Calculate hashes for all files recursively and store in a file called `checksum.sha1`. - function checksum() { - find -type f | parallel -j $(_core_count) -- sha1sum {} >> checksum.sha1 - } - - # Create checksum for a file. - # Usage: _checksum_create - function _checksum_create() { - local path="''${1%/*}" - local name="''${1##*/}" - sha1sum "''${path}/''${name}" > "''${path}/.''${name}.sha1" - } - - # Check checksum for a file. - # Usage: _checksum_check - function _checksum_check() { - local file="''${1##*\ \ }" - local stored="''${1%%\ \ *}" - - # Skip if no file. - [[ -f "''${file}" ]] || return 0 - - # Check file hash. - local actual=$(sha1sum "''${file}") - actual="''${actual%%\ \ *}" - - # Compare values. - if [[ "''${stored}" != "''${actual}" ]]; then - _error "''${file}: Failed." - return 1 - fi - - return 0 - } - ''; -} diff --git a/home/program/bash/module/Chmod.nix b/home/program/bash/module/Chmod.nix deleted file mode 100644 index 6971f83..0000000 --- a/home/program/bash/module/Chmod.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: -{ - text = '' - # Add executable flag to file. - # Usage: x - function x() { - chmod +x -- "''${@}" - } - ''; -} diff --git a/home/program/bash/module/Container.nix b/home/program/bash/module/Container.nix deleted file mode 100644 index ed271b5..0000000 --- a/home/program/bash/module/Container.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ ... }: -{ - text = '' - # Attach/create container box in current directory with specified name. - # By default uses current dir name. - # Usage: ca [NAME] - function ca() { - local name="''${1}" - - # Set default name. - # [[ "''${name}" = "" ]] && name="main" - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - - # Append box prefix. - name="box-''${name}" - - # Create container. - docker run \ - --privileged \ - -d -it \ - -h "''${HOSTNAME}''${name#box}" --name "''${name}" \ - --workdir /data \ - -e XDG_RUNTIME_DIR=/tmp \ - -e WAYLAND_DISPLAY=''${WAYLAND_DISPLAY} \ - -v ''${XDG_RUNTIME_DIR}/''${WAYLAND_DISPLAY}:/tmp/''${WAYLAND_DISPLAY} \ - -v ''${PWD}:/data \ - -v ''${HOME}:/root \ - debian:latest bash -c bash &> /dev/null - - # Attempt to start container. - docker start "''${name}" &> /dev/null - - # Attach to running container. - docker attach "''${name}" - } - - # Remove container box with specified name. - # By default uses current dir name. - # Usage: ck [NAME] - function ck() { - local name="''${1}" - - # Set default name. - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - - # Append box prefix. - name="box-''${name}" - - # Kill container. - docker kill "''${name}" &> /dev/null - docker rm "''${name}" &> /dev/null - } - - # Remove all container boxes. - function cka() { - local IFS=$'\n' - local boxes=$(_get_boxes) - - for box in ''${boxes[@]}; do - ck "''${box}" - done - } - - # List all container boxes. - function cl() { - _get_boxes - } - - # Print all boxes. - function _get_boxes() { - local IFS=$'\n' - local boxes=$(docker ps -a | grep "box-" | sed -e "s/.*box-//") - - [[ "''${boxes[@]}" != "" ]] && echo "''${boxes[@]}" || true - } - - # Autocomplete with boxes. - function _comp_get_boxes() { - local IFS=$'\n' - _autocomplete_first $(_get_boxes) - } - - complete -F _comp_get_boxes ca ck - ''; -} diff --git a/home/program/bash/module/Dconf.nix b/home/program/bash/module/Dconf.nix deleted file mode 100644 index f35573f..0000000 --- a/home/program/bash/module/Dconf.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ ... }: -{ - text = '' - export _gdconf_path="''${HOME}/.config/linux/Gnome.dconf" - - # Load Gnome settings. - function dconf_load() { - sed -i -e s/voronind/$(whoami)/g ''${_gdconf_path} ; dconf load / < ''${_gdconf_path} - } - - # Dump Gnome settings into the file. - # Default name is `gnome.dconf`. - # Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`. - # Usage: dconf_save [FILE] - function dconf_save() { - local name="''${1}" - [[ "''${name}" = "" ]] && name="gnome.dconf" - dconf dump / > "''${name}" - } - ''; -} diff --git a/home/program/bash/module/Distrobox.nix b/home/program/bash/module/Distrobox.nix deleted file mode 100644 index 7c69006..0000000 --- a/home/program/bash/module/Distrobox.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ ... }: -{ - text = '' - # Create/Attach to the box. - # Uses name `main` by default. - # Usage: da [BOX] - function da() { - local name="''${1}" - - [[ "''${name}" = "" ]] && name="main" - # if [[ "''${name}" = "" ]]; then - # help da - # return 2 - # fi - - # --user 0 is required for rootless docker. - distrobox enter -a '--user=0' "''${name}" - } - ''; -} diff --git a/home/program/bash/module/Dmenu.nix b/home/program/bash/module/Dmenu.nix deleted file mode 100644 index 8ee2a72..0000000 --- a/home/program/bash/module/Dmenu.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ ... }: -{ - text = '' - # Wrapped dmenu_path to include my functions. - function _dmenu_path_wrapped() { - c=0 - while [ ''${c} -lt 1000 ]; do - echo - ((c++)) - done - - find_function | grep -v ^_ - dmenu_path - } - ''; -} diff --git a/home/program/bash/module/File.nix b/home/program/bash/module/File.nix index b1989ff..82023d4 100644 --- a/home/program/bash/module/File.nix +++ b/home/program/bash/module/File.nix @@ -6,28 +6,5 @@ function o() { xdg-open "''${@}" } - - # Play media file from CLI. All files by default. - # Usage: play [FILE] - function play() { - local targets=''${*} - [[ "''${targets}" = "" ]] && targets=$(_ls_file) - - mpv --no-video ''${targets} - } - - # Play media files shuffled from CLI. All files by default. - # Usage: play_shuffle [FILE] - function play_shuffle() { - local targets=''${*} - [[ "''${targets}" = "" ]] && targets=$(_ls_file) - - mpv --no-video --shuffle ''${targets} - } - - # Open files app. - function files() { - nautilus - } ''; } diff --git a/home/program/bash/module/Fix.nix b/home/program/bash/module/Fix.nix index 57b59fa..b2ded6b 100644 --- a/home/program/bash/module/Fix.nix +++ b/home/program/bash/module/Fix.nix @@ -16,56 +16,10 @@ ethtool -s "''${device}" speed "''${speed}" } - # Fix nautilus after typing wrong sftp password. - function fix_files_sftp() { - secret-tool clear protocol sftp - } - # Delete lost Gradle lock files. function fix_gradle_lock() { cd "''${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm cd - } - - # Fix Gnome's broken RDP ffs. - # Usage: fix_gnome_rdp - function fix_gnome_rdp() { - local user="''${USERNAME}" - local password="''${1}" - - # Check params. - if [[ "''${password}" = "" ]]; then - help fix_gnome_rdp - return 2 - fi - - # Unlock keyring. PROTIP: Disable password for it in password manager. - pkill -9 -f gnome-keyring-daemon - echo -n "''${user}" | gnome-keyring-daemon --unlock - - # Generate keys. - cd /tmp - openssl genrsa -out rdp-tls.key 4096 - openssl req -new -key rdp-tls.key -subj "/C=US" | openssl x509 -req -days 730 -signkey rdp-tls.key -out rdp-tls.crt - mkdir -p "''${HOME}/.local/share/gnome-remote-desktop/" - mv rdp-tls.key rdp-tls.crt "''${HOME}/.local/share/gnome-remote-desktop/" - - # Configure RDP. - grdctl rdp set-tls-cert "''${HOME}/.local/share/gnome-remote-desktop/rdp-tls.crt" - grdctl rdp set-tls-key "''${HOME}/.local/share/gnome-remote-desktop/rdp-tls.key" - grdctl rdp set-credentials "''${user}" "''${password}" - grdctl rdp disable-view-only - - # Start service. - grdctl rdp enable - systemctl --user start gnome-remote-desktop.service - - # Show status. - grdctl status --show-credentials - systemctl --user status gnome-remote-desktop.service - - # Show extra info. - _warn "You may need to manually restart Desktop sharing via Gnome Settings." - } ''; } diff --git a/home/program/bash/module/Markdown.nix b/home/program/bash/module/Markdown.nix deleted file mode 100644 index 77498fc..0000000 --- a/home/program/bash/module/Markdown.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ ... }: -{ - text = '' - # Render markdown in browser using Gitea API. Because I want consistency with Gitea web render. - # Works only inside LAN. - # Usage: markdown_render - function markdown_render() { - local IFS=$'\n' - local file="''${1}" - local render="markdown_render.html" - - if [[ "''${file}" = "" ]]; then - help markdown_render - return 2 - fi - - curl -X POST https://git.voronind.com/markdown -d "$(cat ''${file})" > "''${render}" && o "''${render}" && sleep 2 && rm "''${render}" - } - ''; -} diff --git a/home/program/bash/module/Network.nix b/home/program/bash/module/Network.nix deleted file mode 100644 index 6e3578a..0000000 --- a/home/program/bash/module/Network.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ ... }: -{ - text = '' - # Open bluetooth control panel. - function bluetooth() { - blueman-manager - } - - # Open network control panel. - function network() { - nm-connection-editor - } - - # Show active connections. - function nms() { - nmcli connection show - } - - # Start the connection. - # Usage: nu - function nmu() { - nmcli connection up "''${@}" - } - - # Stop the connection. - # Usage: nd - function nmd() { - nmcli connection down "''${@}" - } - - function _complete_connections() { - _autocomplete $(nmcli connection show | sed "1d" | cut -d\ -f1) - } - - complete -F _complete_connections nmd nmu - ''; -} diff --git a/home/program/bash/module/Nix.nix b/home/program/bash/module/Nix.nix index 3bbe2af..e6fa0ec 100644 --- a/home/program/bash/module/Nix.nix +++ b/home/program/bash/module/Nix.nix @@ -1,28 +1,6 @@ -{ const, ... }: +{ ... }: { text = '' - export _nix_system_config="git+${const.url}" - - # Rebuild system. - # Optionally force the hostname. - # Usage: nixos_rebuild [HOSTNAME] - function nixos_rebuild() { - local target="''${1}" - [[ "''${target}" = "" ]] && target="''${HOSTNAME}" - - nixos-rebuild boot --refresh --option eval-cache false --flake "''${_nix_system_config}#''${target}" - } - - # Rebuild and switch system. - # Optionally force the hostname. - # Usage: nixos_switch [HOSTNAME] - function nixos_switch() { - local target="''${1}" - [[ "''${target}" = "" ]] && target="''${HOSTNAME}" - - nixos-rebuild switch --refresh --option eval-cache false --flake "''${_nix_system_config}#''${target}" - } - # Spawn shell with specified nix environment. # Uses flake.nix in current dir by default. # Usage: shell [NAME] @@ -30,10 +8,7 @@ local target="''${1}" [[ "''${target}" = "" ]] && target="default" - # Create Nix GC root in .NixRoot{NAME}. - nix build ".#devShells.''${NIX_CURRENT_SYSTEM}.''${target}" -o ".NixRoot''${target^}" - - SHELL_NAME="''${target}" nix develop ".#devShells.''${NIX_CURRENT_SYSTEM}.''${target}" + SHELL_NAME="''${target}" nix develop ".#''${target}" } # Spawn temporary nix-shell with specified packages. @@ -42,15 +17,13 @@ local IFS=$'\n' local input=("''${@}") local pkgs=() - local tag="''${SHELL_NAME}" + local tag="''${1}" if [[ "''${input}" = "" ]]; then help tmpshell return 2 fi - [[ "''${tag}" = "" ]] && tag="''${1}" - for pkg in ''${input[@]}; do pkgs+=("nixpkgs#''${pkg}") done @@ -58,35 +31,21 @@ SHELL_NAME="''${tag}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure ''${pkgs[@]} } - # Build live image. - function nixos_live() { - nix build "''${_nix_system_config}#nixosConfigurations.live.config.system.build.isoImage" --refresh ''${@} + # Run stuff directrly from Nixpks. + # Usage: nixpkgs_run [COMMAND] + function nixpkgs_run() { + local rev="''${1}" + local pkg="''${2}" + local cmd="''${@:3}" + + if [[ "''${pkg}" = "" ]]; then + help nixpkgs_run + return 2 + fi + + [[ "''${cmd}" = "" ]] && cmd="''${pkg}" + + SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd} } - - # List nixos generations. - function nixos_generations() { - nix-env -p /nix/var/nix/profiles/system --list-generations - } - - # Switch nix-on-droid. - function nixdroid_switch() { - nix-on-droid switch --flake "''${_nix_system_config}" ''${@} - } - - # Nix auto-run wrapper. - # Usage: , - function ,() { - NIX_AUTO_RUN=1 ''${@} - } - - # Autocomplete with available hosts. - function _comp_hosts() { - local IFS=$'\n' - local targets=($(ls ~/.config/linux/system/host/)) - - _autocomplete_first ''${targets[@]} - } - - complete -F _comp_hosts nix_switch nix_rebuild ''; } diff --git a/home/program/bash/module/Power.nix b/home/program/bash/module/Power.nix deleted file mode 100644 index 030e6bc..0000000 --- a/home/program/bash/module/Power.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ ... }: -{ - text = '' - # Suspend system. - function slp() { - systemctl suspend -i - } - - # Poweroff. - function bye() { - systemctl poweroff -i - } - ''; -} diff --git a/home/program/bash/module/Prune.nix b/home/program/bash/module/Prune.nix deleted file mode 100644 index 08d39a8..0000000 --- a/home/program/bash/module/Prune.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ ... }: -{ - text = '' - export _flatpakcfg_path="''${HOME}/.config/linux/Flatpak.txt" - - # Prune everything unused in docker. - function prune_docker() { - docker system prune --volumes --all - } - - # Prune Nix Store. - function prune_nix() { - nix-store --gc - } - - # Uninstall flatpaks not listed in the config. - function prune_flatpak() { - local IFS=$'\n' - local config=($(cat ''${_flatpakcfg_path} | cut -f2)) - local installed=($(flatpak list --app | cut -f2)) - - process() { - _contains ''${target} ''${config[@]} || flatpak uninstall ''${target} - } - - _iterate_targets process ''${installed[@]} - } - ''; -} diff --git a/home/program/bash/module/Ssh.nix b/home/program/bash/module/Ssh.nix deleted file mode 100644 index f40fcfc..0000000 --- a/home/program/bash/module/Ssh.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ ... }: -{ - text = '' - # Mount FS over ssh. Just extra config for sshfs. - # Usage: ssh_mount - function ssh_mount() { - sshfs -o uid=''${UID},auto_unmount "''${@}" - } - - # Mount FS over ssh. Just extra config for sshfs. - # Usage: ssh_mount - function ssh_mount_ro() { - sshfs -o uid=''${UID},auto_unmount,ro "''${@}" - } - - # Generate private an public keys on a local host and print a public key. - function ssh_keygen() { - ssh-keygen && cat ~/.ssh/*.pub - } - - complete -o nospace -F _sshfs sshmount - ''; -} diff --git a/home/program/bash/module/Steam.nix b/home/program/bash/module/Steam.nix deleted file mode 100644 index 37ad0ad..0000000 --- a/home/program/bash/module/Steam.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: -{ - text = '' - # Start Steam with Wayland screen share for Link to work. - function steam_link() { - steam -pipewire -pipewire-dmabuf - } - ''; -} diff --git a/home/program/bash/module/Terminal.nix b/home/program/bash/module/Terminal.nix deleted file mode 100644 index bd56690..0000000 --- a/home/program/bash/module/Terminal.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: -{ - text = '' - # Get terminal size. - function tsize() { - local width=$(tput cols) - local height=$(tput lines) - echo "''${width}x''${height}" - } - ''; -} diff --git a/home/program/bash/module/Tmp.nix b/home/program/bash/module/Tmp.nix deleted file mode 100644 index d1d169e..0000000 --- a/home/program/bash/module/Tmp.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ ... }: -{ - text = '' - # CD into host's primary tmp dir. - function tmp() { - local host="''${HOSTNAME}" - local tmp_path - - case "''${host}" in - "desktop"|"home") - tmp_path="/storage/hot/tmp" - ;; - *) - tmp_path="''${HOME}/tmp" - ;; - esac - - cd "''${tmp_path}" - } - ''; -} diff --git a/home/program/bash/module/Todo.nix b/home/program/bash/module/Todo.nix deleted file mode 100644 index 554feea..0000000 --- a/home/program/bash/module/Todo.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: -{ - text = '' - # Open `~/.todo.md` file. - function todo() { - vi ~/.todo.md - } - ''; -} diff --git a/home/program/bash/module/Util.nix b/home/program/bash/module/Util.nix index d2e4acf..cad702b 100644 --- a/home/program/bash/module/Util.nix +++ b/home/program/bash/module/Util.nix @@ -155,22 +155,5 @@ local users=("voronind" "dasha") echo ''${users[@]} } - - # Force the command to be called twice within the specified period in seconds. Used primarily in important keyboard shortcuts like poweroff. - # Usage: _twice - function _twice() { - local IFS=$'\n' - local file="/tmp/.twice" - local period=''${1} - local command="''${@:2}" - - if [[ "$(cat ''${file} 2> /dev/null)" = "''${command}" ]]; then - ''${command} - return 0 - fi - echo "''${command}" > "''${file}" - sleep ''${period} - rm "''${file}" 2> /dev/null - } ''; } diff --git a/home/program/bash/module/Zapret.nix b/home/program/bash/module/Zapret.nix deleted file mode 100644 index 9c8acc7..0000000 --- a/home/program/bash/module/Zapret.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: -{ - text = '' - # FRKN. - # SOURCE: https://github.com/bol-van/zapret - function zapret() { - iptables -t mangle -I POSTROUTING -p tcp -m multiport --dports 80,443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num 200 --queue-bypass - nfqws --pidfile=/run/nfqws.pid --qnum=201 ''${@} - } - ''; -} diff --git a/module/Ollama.nix b/module/Ollama.nix deleted file mode 100644 index 3d90502..0000000 --- a/module/Ollama.nix +++ /dev/null @@ -1,61 +0,0 @@ -# https://github.com/ollama/ollama -{ - pkgsStable, - lib, - config, - ... -}: -with lib; -let - pkgs = pkgsStable; - cfg = config.module.ollama; -in -{ - options = { - module.ollama = { - enable = mkEnableOption "Local LLM server"; - primaryModel = mkOption { - default = "llama3"; - type = types.str; - }; - models = mkOption { - default = [ cfg.primaryModel ]; - type = types.listOf types.str; - }; - }; - }; - - config = mkIf cfg.enable { - environment = { - # Specify default model. - variables.OLLAMA_MODEL = cfg.primaryModel; - }; - - systemd.services = { - # Enable Ollama server. - ollama = { - description = "Ollama LLM server."; - wantedBy = [ "multi-user.target" ]; - wants = [ "NetworkManager-wait-online.service" ]; - after = [ "NetworkManager-wait-online.service" ]; - serviceConfig.Type = "simple"; - script = '' - HOME=/root ${getExe pkgs.ollama} serve - ''; - }; - - # Download Ollama models. - ollamamodel = { - description = "Ollama LLM model."; - wantedBy = [ "multi-user.target" ]; - wants = [ "ollama.service" ]; - after = [ "ollama.service" ]; - serviceConfig.Type = "simple"; - script = '' - sleep 5 - ${getExe pkgs.ollama} pull ${concatStringsSep " " cfg.models} - ''; - }; - }; - }; -}