From 1da4bf6163cb2cea90086b3b8a2c2416a936e744 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Thu, 27 Nov 2025 17:16:07 +0100 Subject: [PATCH] misc: formatting + updates that weren't commited properly before --- .gitignore | 7 ++ Makefile | 27 +++++ files/curl-timings.txt | 9 ++ files/stt-dictate.sh | 132 ++++++++++---------- home.nix | 50 +++++--- nixos/configuration.nix | 70 ++++++----- nixos/framework.nix | 19 ++- nixos/hardware-configuration.nix | 29 ++--- packages.nix | 93 ++++++++------ programs/git.nix | 34 ++++-- programs/i3.nix | 202 +++++++++++++++++-------------- programs/zsh.nix | 23 ++-- 12 files changed, 400 insertions(+), 295 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 files/curl-timings.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06bcdb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Secrets +files/.aider.conf.yml +*.conf + +# Nix +.direnv/ +result diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e78081 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +.PHONY: all fmt fmt-nix fmt-shell lint lint-shell check clean + +all: fmt lint + +# Formatage +fmt: fmt-nix fmt-shell + +fmt-nix: + find . -name '*.nix' -not -path './.direnv/*' | xargs nixfmt + +fmt-shell: + find . -name '*.sh' -not -path './.direnv/*' | xargs shfmt -w -i 2 + +# Validation +lint: lint-shell + +lint-shell: + find . -name '*.sh' -not -path './.direnv/*' | xargs shellcheck + +# Vérification sans modification +check: + find . -name '*.nix' -not -path './.direnv/*' | xargs nixfmt --check + find . -name '*.sh' -not -path './.direnv/*' | xargs shfmt -d -i 2 + +# Nettoyage +clean: + rm -rf .direnv result diff --git a/files/curl-timings.txt b/files/curl-timings.txt new file mode 100644 index 0000000..23b21e1 --- /dev/null +++ b/files/curl-timings.txt @@ -0,0 +1,9 @@ + time_namelookup: %{time_namelookup}s\n + time_connect: %{time_connect}s\n + time_appconnect: %{time_appconnect}s\n + time_pretransfer: %{time_pretransfer}s\n + time_redirect: %{time_redirect}s\n + time_starttransfer: %{time_starttransfer}s\n + ----------\n + time_total: %{time_total}s\n +Legend: https://cf-assets.www.cloudflare.com/zkvhlag99gkb/2EfInkqn7sNtWkWFdxPDk4/2f3e1c0202ed6025bbe12f6f540c1b4a/Screen-Shot-2018-10-16-at-14.51.29-1.png \ No newline at end of file diff --git a/files/stt-dictate.sh b/files/stt-dictate.sh index cb61019..e989e8a 100755 --- a/files/stt-dictate.sh +++ b/files/stt-dictate.sh @@ -27,85 +27,85 @@ MODEL="${STT_MODEL:-small}" # Notification helper (silently fails if no daemon) notify() { - notify-send "STT" "$1" -t "${2:-2000}" 2>/dev/null || echo "[STT] $1" + notify-send "STT" "$1" -t "${2:-2000}" 2>/dev/null || echo "[STT] $1" } # Telecharge le modele si absent download_model() { - local model_file="${MODEL_DIR}/ggml-${MODEL}.bin" - if [[ ! -f "$model_file" ]]; then - mkdir -p "$MODEL_DIR" - notify "Telechargement du modele ${MODEL}..." 5000 - local url="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${MODEL}.bin" - curl -L "$url" -o "$model_file" - notify "Modele ${MODEL} pret" - fi + local model_file="${MODEL_DIR}/ggml-${MODEL}.bin" + if [[ ! -f "$model_file" ]]; then + mkdir -p "$MODEL_DIR" + notify "Telechargement du modele ${MODEL}..." 5000 + local url="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${MODEL}.bin" + curl -L "$url" -o "$model_file" + notify "Modele ${MODEL} pret" + fi } start_recording() { - # Ne pas démarrer si déjà en cours - if [[ -f "$RECORDING_PID" ]] && kill -0 "$(cat "$RECORDING_PID")" 2>/dev/null; then - return 0 - fi - download_model - # Enregistre avec arecord (format compatible whisper.cpp) - arecord -f S16_LE -r 16000 -c 1 -t wav "$AUDIO_FILE" & - echo $! > "$RECORDING_PID" - notify "Enregistrement..." 1000 + # Ne pas démarrer si déjà en cours + if [[ -f "$RECORDING_PID" ]] && kill -0 "$(cat "$RECORDING_PID")" 2>/dev/null; then + return 0 + fi + download_model + # Enregistre avec arecord (format compatible whisper.cpp) + arecord -f S16_LE -r 16000 -c 1 -t wav "$AUDIO_FILE" & + echo $! >"$RECORDING_PID" + notify "Enregistrement..." 1000 } stop_and_transcribe() { - if [[ -f "$RECORDING_PID" ]]; then - kill "$(cat "$RECORDING_PID")" 2>/dev/null || true - rm -f "$RECORDING_PID" - sleep 0.3 # laisse arecord finaliser le fichier + if [[ -f "$RECORDING_PID" ]]; then + kill "$(cat "$RECORDING_PID")" 2>/dev/null || true + rm -f "$RECORDING_PID" + sleep 0.3 # laisse arecord finaliser le fichier - if [[ ! -f "$AUDIO_FILE" ]] || [[ ! -s "$AUDIO_FILE" ]]; then - notify "Pas d'audio enregistre" - rm -f "$AUDIO_FILE" - return 1 - fi - - notify "Transcription..." 1000 - - local model_file="${MODEL_DIR}/ggml-${MODEL}.bin" - - # Transcription avec whisper.cpp - TEXT=$(whisper-cli \ - -m "$model_file" \ - -l fr \ - -nt \ - -np \ - "$AUDIO_FILE" 2>&1 \ - | grep -v "^load_backend:" \ - | tr -d '\n' \ - | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') - - rm -f "$AUDIO_FILE" - - # Tape le texte au curseur - if [[ -n "$TEXT" ]]; then - sleep 0.1 # petit delai pour focus - xdotool type --delay 10 -- "$TEXT" - notify "$TEXT" - else - notify "Aucun texte detecte" - fi + if [[ ! -f "$AUDIO_FILE" ]] || [[ ! -s "$AUDIO_FILE" ]]; then + notify "Pas d'audio enregistre" + rm -f "$AUDIO_FILE" + return 1 fi + + notify "Transcription..." 1000 + + local model_file="${MODEL_DIR}/ggml-${MODEL}.bin" + + # Transcription avec whisper.cpp + TEXT=$(whisper-cli \ + -m "$model_file" \ + -l fr \ + -nt \ + -np \ + "$AUDIO_FILE" 2>&1 | + grep -v "^load_backend:" | + tr -d '\n' | + sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + + rm -f "$AUDIO_FILE" + + # Tape le texte au curseur + if [[ -n "$TEXT" ]]; then + sleep 0.1 # petit delai pour focus + xdotool type --delay 10 -- "$TEXT" + notify "$TEXT" + else + notify "Aucun texte detecte" + fi + fi } case "${1:-toggle}" in - start) start_recording ;; - stop) stop_and_transcribe ;; - toggle) - if [[ -f "$RECORDING_PID" ]]; then - stop_and_transcribe - else - start_recording - fi - ;; - *) - echo "Usage: $0 {start|stop|toggle}" - exit 1 - ;; +start) start_recording ;; +stop) stop_and_transcribe ;; +toggle) + if [[ -f "$RECORDING_PID" ]]; then + stop_and_transcribe + else + start_recording + fi + ;; +*) + echo "Usage: $0 {start|stop|toggle}" + exit 1 + ;; esac diff --git a/home.nix b/home.nix index 6b1906b..88df579 100644 --- a/home.nix +++ b/home.nix @@ -8,26 +8,26 @@ home.file.".config/traefik/traefik.toml".source = ./files/traefik.toml; home.file.".npmrc".source = ./files/.npmrc; + home.file.".aider.conf.yml".source = ./files/.aider.conf.yml; home.file.".local/bin/stt-dictate" = { source = ./files/stt-dictate.sh; executable = true; }; - imports = - [ - ./packages.nix + imports = [ + ./packages.nix - ./programs/git.nix - ./programs/i3.nix - ./programs/zsh.nix - ]; + ./programs/git.nix + ./programs/i3.nix + ./programs/zsh.nix + ]; programs.btop.enable = true; programs.vim.enable = true; programs.vscode = { enable = true; package = pkgs.vscode.fhs; - extensions = [ ]; + profiles = { default = { extensions = [ ]; }; }; }; programs.rofi = { enable = true; @@ -37,23 +37,35 @@ programs.autorandr = { enable = true; hooks = { - postswitch = { - "notify-i3" = "${pkgs.i3}/bin/i3-msg restart"; - }; + postswitch = { "notify-i3" = "${pkgs.i3}/bin/i3-msg restart"; }; }; }; # https://github.com/nix-community/nix-direnv/ - programs.direnv = - { - enable = true; - enableZshIntegration = true; - nix-direnv.enable = true; - }; + programs.direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ obs-backgroundremoval ]; + }; services.unclutter.enable = true; services.blueman-applet.enable = true; - services.dunst.enable = true; # notification daemon + services.dunst.enable = true; # notification daemon - services.udiskie.enable = true; # require "services.udisks2.enable = true" in system configuration + services.udiskie.enable = + true; # require "services.udisks2.enable = true" in system configuration + + # Workaround for Failed to restart syncthingtray.service: Unit tray.target not found. + # - https://github.com/nix-community/home-manager/issues/2064 + systemd.user.targets.tray = { + Unit = { + Description = "Home Manager System Tray"; + Requires = [ "graphical-session-pre.target" ]; + }; + }; } diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 2f6ae74..93bcb8f 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -5,13 +5,12 @@ { config, pkgs, ... }: { - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - ./framework.nix - - ]; + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ./framework.nix + + ]; # Bootloader. boot.loader.systemd-boot.enable = true; @@ -30,25 +29,24 @@ # Enable networking networking.networkmanager.enable = true; - networking.extraHosts = " -"; + networking.extraHosts = ""; # Set your time zone. time.timeZone = "Europe/Paris"; # Select internationalisation properties. - i18n.defaultLocale = "en_US.utf8"; + i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { - LC_ADDRESS = "fr_FR.utf8"; - LC_IDENTIFICATION = "fr_FR.utf8"; - LC_MEASUREMENT = "fr_FR.utf8"; - LC_MONETARY = "fr_FR.utf8"; - LC_NAME = "fr_FR.utf8"; - LC_NUMERIC = "fr_FR.utf8"; - LC_PAPER = "fr_FR.utf8"; - LC_TELEPHONE = "fr_FR.utf8"; - LC_TIME = "fr_FR.utf8"; + LC_ADDRESS = "fr_FR.UTF-8"; + LC_IDENTIFICATION = "fr_FR.UTF-8"; + LC_MEASUREMENT = "fr_FR.UTF-8"; + LC_MONETARY = "fr_FR.UTF-8"; + LC_NAME = "fr_FR.UTF-8"; + LC_NUMERIC = "fr_FR.UTF-8"; + LC_PAPER = "fr_FR.UTF-8"; + LC_TELEPHONE = "fr_FR.UTF-8"; + LC_TIME = "fr_FR.UTF-8"; }; # Configure keymap in X11 @@ -59,15 +57,9 @@ variant = "bepo"; }; - windowManager = { - i3 = { - enable = true; - }; - }; - }; - services.displayManager = { - defaultSession = "none+i3"; + windowManager = { i3 = { enable = true; }; }; }; + services.displayManager = { defaultSession = "none+i3"; }; # Configure console keymap console.keyMap = "fr"; @@ -89,7 +81,7 @@ # Basics docker - gitAndTools.gitFull + gitFull vim # Sound @@ -108,25 +100,36 @@ # enable = true; # enableSSHSupport = true; # }; - programs.zsh.enable = true; # see https://github.com/NixOS/nixpkgs/issues/20548#issuecomment-261965667 + programs.zsh.enable = + true; # see https://github.com/NixOS/nixpkgs/issues/20548#issuecomment-261965667 programs.light.enable = true; + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ fnm stdenv.cc.cc.lib ]; + }; + # List services that you want to enable: services.nscd.enable = true; services.tlp.enable = true; services.upower.enable = true; # keyboard backlight - services.gnome.at-spi2-core.enable = true; # see https://github.com/NixOS/nixpkgs/pull/49636/files - services.gnome.gnome-keyring.enable = true; # see https://nixos.wiki/wiki/Visual_Studio_Code#Error_after_Sign_On + services.gnome.at-spi2-core.enable = + true; # see https://github.com/NixOS/nixpkgs/pull/49636/files + services.gnome.gnome-keyring.enable = + true; # see https://nixos.wiki/wiki/Visual_Studio_Code#Error_after_Sign_On services.blueman.enable = true; services.udisks2.enable = true; services.resolved.enable = true; + services.gvfs.enable = + true; # to view MTP devices in file manager - https://www.perplexity.ai/search/how-to-browse-files-from-bus-0-QWBoYG1gRLu3uMRqFSzw9A # Enable the OpenSSH daemon. # services.openssh.enable = true; # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; + # Ports: 9003 - Xdebug + networking.firewall.allowedTCPPorts = [ 9003 ]; + networking.firewall.allowedUDPPorts = [ 9003 ]; # Or disable the firewall altogether. # networking.firewall.enable = false; # https://github.com/nix-community/nix-direnv/ @@ -134,6 +137,7 @@ keep-outputs = true keep-derivations = true ''; + nix.settings.extra-experimental-features = [ "nix-command" "flakes" ]; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/nixos/framework.nix b/nixos/framework.nix index a7ab88c..19630d9 100644 --- a/nixos/framework.nix +++ b/nixos/framework.nix @@ -1,4 +1,3 @@ -# # NixOS Configuration for Framework Laptop # Source: https://gist.github.com/digitalknk/ee0379c1cd4597463c31a323ea5882a5 # Alt: https://github.com/NixOS/nixos-hardware/blob/master/framework/default.nix @@ -17,8 +16,7 @@ "layout=bls" # Read $KERNEL_INSTALL_LAYOUT from /etc/machine-info. Please move it to the layout= setting of /etc/kernel/install.conf. ]; - # Use latest kernel version because on 5.15 screen is not detected properly (and external monitor doesn't work either) - boot.kernelPackages = pkgs.linuxPackages_6_1; # see https://github.com/NixOS/nixpkgs/issues/183955#issuecomment-1210468614 + boot.kernelPackages = pkgs.linuxPackages_latest; # prevent "/boot/efi No space left on device" errors - see https://github.com/NixOS/nixpkgs/issues/23926 boot.loader.grub.configurationLimit = 10; @@ -47,12 +45,11 @@ # Display things like a boss ## Make it work - hardware.opengl.enable = true; - hardware.opengl.extraPackages = with pkgs; [ - mesa.drivers # was mesa_drivers before 27th september 2022 - vaapiIntel - vaapiVdpau - libvdpau-va-gl + hardware.graphics.enable = true; + hardware.graphics.extraPackages = with pkgs; [ + mesa + intel-vaapi-driver # used to be vaapiIntel + libva-vdpau-driver # used to be vaapiVdpau intel-media-driver ]; ## Make it nice (https://nixos.wiki/wiki/Xorg && https://wiki.archlinux.org/title/Framework_Laptop#HiDPI_settings) @@ -64,9 +61,9 @@ services.xserver.dpi = 130; environment.variables = { - GDK_SCALE = "1.5"; + GDK_SCALE = "1.3"; GDK_DPI_SCALE = "0.77"; # 1/1.3 - _JAVA_OPTIONS = "-Dsun.java2d.uiScale=1.5"; + _JAVA_OPTIONS = "-Dsun.java2d.uiScale=1.3"; }; # Bring in some audio diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix index 57018c8..53d4076 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration.nix @@ -4,27 +4,23 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { - device = "/dev/disk/by-uuid/db660732-f520-4e68-9141-b0899f221e82"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/db660732-f520-4e68-9141-b0899f221e82"; + fsType = "ext4"; + }; - fileSystems."/boot/efi" = - { - device = "/dev/disk/by-uuid/D7D6-B4C6"; - fsType = "vfat"; - }; + fileSystems."/boot/efi" = { + device = "/dev/disk/by-uuid/D7D6-B4C6"; + fsType = "vfat"; + }; swapDevices = [{ device = "/dev/disk/by-uuid/da431bdf-cec4-4928-b44b-e6d2c3419063"; }]; @@ -37,5 +33,6 @@ # networking.interfaces.wlp166s0.useDHCP = lib.mkDefault true; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/packages.nix b/packages.nix index f8e5eef..6979e88 100644 --- a/packages.nix +++ b/packages.nix @@ -1,30 +1,32 @@ { pkgs, lib, ... }: -{ - nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ - "1password" - "1password-cli" +let + atomicptr = import (fetchTarball + "https://github.com/atomicptr/nix/archive/refs/heads/master.tar.gz") { }; +in { + nixpkgs.config.allowUnfreePredicate = pkg: + builtins.elem (lib.getName pkg) [ + "1password" + "1password-cli" - "ngrok" - "postman" - "vscode" - "code" + "ngrok" + "postman" + "vscode" + "code" - "vivaldi" - "google-chrome" - "slack" - "spotify" - "spotify-unwrapped" - "zoom" + "google-chrome" + "slack" + "spotify" + "spotify-unwrapped" - "ticktick" - ]; + "ticktick" + ]; home.packages = with pkgs; [ wget curl httpie - hurl + hurl # TODO 2025-08-28 Compilation error: error: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique bind gcc openssl.dev @@ -34,11 +36,14 @@ hey ngrok openssl + atomicptr.crab pulseaudioFull pavucontrol bluez # was bluezFull before 27th september 2022 - solaar # bluetooth unifying devices and receiver + + # see https://discourse.nixos.org/t/error-nose-1-3-7-not-supported-for-interpreter-python3-12/48703 + # solaar # bluetooth unifying devices and receiver sakura fasd @@ -62,12 +67,12 @@ xsel trippy monolith # save a web page as a single file + killport atool unzip zip - pass _1password-cli _1password-gui yubico-pam @@ -85,35 +90,32 @@ gh meld difftastic + glab firefox - vivaldi google-chrome - epiphany offpunk lagrange thunderbird slack + mattermost-desktop signal-desktop - tdesktop - zoom-us libreoffice freemind filezilla vokoscreen-ng ffmpeg - flameshot + ksnip gimp copyq wireshark gcalcli + zed-editor + kdePackages.kcachegrind spotify - spotdl + # spotdl see https://discourse.nixos.org/t/error-nose-1-3-7-not-supported-for-interpreter-python3-12/48703 vlc - audacity - obs-studio - shotcut jetbrains-mono vscode.fhs @@ -122,13 +124,14 @@ playerctl numlockx - nixpkgs-fmt - nodejs_20 + nixfmt-classic + nodejs_22 + fnm bun cypress docker docker-compose - kube3d + k3d kubectl kubernetes-helm stern @@ -136,16 +139,23 @@ krew php - php83Packages.composer - python3 - pipx # for global python packages (aider-chat, fabric, etc.) - conda + php84Packages.composer + mariadb + adminer + python312 + python312Packages.pip + python312Packages.uv + # pipx # for global python packages (aider-chat, fabric, etc.) + twine + # uv + # conda mkcert goaccess grafana-loki # logcli checkbashisms shellcheck + shfmt toilet # AI @@ -158,9 +168,18 @@ # Perso nextcloud-client rclone - ventoy-full - # calibre + # calibre gparted ticktick + agate + beancount + + ## TODO: fix fava + # Checking runtime dependencies for fava-1.29-py3-none-any.whl + # copying path '/nix/store/yxd2da4vc9gi5jbs1nlvwpsmwj308bp1-kdoctools-6.10.0' from 'https://cache.nixos.org'... + # - beancount<3,>=2.3.5 not satisfied by version 3.0.0 + # copying path '/nix/store/a8n27li3n2fy8jfdm99v9j3yn6w3yk5y-kguiaddons-6.10.0' from 'https://cache.nixos.org'... + # error: builder for '/nix/store/2xd25ssas4yliykz4y4n8p6h762wcalm-fava-1.29.drv' failed with exit code 1 + # fava ]; } diff --git a/programs/git.nix b/programs/git.nix index cfe3389..c600fbf 100644 --- a/programs/git.nix +++ b/programs/git.nix @@ -4,17 +4,7 @@ programs.gitui.enable = true; programs.git = { enable = true; - package = pkgs.gitAndTools.gitFull; - - # TODO: https://www.imagile.fr/utiliser-automatiquement-plusieurs-identites-sur-git/ - userEmail = "pierre@front-commerce.com"; - userName = "Pierre Martin"; - - aliases = { - co = "checkout"; - pushf = "push --force-with-lease --force-if-includes"; - aimr = "log --pretty=format:'%s%n%b---'"; - }; + package = pkgs.gitFull; ignores = [ ".DS_Store" @@ -28,11 +18,29 @@ "shell.nix" ".envrc" ".direnv" + ".ddev" + ".claude" + "CLAUDE.local.md" ]; # see https://github.com/dandavison/delta#get-started - delta.enable = true; - extraConfig = { + #delta.enable = true; + # TEMPORARY DEACTIVATED due to the error + # error[E0282]: type annotations needed for `Box<_>` + # --> /build/delta-0.17.0-vendor.tar.gz/time/src/format_description/parse/mod.rs:83:9 + + settings = { + alias = { + co = "checkout"; + pushf = "push --force-with-lease --force-if-includes"; + aimr = "log --pretty=format:'%s%n%b---'"; + }; + + user = { + email = "pierre@front-commerce.com"; + name = "Pierre Martin"; + }; + merge.conflictstyle = "diff3"; diff.colorMoved = "default"; diff --git a/programs/i3.nix b/programs/i3.nix index 0bb297c..ffcff76 100644 --- a/programs/i3.nix +++ b/programs/i3.nix @@ -3,96 +3,118 @@ { home.file.".i3status.conf".source = ../files/.i3status.conf; - xsession.windowManager.i3 = - let - modifier = "Mod4"; - in - { - enable = true; - config = { - assigns = { - # https://rycee.gitlab.io/home-manager/options.html#opt-xsession.windowManager.i3.config.assigns - }; - focus = { - mouseWarping = false; # Whether mouse cursor should be warped to the center of the window when switching focus to a window on a different output. - }; - - modifier = modifier; - - # see https://rycee.gitlab.io/home-manager/options.html#opt-xsession.windowManager.i3.config.keybindings - keybindings = pkgs.lib.mkOptionDefault { - "${modifier}+Return" = "exec sakura"; #i3-sensible-terminal - - ### BÉPO ### - "${modifier}+b" = "kill"; - "${modifier}+d" = "exec rofi -combi-modi 'window#run#ssh#emoji#calc' -modi 'calc#combi' -show combi"; - "${modifier}+e" = "fullscreen toggle"; - # change container layout (stacked, tabbed, toggle split) - "${modifier}+u" = "layout stacking"; - "${modifier}+eacute" = "layout tabbed"; - "${modifier}+p" = "layout toggle split"; - "${modifier}+Shift+t" = "i3lock --colour=000000"; - # switch to workspace - "${modifier}+quotedbl" = "workspace 1"; - "${modifier}+guillemotleft" = "workspace 2"; - "${modifier}+guillemotright" = "workspace 3"; - "${modifier}+parenleft" = "workspace 4"; - "${modifier}+parenright" = "workspace 5"; - "${modifier}+at" = "workspace 6"; - "${modifier}+plus" = "workspace 7"; - "${modifier}+minus" = "workspace 8"; - "${modifier}+slash" = "workspace 9"; - "${modifier}+asterisk" = "workspace 10"; - # move workspaces between outputs - "${modifier}+Control+Left" = "move workspace to output left"; - "${modifier}+Control+Right" = "move workspace to output right"; - "${modifier}+Control+Up" = "move workspace to output up"; - "${modifier}+Control+Down" = "move workspace to output down"; - # move focused container to workspace - "${modifier}+Shift+quotedbl" = "move container to workspace 1"; - "${modifier}+Shift+guillemotleft" = "move container to workspace 2"; - "${modifier}+Shift+guillemotright" = "move container to workspace 3"; - "${modifier}+Shift+4" = "move container to workspace 4"; - "${modifier}+Shift+5" = "move container to workspace 5"; - "${modifier}+Shift+at" = "move container to workspace 6"; - "${modifier}+Shift+plus" = "move container to workspace 7"; - "${modifier}+Shift+minus" = "move container to workspace 8"; - "${modifier}+Shift+slash" = "move container to workspace 9"; - "${modifier}+Shift+asterisk" = "move container to workspace 10"; - ### /BÉPO ### - - # See https://faq.i3wm.org/question/3747/enabling-multimedia-keys.1.html - # Pulse Audio controls - "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; #increase sound volume - "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; #decrease sound volume - "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound - - # Media player controls - "XF86AudioPlay" = "exec playerctl play"; - "XF86AudioPause" = "exec playerctl pause"; - "XF86AudioNext" = "exec playerctl next"; - "XF86AudioPrev" = "exec playerctl previous"; - - # Sreen brightness controls - "XF86MonBrightnessUp" = "exec light -A 2"; # increase screen brightness - "XF86MonBrightnessDown" = "exec light -U 2"; # decrease screen brightness - - # Speech-to-text (toggle: press to start/stop) - "${modifier}+space" = "exec ~/.local/bin/stt-dictate toggle"; - }; - - startup = [ - { command = "nextcloud"; notification = false; } - { command = "setxkbmap -layout fr -variant bepo"; notification = false; } - { command = "copyq"; notification = false; } - { command = "numlockx on"; notification = false; } # turn verr num on - - { command = "autorandr -c"; notification = false; } - { command = "feh --bg-scale /home/pierre/Documents/Graphisme/fc-bg-light-black.png"; notification = false; } - - # docker run -d --net traefik --ip 172.10.0.10 --restart always -v /var/run/docker.sock:/var/run/docker.sock:ro --name traefik -p 80:80 -p 8080:8080 traefik:2.4.9 --api.insecure=true --providers.docker - # { command = "docker start traefik"; notification = false; } - ]; + xsession.windowManager.i3 = let modifier = "Mod4"; + in { + enable = true; + config = { + assigns = { + # https://rycee.gitlab.io/home-manager/options.html#opt-xsession.windowManager.i3.config.assigns }; + focus = { + mouseWarping = + false; # Whether mouse cursor should be warped to the center of the window when switching focus to a window on a different output. + }; + + modifier = modifier; + + # see https://rycee.gitlab.io/home-manager/options.html#opt-xsession.windowManager.i3.config.keybindings + keybindings = pkgs.lib.mkOptionDefault { + "${modifier}+Return" = "exec sakura"; # i3-sensible-terminal + + ### BÉPO ### + "${modifier}+b" = "kill"; + "${modifier}+d" = + "exec rofi -combi-modi 'window#run#ssh#emoji#calc' -modi 'calc#combi' -show combi"; + "${modifier}+e" = "fullscreen toggle"; + # change container layout (stacked, tabbed, toggle split) + "${modifier}+u" = "layout stacking"; + "${modifier}+eacute" = "layout tabbed"; + "${modifier}+p" = "layout toggle split"; + "${modifier}+Shift+t" = "i3lock --colour=000000"; + # switch to workspace + "${modifier}+quotedbl" = "workspace 1"; + "${modifier}+guillemotleft" = "workspace 2"; + "${modifier}+guillemotright" = "workspace 3"; + "${modifier}+parenleft" = "workspace 4"; + "${modifier}+parenright" = "workspace 5"; + "${modifier}+at" = "workspace 6"; + "${modifier}+plus" = "workspace 7"; + "${modifier}+minus" = "workspace 8"; + "${modifier}+slash" = "workspace 9"; + "${modifier}+asterisk" = "workspace 10"; + # move workspaces between outputs + "${modifier}+Control+Left" = "move workspace to output left"; + "${modifier}+Control+Right" = "move workspace to output right"; + "${modifier}+Control+Up" = "move workspace to output up"; + "${modifier}+Control+Down" = "move workspace to output down"; + # move focused container to workspace + "${modifier}+Shift+quotedbl" = "move container to workspace 1"; + "${modifier}+Shift+guillemotleft" = "move container to workspace 2"; + "${modifier}+Shift+guillemotright" = "move container to workspace 3"; + "${modifier}+Shift+4" = "move container to workspace 4"; + "${modifier}+Shift+5" = "move container to workspace 5"; + "${modifier}+Shift+at" = "move container to workspace 6"; + "${modifier}+Shift+plus" = "move container to workspace 7"; + "${modifier}+Shift+minus" = "move container to workspace 8"; + "${modifier}+Shift+slash" = "move container to workspace 9"; + "${modifier}+Shift+asterisk" = "move container to workspace 10"; + ### /BÉPO ### + + # See https://faq.i3wm.org/question/3747/enabling-multimedia-keys.1.html + # Pulse Audio controls + "XF86AudioRaiseVolume" = + "exec --no-startup-id pactl set-sink-volume 0 +5%"; # increase sound volume + "XF86AudioLowerVolume" = + "exec --no-startup-id pactl set-sink-volume 0 -5%"; # decrease sound volume + "XF86AudioMute" = + "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound + + # Media player controls + "XF86AudioPlay" = "exec playerctl play"; + "XF86AudioPause" = "exec playerctl pause"; + "XF86AudioNext" = "exec playerctl next"; + "XF86AudioPrev" = "exec playerctl previous"; + + # Sreen brightness controls + "XF86MonBrightnessUp" = "exec light -A 2"; # increase screen brightness + "XF86MonBrightnessDown" = + "exec light -U 2"; # decrease screen brightness + + # Speech-to-text (toggle: press to start/stop) + "${modifier}+space" = "exec ~/.local/bin/stt-dictate toggle"; + }; + + startup = [ + { + command = "nextcloud"; + notification = false; + } + { + command = "setxkbmap -layout fr -variant bepo"; + notification = false; + } + { + command = "copyq"; + notification = false; + } + { + command = "numlockx on"; + notification = false; + } # turn verr num on + + { + command = "autorandr -c"; + notification = false; + } + { + command = + "feh --bg-scale /home/pierre/Documents/Graphisme/fc-bg-light-black.png"; + notification = false; + } + + # docker run -d --net traefik --ip 172.10.0.10 --restart always -v /var/run/docker.sock:/var/run/docker.sock:ro --name traefik -p 80:80 -p 8080:8080 traefik:2.4.9 --api.insecure=true --providers.docker + # { command = "docker start traefik"; notification = false; } + ]; }; + }; } diff --git a/programs/zsh.nix b/programs/zsh.nix index b134f11..529c649 100644 --- a/programs/zsh.nix +++ b/programs/zsh.nix @@ -1,16 +1,15 @@ +{ pkgs, ... }: + { # see https://starship.rs/fr-fr/installing/#declaration-utilisateur-unique-via-home-manager - programs.starship = - { - enable = true; - enableZshIntegration = true; - }; + programs.starship = { + enable = true; + enableZshIntegration = true; + }; programs.zsh = { enable = true; - autosuggestion = { - enable = true; - }; + autosuggestion = { enable = true; }; enableCompletion = true; history = { ignoreDups = true; @@ -37,9 +36,9 @@ # `$` must be escaped with `''` :metal: # source: https://nixos.org/nix-dev/2015-December/019018.html - initExtra = '' + initContent = '' bindkey ' ' forward-word - zstyle ':completion:*:hosts' hosts ''${=''${''${''${''${(@M)''${(f)"''$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} + zstyle ':completion:*:hosts' hosts ''${=''${''${''${''${(@M)''${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} setopt PROMPT_CR setopt PROMPT_SP @@ -77,6 +76,9 @@ source <(k3d completion zsh) source <(kubectl completion zsh) source <(k9s completion zsh); compdef _k9s k9s + + # https://github.com/Schniz/fnm#shell-setup + eval "$(fnm env --use-on-cd --shell zsh)" ''; sessionVariables = { @@ -88,6 +90,7 @@ # see https://github.com/NixOS/nixpkgs/pull/56387 and https://discourse.nixos.org/t/cypress-with-npm/15137/4 CYPRESS_INSTALL_BINARY = 0; CYPRESS_RUN_BINARY = "$HOME/.nix-profile/bin/Cypress"; + LD_LIBRARY_PATH = "${pkgs.libgcc}/lib"; }; shellAliases = {