diff --git a/flake.lock b/flake.lock index 1c11053..0a6677a 100644 --- a/flake.lock +++ b/flake.lock @@ -191,27 +191,6 @@ "url": "https://install.determinate.systems/determinate-nixd/tag/v3.21.8/x86_64-linux" } }, - "emacs-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1785001529, - "narHash": "sha256-9LVzQuieVsYQWRDbOZrHAZcYf5MYLIuv9LWb+oV24zA=", - "owner": "nix-community", - "repo": "emacs-overlay", - "rev": "50c7c057b5c0ac06864cfd85f1c0c0895b0bfedf", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "emacs-overlay", - "type": "github" - } - }, "firefox-gnome-theme": { "flake": false, "locked": { @@ -274,22 +253,6 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, - "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -739,22 +702,6 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1784856561, - "narHash": "sha256-J+Bx1Z6Oeoj2FgnBhRMKyUhhtDoOpTgXYaVLZpDjW4A=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "597283ad8aa0b331c788e97c4c262d58877074ef", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-26.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1782767157, @@ -845,7 +792,6 @@ "agenix": "agenix", "chaotic": "chaotic", "determinate": "determinate", - "emacs-overlay": "emacs-overlay", "giz": "giz", "helium": "helium", "home-manager": "home-manager_3", @@ -856,9 +802,7 @@ "stinkpot": "stinkpot", "stylix": "stylix", "tork": "tork", - "treefmt-nix": "treefmt-nix", - "xlibre-overlay": "xlibre-overlay", - "zig-overlay": "zig-overlay_2" + "xlibre-overlay": "xlibre-overlay" } }, "stinkpot": { @@ -975,22 +919,6 @@ "type": "github" } }, - "systems_5": { - "flake": false, - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "tinted-kitty": { "flake": false, "locked": { @@ -1075,26 +1003,6 @@ "type": "github" } }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1784369104, - "narHash": "sha256-47cxbcZODibHv3rELFQ9vZly0vUNkND/atn/U7HLeb0=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "df3c0640565d04a0261253cdd89fce78ec50168a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - }, "xlibre-overlay": { "inputs": { "flake-parts": "flake-parts_4", @@ -1136,28 +1044,6 @@ "repo": "zig-overlay", "type": "github" } - }, - "zig-overlay_2": { - "inputs": { - "flake-compat": "flake-compat_4", - "nixpkgs": [ - "nixpkgs" - ], - "systems": "systems_5" - }, - "locked": { - "lastModified": 1784940578, - "narHash": "sha256-I2DK3JboNU4G3ncdyvaiXIh3pa43I8JBjC1fp7LjtXs=", - "owner": "mitchellh", - "repo": "zig-overlay", - "rev": "c01b28d4f7612f2d3e1673cdb1f24f8b45561dc5", - "type": "github" - }, - "original": { - "owner": "mitchellh", - "repo": "zig-overlay", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index fa9f042..7a87f2b 100644 --- a/flake.nix +++ b/flake.nix @@ -26,10 +26,6 @@ url = "github:nix-community/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; - # emacs-overlay = { - # url = "github:nix-community/emacs-overlay"; - # inputs.nixpkgs.follows = "nixpkgs"; - # }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -54,7 +50,6 @@ outputs = inputs@{ nixpkgs, - treefmt-nix, chaotic, stylix, ... @@ -67,13 +62,6 @@ tork = import ./overlays/tork.nix inputs; }; - treefmtEval = treefmt-nix.lib.evalModule pkgs { - projectRootFile = "flake.nix"; - programs = { - nixfmt.enable = true; - black.enable = true; - }; - }; in { overlays = overlays; @@ -90,7 +78,6 @@ } stylix.nixosModules.stylix chaotic.nixosModules.default - # ./modules/system/stylix.nix ./configuration.nix inputs.determinate.nixosModules.default inputs.nix-flatpak.nixosModules.nix-flatpak @@ -112,6 +99,5 @@ }; devShells.${system}.default = pkgs.mkShell { packages = [ ]; }; - checks.${system}.formatting = treefmtEval.config.build.check inputs.self; }; } diff --git a/modules/home/scripts.nix b/modules/home/scripts.nix index 693c49c..693f6f1 100644 --- a/modules/home/scripts.nix +++ b/modules/home/scripts.nix @@ -1,5 +1,124 @@ { pkgs, lib }: let + + screenshotScript = pkgs.writeShellScriptBin "screenshot" '' + MODE="$1" + BASE_DIR="$HOME/Pictures/screenshots" + DATE_DIR="$(date +'%Y-%m-%d')" + DIR="$BASE_DIR/$DATE_DIR" + mkdir -p "$DIR" + TMPDIR=$(mktemp -d) + FILE="$DIR/$(date +'%Y-%m-%d_%H-%M-%S').png" + + if [ "$MODE" = "select" ]; then + ${lib.getExe pkgs.scrot} -s "$FILE" || exit 1 + else + ${lib.getExe pkgs.scrot} "$FILE" || exit 1 + fi + + [ ! -f "$FILE" ] && exit 1 + ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png -i "$FILE" + + CROPPED_FILE="$TMPDIR/cropped.png" + ${pkgs.imagemagick}/bin/magick "$FILE" \ + -gravity center \ + -crop '%[fx:min(w,h)]x%[fx:min(w,h)]+0+0' \ + -resize 128x128 +repage "$CROPPED_FILE" 2>/dev/null \ + || CROPPED_FILE="$FILE" + + ACTION=$(${pkgs.libnotify}/bin/dunstify "Screenshot saved" \ + -i "$CROPPED_FILE" -t 4000 \ + -A view,"View Image" \ + -A open,"Open Folder") + [ "$ACTION" = "view" ] && xdg-open "$FILE" & + [ "$ACTION" = "open" ] && xdg-open "$(dirname "$FILE")" & + (sleep 3 && rm -rf "$TMPDIR") & + ''; + screenrecordScript = pkgs.writeShellScriptBin "screenrecord" '' + FPS=60 + VIDEO_CODEC="hevc" + AUDIO_CODEC="opus" + QUALITY="high" + MODE="$1" + BASE_DIR="$HOME/Videos/recordings" + DIR="$BASE_DIR/$(date +'%Y-%m-%d')" + mkdir -p "$DIR" + PIDFILE="/tmp/gpu-screen-recorder.pid" + + if [ -f "$PIDFILE" ]; then + PID=$(head -1 "$PIDFILE") + FILE=$(tail -1 "$PIDFILE") + + if kill -0 "$PID" 2>/dev/null; then + kill -INT "$PID" + wait "$PID" 2>/dev/null + rm -f "$PIDFILE" + + TMPDIR=$(mktemp -d) + THUMB="$TMPDIR/thumb.png" + + ${lib.getExe pkgs.ffmpeg} \ + -i "$FILE" \ + -vframes 1 \ + -vf "scale=128:128:force_original_aspect_ratio=increase,crop=128:128" \ + -y "$THUMB" \ + 2>/dev/null + + printf 'file://%s' "$FILE" | ${pkgs.xclip}/bin/xclip -selection clipboard + + ICON_ARG="" + [ -f "$THUMB" ] && ICON_ARG="-i $THUMB" + + ACTION=$(${pkgs.libnotify}/bin/dunstify \ + "Recording saved" \ + $ICON_ARG \ + -t 4000 \ + -A view,"View Recording" \ + -A open,"Open Folder") + + [ "$ACTION" = "view" ] && xdg-open "$FILE" + [ "$ACTION" = "open" ] && xdg-open "$(dirname "$FILE")" + + (sleep 3 && rm -rf "$TMPDIR") & + exit 0 + else + rm -f "$PIDFILE" + fi + fi + + FILE="$DIR/$(date +'%Y-%m-%d_%H-%M-%S').mp4" + + MONITOR=$(${pkgs.xrandr}/bin/xrandr --current \ + | awk '/ connected/ {print $1; exit}') + + if [ "$MODE" = "select" ]; then + GEOMETRY=$(${lib.getExe pkgs.slop} -f "%wx%h+%x+%y") || exit 1 + + ${pkgs.gpu-screen-recorder}/bin/gpu-screen-recorder \ + -w region \ + -region "$GEOMETRY" \ + -c mp4 \ + -f "$FPS" \ + -a default_output \ + -ac "$AUDIO_CODEC" \ + -k "$VIDEO_CODEC" \ + -q "$QUALITY" \ + -o "$FILE" & + else + ${pkgs.gpu-screen-recorder}/bin/gpu-screen-recorder \ + -w "$MONITOR" \ + -c mp4 \ + -f "$FPS" \ + -a default_output \ + -ac "$AUDIO_CODEC" \ + -k "$VIDEO_CODEC" \ + -q "$QUALITY" \ + -o "$FILE" & + fi + + PID=$! + printf '%s\n%s\n' "$PID" "$FILE" > "$PIDFILE" + ''; cavaScript = pkgs.writeShellScriptBin "waybar-cava" '' set -u bars=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █) @@ -75,5 +194,10 @@ let in { + home.packages = [ + screenshotScript + screenrecordScript + cavaScript + ]; inherit cavaScript trayIndicator updatesCheck; } diff --git a/modules/home/shell/fish.nix b/modules/home/shell/fish.nix index c62759e..b43446e 100644 --- a/modules/home/shell/fish.nix +++ b/modules/home/shell/fish.nix @@ -13,13 +13,24 @@ sudo = "doas"; nhs = "nh os switch"; nhu = "nh os switch -u"; + gota = "got_add"; }; interactiveShellInit = '' set -g fish_greeting "" fortune -s | cowsay echo "$(date +%H:%M) on $(nix --version)" + echo ''; functions = { + got_add = '' + if test -z $argv + got add -R . + return 1 + else if test -n $argv + got add $argv + end + + ''; gg = '' set -l gitdir (git rev-parse --git-dir 2>/dev/null) if test -z "$gitdir" diff --git a/modules/home/terminal.nix b/modules/home/terminal.nix index dd00d7a..92963dc 100644 --- a/modules/home/terminal.nix +++ b/modules/home/terminal.nix @@ -1,6 +1,7 @@ { pkgs, inputs, + lib, ... }: { @@ -23,10 +24,6 @@ x = 8; y = 8; }; - font = { - normal.family = "Commit Mono"; - size = 12; - }; terminal.shell.program = "${pkgs.fish}/bin/fish"; }; }; diff --git a/modules/system/desktop.nix b/modules/system/desktop.nix index 6c3e154..d90c577 100644 --- a/modules/system/desktop.nix +++ b/modules/system/desktop.nix @@ -20,11 +20,9 @@ }; printing.enable = true; dbus.enable = true; + displayManager.lemurs.enable = true; xserver = { enable = true; - displayManager = { - lightdm.enable = true; - }; xkb.layout = "pl"; }; diff --git a/modules/system/font.nix b/modules/system/font.nix index f86d301..59405fd 100644 --- a/modules/system/font.nix +++ b/modules/system/font.nix @@ -6,7 +6,6 @@ packages = with pkgs; [ nerd-fonts.iosevka-term commit-mono - ioskeley-mono.normal-NL-NF ]; fontconfig.defaultFonts.monospace = [ "Commit Mono" diff --git a/modules/system/networking.nix b/modules/system/networking.nix index 2d6b21b..ffef38b 100644 --- a/modules/system/networking.nix +++ b/modules/system/networking.nix @@ -161,7 +161,5 @@ }; hosts."192.168.1.27" = [ "searching.strangled.net" ]; firewall.enable = true; - #firewall.allowedTCPPorts = [ ]; - # firewall.allowedUDPPorts = [ ]; }; } diff --git a/networking-pre-4get.nix.bak b/networking-pre-4get.nix.bak new file mode 100644 index 0000000..2d6b21b --- /dev/null +++ b/networking-pre-4get.nix.bak @@ -0,0 +1,167 @@ +{ + config, + pkgs, + lib, + ... +}: +{ + age.secrets.searx-secret = { + file = ../../secrets/searx-secret.age; + }; + age.secrets.wifi-pass = { + file = ../../secrets/wifi-pass.age; + }; + services = { + caddy = { + enable = true; + email = "sophie@qwq.sh"; + virtualHosts = { + "http://searching.strangled.net:8080" = { + extraConfig = '' + reverse_proxy 127.0.0.1:8888 + ''; + }; + }; + + }; + openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + KbdInteractiveAuthentication = false; + PermitRootLogin = "no"; + }; + }; + searx = { + enable = true; + package = pkgs.searxng; + + settings = { + server = { + port = 8888; + bind_address = "127.0.0.1"; + secret_key = "@SEARX_SECRET_KEY@"; + limiter = true; + public_instance = false; + image_proxy = false; + method = "GET"; + }; + + general = { + debug = false; + instance_name = "local-searx"; + enable_metrics = false; + }; + + ui = { + default_theme = "simple"; + theme_args.simple_style = "auto"; + query_in_title = true; + infinite_scroll = false; + center_alignment = true; + hotkeys = "vim"; + search_on_category_select = false; + }; + + search = { + safe_search = 0; + autocomplete = "duckduckgo"; + autocomplete_min = 2; + ban_time_on_fail = 5; + max_ban_time_on_fail = 120; + }; + + outgoing = { + request_timeout = 5.0; + max_request_timeout = 3.0; + pool_connections = 20; + pool_maxsize = 5; + enable_http2 = true; + }; + + engines = lib.mapAttrsToList (name: value: { inherit name; } // value) { + "google".disabled = false; + "bing".disabled = false; + "brave".disabled = false; + "duckduckgo".disabled = false; + "mojeek".disabled = true; + "qwant".disabled = true; + "google images".disabled = false; + "bing images".disabled = false; + "duckduckgo images".disabled = true; + "google videos".disabled = false; + "bing videos".disabled = false; + "youtube".disabled = false; + "google news".disabled = true; + "wikipedia".disabled = false; + "wikidata".disabled = false; + "github".disabled = false; + "gitlab".disabled = false; + "stackoverflow".disabled = false; + "arch linux wiki".disabled = true; + "genius".disabled = true; + "goodreads".disabled = true; + "imdb".disabled = true; + }; + + enabled_plugins = [ + "Basic Calculator" + "Hash plugin" + "Open Access DOI rewrite" + "Hostnames plugin" + "Unit converter plugin" + "Tracker URL remover" + ]; + }; + }; + avahi = { + enable = true; + nssmdns4 = true; + }; + }; + systemd.services.avahi-daemon.serviceConfig.ExecStartPre = [ + "-${pkgs.coreutils}/bin/rm -f /run/avahi-daemon/pid" + ]; + systemd.services.searx-init.serviceConfig.ExecStartPost = [ + "+${pkgs.writeShellScript "searx-inject-secret" '' + secret=$(cat "${config.age.secrets.searx-secret.path}") + configFile=''${RUNTIME_DIRECTORY}/settings.yml + if [ -f "$configFile" ] && grep -q '@SEARX_SECRET_KEY@' "$configFile"; then + ${pkgs.gnused}/bin/sed -i "s#@SEARX_SECRET_KEY@#$secret#" "$configFile" + fi + ''}" + ]; + systemd.services.searx = { + wantedBy = [ "multi-user.target" ]; + serviceConfig.Restart = "no"; + }; + networking = { + networkmanager.ensureProfiles = { + environmentFiles = [ config.age.secrets.wifi-pass.path ]; + profiles = { + "wlp0s20f3-static" = { + connection = { + id = "wlp0s20f3-static"; + type = "wifi"; + interface-name = "wlp0s20f3"; + }; + wifi = { + ssid = "Orange_Swiatlowod_E4B0"; + }; + wifi-security = { + key-mgmt = "wpa-psk"; + psk = "$WIFI_PASSWORD"; + }; + ipv4 = { + method = "manual"; + address1 = "192.168.1.200/24,192.168.1.1"; + }; + }; + }; + }; + hosts."192.168.1.27" = [ "searching.strangled.net" ]; + firewall.enable = true; + #firewall.allowedTCPPorts = [ ]; + # firewall.allowedUDPPorts = [ ]; + }; +}