diff --git a/flake.nix b/flake.nix index e98160f..e360572 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,8 @@ url = "github:nix-community/home-manager/release-25.11"; inputs.nixpkgs.follows = "nixpkgs"; }; - caelestia-shell = { # based on quickshell. See https://github.com/caelestia-dots/shell + caelestia-shell = { + # based on quickshell. See https://github.com/caelestia-dots/shell url = "github:caelestia-dots/shell"; inputs.nixpkgs.follows = "nixpkgs-unstable"; }; diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 3b04587..66d0c5b 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -8,10 +8,7 @@ libs, inputs, ... -}: - - -{ +}: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -23,11 +20,10 @@ ../../modules/nixos/udevsimple.nix ]; - - programs.nix-ld.enable=true; #Run unpatched dynamic binaries on NixOS. For example lets run ./a.out from gcc + programs.nix-ld.enable = true; #Run unpatched dynamic binaries on NixOS. For example lets run ./a.out from gcc documentation.man.generateCaches = true; # used for the man script - + hardware.bluetooth.enable = true; qt.enable = true; @@ -83,12 +79,13 @@ # zsh dont want to work if it is not initialzed here. programs.zsh.enable = true; - security.wrappers.gsr-kms-server = { # to remove the password prompt when using gpu-screen-recorder - owner = "root"; - group = "root"; - capabilities = "cap_sys_admin+ep"; - source = "${pkgs.gpu-screen-recorder}/bin/gsr-kms-server"; -}; + security.wrappers.gsr-kms-server = { + # to remove the password prompt when using gpu-screen-recorder + owner = "root"; + group = "root"; + capabilities = "cap_sys_admin+ep"; + source = "${pkgs.gpu-screen-recorder}/bin/gsr-kms-server"; + }; # Enable the GNOME Desktop Environment. # services.displayManager.gdm.enable = true; @@ -160,7 +157,6 @@ options = "--delete-older-than 7d"; # every week delete generations older than a month }; - # Allow unfree packages nixpkgs.config.allowUnfree = true; # Nonfree packages: Obsidian @@ -221,20 +217,22 @@ framework-tool framework-tool-tui krita # image edition - yt-dlp# some youtube downloader + yt-dlp # some youtube downloader vlc - (pkgs-unstable.python314.withPackages (ps: with ps; [ - matplotlib - networkx - scipy - ])) + (pkgs-unstable.python314.withPackages (ps: + with ps; [ + matplotlib + networkx + scipy + ])) iamb # matrix client direnv vivify # for nvimnotes # utils for dev pkg-config gdb - raylib glfw # raylib and some dependecies + raylib + glfw # raylib and some dependecies rembg # background remover #some nix tools manix diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index b054e31..d7db096 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -17,7 +17,7 @@ ../../modules/home-manager/hyprland.nix #../../modules/home-manager/wlogout.nix # logout utility ../../modules/home-manager/rofi.nix # used for keybinds and for clipboard - #notifications are now manager with quickshell../../modules/home-manager/swaync.nix # notification daemon + #notifications are now manager with quickshell../../modules/home-manager/swaync.nix # notification daemon ../../modules/home-manager/neovim.nix # dont use nixvim. broken #../../modules/home-manager/neovim2.nix # ./neovim2.nix uses vim plug instead of the nix repository as with ./neovim.nix see the begining of neovim2 for an explanation ../../modules/home-manager/rclone.nix @@ -25,7 +25,7 @@ #../../modules/home-manager/quickshell.nix # used for widgets, waybar and notifications # i migrated to caelestia-shell inputs.caelestia-shell.homeManagerModules.default ../../modules/home-manager/caelestia.nix # caelestia shell is based on quickshell -#../../modules/home-manager/oh-my-posh.nix # zsh customizer + #../../modules/home-manager/oh-my-posh.nix # zsh customizer ../../modules/home-manager/oh-my-zsh.nix # another zsh customizer #../../modules/home-manager/hypridle.nix #../../modules/home-manager/swaylock.nix @@ -88,45 +88,47 @@ #(pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {}) #(pkgs.callPackage ../../modules/scripts/QSnotifycache.nix {}) #(pkgs.callPackage ../../modules/scripts/QSnotifyhistory.nix {}) -#pkgs + #pkgs pkgs.gruvbox-gtk-theme pkgs.biber (pkgs.texliveMedium.withPackages ( - ps: with ps; [ - # these few pkgs are used in the CV template - titlesec # allows creating custom \section - marvosym # some symboles - ebgaramond # Use the EB Garamond font - microtype # To enable letterspacing - fontaxes - # these few pkgs were used for my TM - svg - catchfile - caption - transparent - cfr-lm - svn-prov - nfssext-cfr - hyphenat - csquotes - enumitem - chngcntr - tcolorbox - pdfcol - wrapfig - tocloft - lastpage - biblatex - biblatex-iso690 - libertine - minted - upquote - lipsum - footmisc - #(setq org-latex-compiler "lualatex") - #(setq org-preview-latex-default-process 'dvisvgm) - ])) - # # It is sometimes useful to fine-tune packages, for example, by applying + ps: + with ps; [ + # these few pkgs are used in the CV template + titlesec # allows creating custom \section + marvosym # some symboles + ebgaramond # Use the EB Garamond font + microtype # To enable letterspacing + fontaxes + # these few pkgs were used for my TM + svg + catchfile + caption + transparent + cfr-lm + svn-prov + nfssext-cfr + hyphenat + csquotes + enumitem + chngcntr + tcolorbox + pdfcol + wrapfig + tocloft + lastpage + biblatex + biblatex-iso690 + libertine + minted + upquote + lipsum + footmisc + #(setq org-latex-compiler "lualatex") + #(setq org-preview-latex-default-process 'dvisvgm) + ] + )) + # # It is sometimes useful to fine-tune packages, for example, by applying # # overrides. You can do that directly here, just don't forget the # # parentheses. Maybe you want to install Nerd Fonts with a limited number of # # fonts? diff --git a/modules/home-manager/caelestia.nix b/modules/home-manager/caelestia.nix index d0a51b8..1c79c98 100644 --- a/modules/home-manager/caelestia.nix +++ b/modules/home-manager/caelestia.nix @@ -1,593 +1,598 @@ -{ +{ config, pkgs, pkgs-unstable, caelestia-shell, ... -}: -let +}: let sisyphe = ../../assets/sisyphe.gif; pepe-music = ../../assets/pepe-music.gif; in { - - home.file.".face" = { # this is were caelestia will search for profiles pictures + home.file.".face" = { + # this is were caelestia will search for profiles pictures source = ../../assets/sisyphePFP.png; }; # set profile picture in ~/.face programs.caelestia = { - enable = true; - systemd = { - enable = false; # if we launch it form here, the keybinds don't work - target = "graphical-session.target"; - environment = []; - }; - settings = { # default config https://github.com/caelestia-dots/shell?tab=readme-ov-file#example-configuration - appearance = { - mediaGifSpeedAdjustment = 500; - sessionGifSpeed = 0.7; - anim = { - duration = { + enable = true; + systemd = { + enable = false; # if we launch it form here, the keybinds don't work + target = "graphical-session.target"; + environment = []; + }; + settings = { + # default config https://github.com/caelestia-dots/shell?tab=readme-ov-file#example-configuration + appearance = { + mediaGifSpeedAdjustment = 500; + sessionGifSpeed = 0.7; + anim = { + duration = { + scale = 1; + }; + }; + /* + font = { + family = { + clock = "Rubik"; # (TODO figure out those fonts) + material = "Material Symboles Rounded"; + mono = "CaskaydiaCove NF"; + sans = "Rubik"; + }; + size = { + scale = 1; + }; + }; + */ + padding = { scale = 1; }; - }; - /*font = { - family = { - clock = "Rubik"; # (TODO figure out those fonts) - material = "Material Symboles Rounded"; - mono = "CaskaydiaCove NF"; - sans = "Rubik"; - }; - size = { + rounding = { scale = 1; }; - };*/ - padding = { - scale = 1; - }; - rounding = { - scale = 1; - }; - spacing = { - scale = 1; - }; - transparency = { - enabled = false; - base = 0.85; - layeres = 0.4; - }; - }; - general = { - logo = "caelestia"; - apps = { - terminal = [ "kitty" ]; # default foot - audio = [ "pavucontrol" ]; - playback = [ "mpv" ]; # what's that? - explorer = [ "nautilus" ]; # default thunar - }; - battery = { - wanLevels = [ - { - level = 20; - title = "Low battery"; - message = "You might want to plug in a charger"; - icon = "battery_android_frame_2"; - } - { - level = 10; - title = "Did you see the previous message?"; - message = "You should probably plug in a charger now"; - icon = "battery_android_frame_1"; - } - { - level = 5; - title = "Critical battery level"; - message = "PLUG THE CHARGER RIGHT NOW!!"; - icon = "battery_android_alert"; - critical = true; - } - ]; - criticalLevel = 3; - }; - idle = { - lockBeforeSleep = true; - inhibitWhenAudio = true; - timeouts = [ - { - timeout = 180; - idleAction = "lock"; - } - { - timeout = 300; - idleAction = "dpms off"; # what's that? - returnAction = "dpms on"; - } - { - timeout = 600; - idleAction = [ "systemctl" "suspend-then-hibernate" ]; - } - ]; - }; - }; - background = { - desktopClock = { - enabled = false; - scale = 1.0; - position = "bottom-right"; - shadow = { - enabled = true; - opacity = 0.7; - blur = 0.4; + spacing = { + scale = 1; }; - background = { + transparency = { enabled = false; - opacity = 0.7; - blur = true; + base = 0.85; + layeres = 0.4; }; - invertColors = false; }; - enabled = false; #default true - visualiser = { - blur = false; - enabled = false; - autohide = true; - rounding = 1; - spacing = 1; + general = { + logo = "caelestia"; + apps = { + terminal = ["kitty"]; # default foot + audio = ["pavucontrol"]; + playback = ["mpv"]; # what's that? + explorer = ["nautilus"]; # default thunar + }; + battery = { + wanLevels = [ + { + level = 20; + title = "Low battery"; + message = "You might want to plug in a charger"; + icon = "battery_android_frame_2"; + } + { + level = 10; + title = "Did you see the previous message?"; + message = "You should probably plug in a charger now"; + icon = "battery_android_frame_1"; + } + { + level = 5; + title = "Critical battery level"; + message = "PLUG THE CHARGER RIGHT NOW!!"; + icon = "battery_android_alert"; + critical = true; + } + ]; + criticalLevel = 3; + }; + idle = { + lockBeforeSleep = true; + inhibitWhenAudio = true; + timeouts = [ + { + timeout = 180; + idleAction = "lock"; + } + { + timeout = 300; + idleAction = "dpms off"; # what's that? + returnAction = "dpms on"; + } + { + timeout = 600; + idleAction = ["systemctl" "suspend-then-hibernate"]; + } + ]; + }; }; - }; - bar = { - activeWindow = { - compact = false; - inverted = false; + background = { + desktopClock = { + enabled = false; + scale = 1.0; + position = "bottom-right"; + shadow = { + enabled = true; + opacity = 0.7; + blur = 0.4; + }; + background = { + enabled = false; + opacity = 0.7; + blur = true; + }; + invertColors = false; + }; + enabled = false; #default true + visualiser = { + blur = false; + enabled = false; + autohide = true; + rounding = 1; + spacing = 1; + }; + }; + bar = { + activeWindow = { + compact = false; + inverted = false; + showOnHover = true; + }; + clock = { + background = true; + showDate = true; + showIcon = true; + }; + dragThreshold = 20; + entries = [ + { + id = "logo"; + enabled = true; + } + { + id = "workspaces"; + enabled = true; + } + { + id = "spacer"; + enabled = true; + } + { + id = "activeWindow"; + enabled = true; + } + { + id = "spacer"; + enabled = true; + } + { + id = "tray"; + enabled = true; + } + { + id = "clock"; + enabled = true; + } + { + id = "statusIcon"; + enabled = true; + } + { + id = "power"; + enabled = true; + } + ]; + persistent = true; + popouts = { + activeWindow = true; + statusIcon = true; + tray = true; + }; + scrollActions = { + brightness = true; + workspaces = true; + volume = true; + }; + showOnHover = true; + status = { + showAudio = false; + showBattery = false; # use powerprofile daemon + showBluetooth = false; + showKbLayout = false; + showMicrophone = false; + showNetwork = false; + showWifi = true; + showLockStatus = false; + }; + tray = { + background = true; # default true + compact = false; + iconSubs = []; + recolour = true; + }; + workspaces = { + activeIndicator = true; + activeLabel = "󰮯"; + activeTrail = false; + label = " "; + occupiedBg = false; + occpiedLabel = "󰮯"; + perMonitorWorkspaces = true; + showWindows = true; + shown = 5; + specialWorkspaceIcons = [ + { + name = "steam"; + icon = "sports_esports"; + } + ]; + windowIcons = [ + { + regex = "steam(_app_(default|[0-9]+))?"; + icon = "sports_esports"; + } + ]; + }; + excludedScreens = [""]; # default says "" those this work? + }; + border = { + rounding = 25; + thickness = 10; + }; + dashboard = { + enabled = true; + dragThreshold = 50; + mediaUpdateInterval = 500; showOnHover = true; }; - clock = { - background = true; - showDate = true; - showIcon = true; - }; - dragThreshold = 20; - entries = [ - { - id = "logo"; - enabled = true; - } - { - id = "workspaces"; - enabled = true; - } - { - id = "spacer"; - enabled = true; - } - { - id = "activeWindow"; - enabled = true; - } - { - id = "spacer"; - enabled = true; - } - { - id = "tray"; - enabled = true; - } - { - id = "clock"; - enabled = true; - } - { - id = "statusIcon"; - enabled = true; - } - { - id = "power"; - enabled = true; - } - ]; - persistent = true; - popouts = { - activeWindow = true; - statusIcon = true; - tray = true; - }; - scrollActions = { - brightness = true; - workspaces = true; - volume = true; - }; - showOnHover = true; - status = { - showAudio = false; - showBattery = false; # use powerprofile daemon - showBluetooth = false; - showKbLayout = false; - showMicrophone = false; - showNetwork = false; - showWifi = true; - showLockStatus = false; - }; - tray = { - background = true; # default true - compact = false; - iconSubs = []; - recolour = true; - }; - workspaces = { - activeIndicator = true; - activeLabel = "󰮯"; - activeTrail = false; - label = " "; - occupiedBg = false; - occpiedLabel = "󰮯"; - perMonitorWorkspaces = true; - showWindows = true; - shown = 5; - specialWorkspaceIcons = [ + launcher = { + actionsPrefix = ">"; + actions = [ { - name = "steam"; - icon = "sports_esports"; + name = "Calculator"; + icon = "calculate"; + description = "Do simple math equations (powered by Qalc)"; + command = ["autocomplete" "calc"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Scheme"; + icon = "palette"; + description = "Change the current colour scheme"; + command = ["autocomplete" "scheme"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Wallpaper"; + icon = "image"; + description = "Change the current wallpaper"; + command = ["autocomplete" "wallpaper"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Variant"; # to remove + icon = "colors"; + description = "Change the current scheme variant"; + command = ["autocomplete" "variant"]; + enabled = true; + dangerous = false; + } + { + name = "Transparency"; + icon = "opacity"; + description = "Change shell transparency"; + command = ["autocomplete" "transparency"]; + enabled = false; + dangerous = false; + } + { + name = "Random"; + icon = "casino"; + description = "Switch to a random wallpaper"; + command = ["caelestia" "wallpaper" "-r"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Light"; + icon = "light_mode"; + description = "Change the scheme to light mode"; + command = ["setMode" "light"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Dark"; + icon = "dark_mode"; + description = "Change the scheme to dark mode"; + command = ["setMode" "dark"]; + enabled = false; # default true + dangerous = false; + } + { + name = "Shutdown"; + icon = "power_settings_new"; + description = "Shutdown the system"; + command = ["systemctl" "poweroff"]; + enabled = true; + dangerous = true; + } + { + name = "Reboot"; + icon = "cached"; + description = "Reboot the system"; + command = ["systemctl" "reboot"]; + enabled = true; + dangerous = true; + } + { + name = "Lock"; # does this work with ly? + icon = "lock"; + description = "Log out of the current session"; + command = ["loginctl" "terminate-user" ""]; + enabled = true; + dangerous = true; + } + { + name = "Sleep"; + icon = "bedtime"; + description = "Suspend then hibernate"; + command = ["systemctl" "suspend-then-hibernate"]; + enabled = true; + dangerous = false; + } + { + name = "Settings"; + icon = "settings"; + description = "Configure the shell"; + command = ["caelestia" "shell" "controlCenter" "open"]; + enabled = false; # default true + dangerous = false; } ]; - windowIcons = [ + dragThreshold = 50; + vimKeybinds = false; # intersting to put to true + enableDangerousActions = false; # set to true + maxShown = 7; + maxWallpapers = 9; + specialPrefix = "@"; + useFuzzy = { + # should try + apps = false; + actions = false; + schemes = false; + variants = false; + wallpapers = false; + }; + showOnHover = false; + favouriteApps = []; + hiddenApps = []; + }; + lock = { + recolourLogo = false; # what's that + hideNotifs = false; + }; + notifs = { + actionOnClick = false; + clearThreshold = 0.3; + defaultExpireTimeout = 5000; + expantThreshold = 20; + openeExpanded = false; + expire = true; + }; + osd = { + # thats the slider for brightness and sound + enabled = true; + enableBrightness = true; + enableMicrophone = false; + hideDelay = 2000; + }; + paths = { + mediaGif = pepe-music; # default "root:/assets/bongocat.gif" + sessionGif = sisyphe; # default "root:/assets/kurukuru.gif" + noNotifsPic = "root:/assets/dino.png"; + lockNoNotifsPic = "root:/assets/dino.png"; + wallpaperDir = "~/Pictures/Wallpapers"; + lyricsDir = "~/Music/lyrics"; + }; + services = { + audioIncrement = 0.1; + brightnessIncrement = 0.1; + maxVolume = 1.0; + defaultPlayer = "Spotify"; + gpuType = ""; + #playerAliases: [ { "from": "com.github.th_ch.youtube_music", "to": "YT Music" } ]; # how to put this into nix language? + weatherLocation = "Lausanne"; + useFahrenheit = false; + useFahrenheitPerformance = false; + useTwelveHourClock = false; + smartScheme = false; # default true + visualisersBars = 45; + }; + session = { + dragThreshold = 30; # what does dragThreshold do? + enabled = true; + vimKeybinds = false; # maybe set to true? + icons = { + logout = "logout"; + shutdown = "power_settings_new"; + hibernate = "downloading"; # find a better icon + reboot = "cached"; + }; + commands = { + logout = ["loginctl" "terminate-user"]; + shutdown = ["systemctl" "poweroff"]; + hibernate = ["systemctl" "hibernate"]; + reboot = ["systemctl" "reboot"]; + }; + }; + sidebar = { + dragThreshold = 80; + enabled = true; + }; + # is there a way to get some system info? + utilities = { + enabled = true; + maxToasts = 4; # toats are like notification but on the botto left + toasts = { + audioInputChanged = true; + audioOutputChanged = true; + capsLockChanged = true; + chargingChanged = true; + configLoaded = true; + dndChanged = true; + gameModeChanged = true; + kbLayoutChanged = true; + kbLimit = true; + numLockChanged = true; + vpnChanged = true; + nowPlaying = false; + }; + }; + vpn = { + enabled = false; # default true + provider = [ { - regex = "steam(_app_(default|[0-9]+))?"; - icon = "sports_esports"; + # default example-configuration + name = "wireguard"; + interface = "your-connection-name"; + displayName = "wireguard (Your VPN)"; + enabled = false; } ]; }; - excludedScreens = [ "" ]; # default says "" those this work? - }; - border = { - rounding = 25; - thickness = 10; - }; - dashboard = { - enabled = true; - dragThreshold = 50; - mediaUpdateInterval = 500; - showOnHover = true; - }; - launcher = { - actionsPrefix = ">"; - actions = [ + quickToggles = [ { - name = "Calculator"; - icon = "calculate"; - description = "Do simple math equations (powered by Qalc)"; - command = [ "autocomplete" "calc" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Scheme"; - icon = "palette"; - description = "Change the current colour scheme"; - command = [ "autocomplete" "scheme" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Wallpaper"; - icon = "image"; - description = "Change the current wallpaper"; - command = [ "autocomplete" "wallpaper" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Variant"; # to remove - icon = "colors"; - description = "Change the current scheme variant"; - command = [ "autocomplete" "variant" ]; + id = "wifi"; enabled = true; - dangerous = false; } { - name = "Transparency"; - icon = "opacity"; - description = "Change shell transparency"; - command = [ "autocomplete" "transparency" ]; - enabled = false; - dangerous = false; - } - { - name = "Random"; - icon = "casino"; - description = "Switch to a random wallpaper"; - command = [ "caelestia" "wallpaper" "-r" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Light"; - icon = "light_mode"; - description = "Change the scheme to light mode"; - command = [ "setMode" "light" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Dark"; - icon = "dark_mode"; - description = "Change the scheme to dark mode"; - command = [ "setMode" "dark" ]; - enabled = false; # default true - dangerous = false; - } - { - name = "Shutdown"; - icon = "power_settings_new"; - description = "Shutdown the system"; - command = [ "systemctl" "poweroff" ]; + id = "bluetooth"; enabled = true; - dangerous = true; } { - name = "Reboot"; - icon = "cached"; - description = "Reboot the system"; - command = [ "systemctl" "reboot" ]; + id = "mic"; enabled = true; - dangerous = true; } { - name = "Lock"; # does this work with ly? - icon = "lock"; - description = "Log out of the current session"; - command = [ "loginctl" "terminate-user" "" ]; + id = "settings"; + enabled = true; # should desactivate + } + { + id = "gameMode"; + enabled = true; # should remap my performance mode + } + { + id = "dnd"; #do not disturb enabled = true; - dangerous = true; } { - name = "Sleep"; - icon = "bedtime"; - description = "Suspend then hibernate"; - command = [ "systemctl" "suspend-then-hibernate" ]; - enabled = true; - dangerous = false; - } - { - name = "Settings"; - icon = "settings"; - description = "Configure the shell"; - command = [ "caelestia" "shell" "controlCenter" "open" ]; - enabled = false; # default true - dangerous = false; + id = "vpn"; + enabled = false; # default true; } ]; - dragThreshold = 50; - vimKeybinds = false; # intersting to put to true - enableDangerousActions = false; # set to true - maxShown = 7; - maxWallpapers = 9; - specialPrefix = "@"; - useFuzzy = { # should try - apps = false; - actions = false; - schemes = false; - variants = false; - wallpapers = false; - }; - showOnHover = false; - favouriteApps = []; - hiddenApps = []; }; - lock = { - recolourLogo = false; # what's that - hideNotifs = false; - }; - notifs = { - actionOnClick = false; - clearThreshold = 0.3; - defaultExpireTimeout = 5000; - expantThreshold = 20; - openeExpanded = false; - expire = true; - }; - osd = { # thats the slider for brightness and sound - enabled = true; - enableBrightness = true; - enableMicrophone = false; - hideDelay = 2000; - }; - paths = { - mediaGif = pepe-music; # default "root:/assets/bongocat.gif" - sessionGif = sisyphe; # default "root:/assets/kurukuru.gif" - noNotifsPic = "root:/assets/dino.png"; - lockNoNotifsPic = "root:/assets/dino.png"; - wallpaperDir = "~/Pictures/Wallpapers"; - lyricsDir = "~/Music/lyrics"; - }; - services = { - audioIncrement = 0.1; - brightnessIncrement = 0.1; - maxVolume = 1.0; - defaultPlayer = "Spotify"; - gpuType = ""; - #playerAliases: [ { "from": "com.github.th_ch.youtube_music", "to": "YT Music" } ]; # how to put this into nix language? - weatherLocation = "Lausanne"; - useFahrenheit = false; - useFahrenheitPerformance = false; - useTwelveHourClock = false; - smartScheme = false; # default true - visualisersBars = 45; - }; - session = { - dragThreshold = 30; # what does dragThreshold do? - enabled = true; - vimKeybinds = false; # maybe set to true? - icons = { - logout = "logout"; - shutdown = "power_settings_new"; - hibernate = "downloading"; # find a better icon - reboot = "cached"; - }; - commands = { - logout = [ "loginctl" "terminate-user" ]; - shutdown = [ "systemctl" "poweroff" ]; - hibernate = [ "systemctl" "hibernate" ]; - reboot = [ "systemctl" "reboot" ]; - }; - }; - sidebar = { - dragThreshold = 80; - enabled = true; - }; - # is there a way to get some system info? - utilities = { - enabled = true; - maxToasts = 4; # toats are like notification but on the botto left - toasts = { - audioInputChanged = true; - audioOutputChanged = true; - capsLockChanged = true; - chargingChanged = true; - configLoaded = true; - dndChanged = true; - gameModeChanged = true; - kbLayoutChanged = true; - kbLimit = true; - numLockChanged = true; - vpnChanged = true; - nowPlaying = false; - }; - }; - vpn = { - enabled = false; # default true - provider = [ - { - # default example-configuration - name = "wireguard"; - interface = "your-connection-name"; - displayName = "wireguard (Your VPN)"; - enabled = false; - } - ]; - }; - quickToggles = [ - { - id = "wifi"; - enabled = true; - } - { - id = "bluetooth"; - enabled = true; - } - { - id = "mic"; - enabled = true; - } - { - id = "settings"; - enabled = true; # should desactivate - } - { - id = "gameMode"; - enabled = true; # should remap my performance mode - } - { - id = "dnd"; #do not disturb - enabled = true; - } - { - id = "vpn"; - enabled = false; # default true; - } - ]; - }; - cli = { # default config https://github.com/caelestia-dots/cli?tab=readme-ov-file#configuring - enable = true; # Also add caelestia-cli to path - settings = { - record = { - extraArgs = []; - }; - wallpaper = { - postHook = "caelestia scheme set -n gruvbox -f soft -m dark"; # sets the theme - }; - theme = { - enableTerm = false; # we do it manually by adapting our kitty config - enableHypr = true; - enableDiscord = true; - enableSpicetify = true; - enableFuzzel = true; #what's that? - enablleBtop = false; # default true - enableQt = true; - }; - toggles = { - communication = { - discord = { - enable = false; # default true - match = [ - { - class = "discord"; - } - ]; - whatsapp = { + cli = { + # default config https://github.com/caelestia-dots/cli?tab=readme-ov-file#configuring + enable = true; # Also add caelestia-cli to path + settings = { + record = { + extraArgs = []; + }; + wallpaper = { + postHook = "caelestia scheme set -n gruvbox -f soft -m dark"; # sets the theme + }; + theme = { + enableTerm = false; # we do it manually by adapting our kitty config + enableHypr = true; + enableDiscord = true; + enableSpicetify = true; + enableFuzzel = true; #what's that? + enablleBtop = false; # default true + enableQt = true; + }; + toggles = { + communication = { + discord = { + enable = false; # default true + match = [ + { + class = "discord"; + } + ]; + whatsapp = { + enable = true; + match = [ + { + class = "whatsapp"; + } + ]; + }; + }; + }; + music = { + spotify = { + enable = false; # default true + match = [ + { + class = "Spotify"; + } + { + initialTitle = "Spotify"; + } + { + initialTitle = "Spotify Free"; + } + ]; + command = ["spicetify" "watch" "-s"]; + move = true; + }; + feishin = { enable = true; match = [ { - class = "whatsapp"; + class = "feishin"; } ]; + move = true; }; }; - }; - music = { - spotify = { - enable = false; # default true - match = [ - { - class = "Spotify"; - } - { - initialTitle = "Spotify"; - } - { - initialTitle = "Spotify Free"; - } - ]; - command = [ "spicetify" "watch" "-s" ]; - move = true; + sysmon = { + btop = { + enable = true; + match = [ + { + class = "btop"; + title = "btop"; + workspace = { + name = "special:sysmon"; + }; + } + ]; + command = ["foot" "-a" "btop" "-T" "btop" "fish" "-C" "exec btop"]; # maybe switch to btm and kitty? + }; }; - feishin = { - enable = true; - match = [ - { - class = "feishin"; - } - ]; - move = true; - }; - }; - sysmon = { - btop = { - enable = true; - match = [ - { - class = "btop"; - title = "btop"; - workspace = { - name = "special:sysmon"; - }; - } - ]; - command = [ "foot" "-a" "btop" "-T" "btop" "fish" "-C" "exec btop" ]; # maybe switch to btm and kitty? - }; - }; - todo = { - todoist = { - enable = false; # default true - match = [ - { - class = "Todoist"; - } - ]; - command = [ "todoist" ]; - move = true; + todo = { + todoist = { + enable = false; # default true + match = [ + { + class = "Todoist"; + } + ]; + command = ["todoist"]; + move = true; + }; }; }; }; }; }; -}; } diff --git a/modules/home-manager/eza.nix b/modules/home-manager/eza.nix index 4272ebd..4899959 100644 --- a/modules/home-manager/eza.nix +++ b/modules/home-manager/eza.nix @@ -1,14 +1,19 @@ -{ config, pkgs, ... }: # ls replacement +{ + config, + pkgs, + ... +}: +# ls replacement # see ./zsh.nix for the alias (usefull to se default flags) - { programs.eza = { enable = true; enableZshIntegration = true; - theme = { # from https://github.com/eza-community/eza-themes/blob/main/themes/gruvbox-dark.yml + theme = { + # from https://github.com/eza-community/eza-themes/blob/main/themes/gruvbox-dark.yml colourful = true; - - filekinds= { + + filekinds = { normal = {foreground = "#ebdbb2";}; directory = {foreground = "#83a598";}; symlink = {foreground = "#8ec07c";}; @@ -16,98 +21,98 @@ block_device = {foreground = "#fb4934";}; char_device = {foreground = "#fb4934";}; socket = {foreground = "#665c54";}; - special= {foreground= "#d3869b";}; - executable= {foreground= "#b8bb26";}; - mount_point= {foreground= "#fe8019";}; + special = {foreground = "#d3869b";}; + executable = {foreground = "#b8bb26";}; + mount_point = {foreground = "#fe8019";}; }; perms = { - user_read= {foreground= "#ebdbb2";}; - user_write= {foreground= "#fabd2f";}; - user_execute_file= {foreground= "#b8bb26";}; - user_execute_other= {foreground= "#b8bb26";}; - group_read= {foreground= "#ebdbb2";}; - group_write= {foreground= "#fabd2f";}; - group_execute= {foreground= "#b8bb26";}; - other_read= {foreground= "#bdae93";}; - other_write= {foreground= "#fabd2f";}; - other_execute= {foreground= "#b8bb26";}; - special_user_file= {foreground= "#d3869b";}; - special_other= {foreground= "#928374";}; - attribute= {foreground= "#bdae93";}; + user_read = {foreground = "#ebdbb2";}; + user_write = {foreground = "#fabd2f";}; + user_execute_file = {foreground = "#b8bb26";}; + user_execute_other = {foreground = "#b8bb26";}; + group_read = {foreground = "#ebdbb2";}; + group_write = {foreground = "#fabd2f";}; + group_execute = {foreground = "#b8bb26";}; + other_read = {foreground = "#bdae93";}; + other_write = {foreground = "#fabd2f";}; + other_execute = {foreground = "#b8bb26";}; + special_user_file = {foreground = "#d3869b";}; + special_other = {foreground = "#928374";}; + attribute = {foreground = "#bdae93";}; }; - size= { - major= {foreground= "#bdae93";}; - minor= {foreground= "#8ec07c";}; - number_byte= {foreground= "#ebdbb2";}; - number_kilo= {foreground= "#ebdbb2";}; - number_mega= {foreground= "#83a598";}; - number_giga= {foreground= "#d3869b";}; - number_huge= {foreground= "#d3869b";}; - unit_byte= {foreground= "#bdae93";}; - unit_kilo= {foreground= "#83a598";}; - unit_mega= {foreground= "#d3869b";}; - unit_giga= {foreground= "#d3869b";}; - unit_huge= {foreground= "#fe8019";}; + size = { + major = {foreground = "#bdae93";}; + minor = {foreground = "#8ec07c";}; + number_byte = {foreground = "#ebdbb2";}; + number_kilo = {foreground = "#ebdbb2";}; + number_mega = {foreground = "#83a598";}; + number_giga = {foreground = "#d3869b";}; + number_huge = {foreground = "#d3869b";}; + unit_byte = {foreground = "#bdae93";}; + unit_kilo = {foreground = "#83a598";}; + unit_mega = {foreground = "#d3869b";}; + unit_giga = {foreground = "#d3869b";}; + unit_huge = {foreground = "#fe8019";}; }; - users= { - user_you= {foreground= "#ebdbb2";}; - user_root= {foreground= "#fb4934";}; - user_other= {foreground= "#d3869b";}; - group_yours= {foreground= "#ebdbb2";}; - group_other= {foreground= "#928374";}; - group_root= {foreground= "#fb4934";}; + users = { + user_you = {foreground = "#ebdbb2";}; + user_root = {foreground = "#fb4934";}; + user_other = {foreground = "#d3869b";}; + group_yours = {foreground = "#ebdbb2";}; + group_other = {foreground = "#928374";}; + group_root = {foreground = "#fb4934";}; }; - links= { - normal= {foreground= "#8ec07c";}; - multi_link_file= {foreground= "#fe8019";}; + links = { + normal = {foreground = "#8ec07c";}; + multi_link_file = {foreground = "#fe8019";}; }; - git= { - new= {foreground= "#b8bb26";}; - modified= {foreground= "#fabd2f";}; - deleted= {foreground= "#fb4934";}; - renamed= {foreground= "#8ec07c";}; - typechange= {foreground= "#d3869b";}; - ignored= {foreground= "#928374";}; - conflicted= {foreground= "#cc241d";}; + git = { + new = {foreground = "#b8bb26";}; + modified = {foreground = "#fabd2f";}; + deleted = {foreground = "#fb4934";}; + renamed = {foreground = "#8ec07c";}; + typechange = {foreground = "#d3869b";}; + ignored = {foreground = "#928374";}; + conflicted = {foreground = "#cc241d";}; }; - git_repo= { - branch_main= {foreground= "#ebdbb2";}; - branch_other= {foreground= "#d3869b";}; - git_clean= {foreground= "#b8bb26";}; - git_dirty= {foreground= "#fb4934";}; + git_repo = { + branch_main = {foreground = "#ebdbb2";}; + branch_other = {foreground = "#d3869b";}; + git_clean = {foreground = "#b8bb26";}; + git_dirty = {foreground = "#fb4934";}; }; - security_context= { - colon= {foreground= "#928374";}; - user= {foreground= "#ebdbb2";}; - role= {foreground= "#d3869b";}; - typ= {foreground= "#665c54";}; - range= {foreground= "#d3869b";}; + security_context = { + colon = {foreground = "#928374";}; + user = {foreground = "#ebdbb2";}; + role = {foreground = "#d3869b";}; + typ = {foreground = "#665c54";}; + range = {foreground = "#d3869b";}; + }; + file_type = { + image = {foreground = "#fabd2f";}; + video = {foreground = "#fb4934";}; + music = {foreground = "#b8bb26";}; + lossless = {foreground = "#8ec07c";}; + crypto = {foreground = "#928374";}; + document = {foreground = "#ebdbb2";}; + compressed = {foreground = "#d3869b";}; + temp = {foreground = "#cc241d";}; + compiled = {foreground = "#83a598";}; + build = {foreground = "#928374";}; + source = {foreground = "#83a598";}; + punctuation = {foreground = "#928374";}; + date = {foreground = "#fabd2f";}; + inode = {foreground = "#bdae93";}; + blocks = {foreground = "#a89984";}; + header = {foreground = "#ebdbb2";}; + octal = {foreground = "#8ec07c";}; + flags = {foreground = "#d3869b";}; + + symlink_path = {foreground = "#8ec07c";}; + control_char = {foreground = "#83a598";}; + broken_symlink = {foreground = "#fb4934";}; + broken_path_overlay = {foreground = "#928374";}; }; - file_type= { - image= {foreground= "#fabd2f";}; - video= {foreground= "#fb4934";}; - music= {foreground= "#b8bb26";}; - lossless= {foreground= "#8ec07c";}; - crypto= {foreground= "#928374";}; - document= {foreground= "#ebdbb2";}; - compressed= {foreground= "#d3869b";}; - temp= {foreground= "#cc241d";}; - compiled= {foreground= "#83a598";}; - build= {foreground= "#928374";}; - source= {foreground= "#83a598";}; - punctuation= {foreground= "#928374";}; - date= {foreground= "#fabd2f";}; - inode= {foreground= "#bdae93";}; - blocks= {foreground= "#a89984";}; - header= {foreground= "#ebdbb2";}; - octal= {foreground= "#8ec07c";}; - flags= {foreground= "#d3869b";}; - - symlink_path= {foreground= "#8ec07c";}; - control_char= {foreground= "#83a598";}; - broken_symlink= {foreground= "#fb4934";}; - broken_path_overlay= {foreground= "#928374";}; - }; }; }; } diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index 2c2592b..0c5a733 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -149,15 +149,17 @@ in { "Ctrl+Alt, 7, exec, caelestia shell gameMode toggle" # reloads the autostart programs # pos 3 1 # we passed to caelestia-shell and stoped using that - /*"Ctrl+$mod, 4, exec, sleep 1 && kitty -o font_size=16 -e sh -c 'custom-weather'" + /* + "Ctrl+$mod, 4, exec, sleep 1 && kitty -o font_size=16 -e sh -c 'custom-weather'" "Ctrl+$mod, 4, exec, sleep 1 && kitty -o font_size=11 -e sh -c 'custom-cowsay'" "Ctrl+$mod, 4, exec, kitty -e 'custom-launch'" "Ctrl+$mod, 4, exec, sleep 1 && kitty -o font_size=5 -e btm --theme gruvbox --disable-click --disable_advanced_kill --enable_cache_memory -g -R -T " "Ctrl+$mod, 4, exec, sleep 1 && kitty -o font_size=1 -e sh -c 'cmatrix -br'" - #"Ctrl+Alt, 1, exec, swaync-client -t" # pos 4 1 notification center - "Ctrl+Alt, 1, exec, qs ipc call notifications toggle" */ + #"Ctrl+Alt, 1, exec, swaync-client -t" # pos 4 1 notification center + "Ctrl+Alt, 1, exec, qs ipc call notifications toggle" + */ "Ctrl+Alt, 1, exec, caelestia shell drawers toggle sidebar" - "Ctrl+$mod, 4, exec, caelestia shell notifs toggleDnd" + "Ctrl+$mod, 4, exec, caelestia shell notifs toggleDnd" "Ctrl+$mod, 3, exec, pavucontrol" # pos 1 2 audiocontrol "Ctrl+$mod, 5, exec, gnome-characters" # pos 2 2 special chars "Ctrl+Alt, 8, exec, hyprpicker | tee >(wl-copy) | cliphist store" # pos 3 2 colorpicker @@ -220,7 +222,8 @@ in { #"custom-obsidianbackup" # backups the obsidian notes to kdrive and to a timed hidden dir (~/.Notes.backup/) #"QS-notifycache" # builds the cache that will be used for the notification history "sleep 2 & caelestia-shell" #works better if it sleeps a bit before - /* We stopped using that ######################### maybe we should desactivate those scripts + /* + We stopped using that ######################### maybe we should desactivate those scripts # login autostart ####################### "[workspace 1 silent] sleep 1 && kitty -o font_size=16 -e sh -c 'custom-weather'" @@ -229,7 +232,8 @@ in { "[workspace 1 silent] sleep 1 && kitty -o font_size=5 -e btm --theme gruvbox --disable-click --disable_advanced_kill --enable_cache_memory -g -R -T " "[workspace 1 silent] sleep 1 && kitty -o font_size=1 -e sh -c 'cmatrix -br'" ###################### - ######################*/ + ###################### + */ ]; # gestures (also keybindings) diff --git a/modules/home-manager/kitty.nix b/modules/home-manager/kitty.nix index 1dfa5c6..8d80550 100644 --- a/modules/home-manager/kitty.nix +++ b/modules/home-manager/kitty.nix @@ -10,62 +10,63 @@ ## new config (matches with caelestia ## old condfig extraConfig = '' - font_size 14 -bold_font auto -italic_font auto -bold_italic_font auto + font_size 14 + bold_font auto + italic_font auto + bold_italic_font auto -window_padding_width 25 + window_padding_width 25 -# --- Core --- -foreground #ece0d9 -background #18120e + # --- Core --- + foreground #ece0d9 + background #18120e -selection_foreground #18120e -selection_background #ece0d9 + selection_foreground #18120e + selection_background #ece0d9 -cursor #ffb878 -cursor_text_color #18120e + cursor #ffb878 + cursor_text_color #18120e -# --- Tabs --- -active_tab_foreground #18120e -active_tab_background #5c412a -inactive_tab_foreground #d6c3b5 -inactive_tab_background #241e1a + # --- Tabs --- + active_tab_foreground #18120e + active_tab_background #5c412a + inactive_tab_foreground #d6c3b5 + inactive_tab_background #241e1a -# --- Black / Gray --- -color0 #353433 -color8 #b29f91 + # --- Black / Gray --- + color0 #353433 + color8 #b29f91 -# --- Red --- -color1 #e17300 -color9 #ff8a20 + # --- Red --- + color1 #e17300 + color9 #ff8a20 -# --- Green --- -color2 #ffc071 -color10 #ffd6a8 + # --- Green --- + color2 #ffc071 + color10 #ffd6a8 -# --- Yellow --- -color3 #ffe0c6 -color11 #fff2e8 + # --- Yellow --- + color3 #ffe0c6 + color11 #fff2e8 -# --- Blue --- -color4 #b9ab66 -color12 #d7be91 + # --- Blue --- + color4 #b9ab66 + color12 #d7be91 -# --- Magenta --- -color5 #ed9562 -color13 #fcad7e + # --- Magenta --- + color5 #ed9562 + color13 #fcad7e -# --- Cyan --- -color6 #f4c16d -color14 #ffd497 + # --- Cyan --- + color6 #f4c16d + color14 #ffd497 -# --- White --- -color7 #ebd4c1 -color15 #FFFFFF - ''; - /*extraConfig = '' + # --- White --- + color7 #ebd4c1 + color15 #FFFFFF + ''; + /* + extraConfig = '' # font nerd-fonts._0xproto # this key dont work and causes errors font_size 14 bold_font auto @@ -118,6 +119,7 @@ color15 #FFFFFF # white color7 #FFF0CC color15 #F0DBAA - '';*/ + ''; + */ }; } diff --git a/modules/home-manager/neovim.nix b/modules/home-manager/neovim.nix index 70df624..871c50c 100644 --- a/modules/home-manager/neovim.nix +++ b/modules/home-manager/neovim.nix @@ -4,12 +4,11 @@ pkgs-unstable, ... }: { - programs.neovim = { enable = true; vimAlias = false; viAlias = true; - package = pkgs-unstable.neovim-unwrapped; # required for unwrapped version + package = pkgs-unstable.neovim-unwrapped; # required for unwrapped version plugins = [ pkgs-unstable.vimPlugins.vivify-vim pkgs-unstable.vimPlugins.vimtex @@ -70,369 +69,369 @@ ]; extraLuaConfig = '' - local vim = vim + local vim = vim - -- ========================= - -- LEADER & KEY DISABLE - -- ========================= - vim.g.mapleader = ' ' - vim.g.maplocalleader = ' ' - vim.keymap.set({'n', 'v'}, '', '', { desc = 'Leader key, disable default behavior' }) - vim.keymap.set('n', 'q', '', { desc = 'Disable macro recording' }) -vim.keymap.set('n', 'gg', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gG', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g0', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g^', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g$', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gj', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gk', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g~', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gu', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gU', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g=', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gq', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g@', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g?', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gC', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gD', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gx', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'gr', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g[', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g]', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g;', '', { desc = 'Disable g motion' }) -vim.keymap.set('n', 'g,', '', { desc = 'Disable g motion' }) - -- ========================= - -- GENERAL OPTIONS - -- ========================= - vim.g.have_nerd_font = true - vim.opt.relativenumber = false - vim.opt.number = true - vim.opt.mouse = 'a' - vim.opt.showmode = false - vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' - end) - vim.opt.breakindent = true - vim.opt.undofile = true - vim.opt.ignorecase = true - vim.opt.smartcase = true - vim.opt.signcolumn = 'yes' - vim.opt.updatetime = 250 - vim.opt.timeoutlen = 300 - vim.opt.splitright = true - vim.opt.splitbelow = true - vim.opt.list = true - vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - vim.opt.expandtab = true - vim.opt.smartindent = true - vim.opt.tabstop = 4 - vim.opt.shiftwidth = 4 - vim.opt.inccommand = 'split' - vim.opt.cursorline = true - vim.opt.scrolloff = 10 - - - -- ========================= - -- BASIC KEYMAPS - -- ========================= - vim.keymap.set('n', '', 'nohlsearch') - vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - - -- Disable arrow keys in normal mode - vim.keymap.set('n', '', 'echo "Use h to move!!"') - vim.keymap.set('n', '', 'echo "Use l to move!!"') - vim.keymap.set('n', '', 'echo "Use k to move!!"') - vim.keymap.set('n', '', 'echo "Use j to move!!"') - - -- Window navigation - vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - - -- Cheatsheet - vim.keymap.set("n","§", "Cheatsheet") - require("cheatsheet").setup({ - bundled_cheatsheets = { enabled = { "default" } }, - bundled_plugin_cheatsheets = { disabled = { "gitsigns.nvim" } } - }) - - -- Highlight yanked text - vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight on yank', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() vim.highlight.on_yank() end, - }) - - -- ======================== - -- terminal - -- ======================= - require("runner-nvim").setup({ - position = 'right', -- position of the terminal window when using the shell_handler - -- can be: top, left, right, bottom - -- will be overwritten when using the telescope mapping to open horizontally or vertically - - width = 80, -- width of window when position is left or right - height = 10, -- height of window when position is top or bottom - - handlers = { - lua = function(bufnr) - vim.print('Running lua file in buffer ' .. bufnr) - -- Run the file here - end - } - }) - - vim.keymap.set("n", "", function() require("runner-nvim").run() end) - -- ========================= - -- SCROLLBAR - -- ========================= - require("scrollbar").setup() - - -- ========================= - -- UFO FOLDING - -- ========================= - vim.o.foldcolumn = '1' - vim.o.foldlevel = 99 - vim.o.foldlevelstart = 99 - vim.o.foldenable = true - vim.keymap.set('n', '1', "foldopen") - vim.keymap.set('n', '2', "foldclose") - require('ufo').setup({ - provider_selector = function() return {'treesitter', 'indent'} end - }) - - -- ========================= - -- treesitter - -- ======================== - require('nvim-treesitter').setup({ - ensure_installed = {}, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { enable = true }, -}) - -- ========================= - -- NVIM-TREE - -- ========================= - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - require("nvim-tree").setup({ - sort = { sorter = "case_sensitive" }, - view = { width = 30 }, - renderer = { group_empty = true }, - filters = { dotfiles = true }, - }) - - -- ========================= - -- CMP CONFIGURATION - -- ========================= - local cmp = require'cmp' - cmp.setup({ - snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' } }, { { name = 'buffer' } }), - }) - - cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) - cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }), matching = { disallow_symbol_nonprefix_matching = false } }) - --- ========================= --- LSP CONFIGURATION --- ========================= -local capabilities = require('cmp_nvim_lsp').default_capabilities() - - -- Diagnostics - vim.keymap.set("n", "e1", function() vim.diagnostic.jump({ prev=true, count = 1 }) end, { desc = "Previous diagnostic" }) - vim.keymap.set("n", "e2", function() vim.diagnostic.jump({ prev=false, count = 1 }) end, { desc = "Next diagnostic" }) - vim.keymap.set("n", "e3", vim.diagnostic.open_float, { desc = "Show diagnostic" }) - vim.keymap.set("n", "e4", vim.diagnostic.setloclist, { desc = "Diagnostic list" }) - - vim.diagnostic.config({ - update_in_insert = false, -- i don't get any new error when in insert - }) - require("better-diagnostic-virtual-text").setup({ - ui = { - wrap_line_after = false, -- wrap the line after this length to avoid the virtual text is too long - left_kept_space = 3, --- the number of spaces kept on the left side of the virtual text, make sure it enough to custom for each line - right_kept_space = 3, --- the number of spaces kept on the right side of the virtual text, make sure it enough to custom for each line - arrow = "  ", - up_arrow = "  ", - down_arrow = "  ", - above = false, -- the virtual text will be displayed above the line - }, - priority = 2003, -- the priority of virtual text - inline = false, - - }) + -- ========================= + -- LEADER & KEY DISABLE + -- ========================= + vim.g.mapleader = ' ' + vim.g.maplocalleader = ' ' + vim.keymap.set({'n', 'v'}, '', '', { desc = 'Leader key, disable default behavior' }) + vim.keymap.set('n', 'q', '', { desc = 'Disable macro recording' }) + vim.keymap.set('n', 'gg', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gG', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g0', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g^', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g$', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gj', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gk', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g~', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gu', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gU', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g=', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gq', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g@', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g?', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gC', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gD', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gx', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'gr', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g[', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g]', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g;', '', { desc = 'Disable g motion' }) + vim.keymap.set('n', 'g,', '', { desc = 'Disable g motion' }) + -- ========================= + -- GENERAL OPTIONS + -- ========================= + vim.g.have_nerd_font = true + vim.opt.relativenumber = false + vim.opt.number = true + vim.opt.mouse = 'a' + vim.opt.showmode = false + vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' + end) + vim.opt.breakindent = true + vim.opt.undofile = true + vim.opt.ignorecase = true + vim.opt.smartcase = true + vim.opt.signcolumn = 'yes' + vim.opt.updatetime = 250 + vim.opt.timeoutlen = 300 + vim.opt.splitright = true + vim.opt.splitbelow = true + vim.opt.list = true + vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + vim.opt.expandtab = true + vim.opt.smartindent = true + vim.opt.tabstop = 4 + vim.opt.shiftwidth = 4 + vim.opt.inccommand = 'split' + vim.opt.cursorline = true + vim.opt.scrolloff = 10 - -- LSP functionality - vim.keymap.set("n", "g1", vim.lsp.buf.hover, { desc = "Hover documentation" }) - vim.keymap.set("n", "g2", vim.lsp.buf.definition, { desc = "Go to definition" }) - vim.keymap.set("n", "g3", vim.lsp.buf.declaration, { desc = "Go to declaration" }) - vim.keymap.set("n", "g4", vim.lsp.buf.implementation, { desc = "Go to implementation" }) - vim.keymap.set("n", "g5", vim.lsp.buf.references, { desc = "Show references" }) + -- ========================= + -- BASIC KEYMAPS + -- ========================= + vim.keymap.set('n', '', 'nohlsearch') + vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- LSP server setup -vim.lsp.config("lua_ls", { cmd = { "lua-language-server" }, filetypes = { "lua" }, root_dir = vim.fs.dirname, on_attach = on_attach }) - vim.lsp.config("clangd", { - cmd = { "clangd" }, - filetypes = { "c","cpp","objc","objcpp" }, - on_attach = on_attach , - init_options = { - clangdFileStatus = true, - usePlaceholders = true, - completeUnimported = true, - semanticHighlighting = true} - }) - vim.lsp.config("nixd", { - cmd = { "nixd" }, - filetyypes = { "nix" }, - on_attach = on_attach, - }) -vim.lsp.config("pylsp", { - cmd = { "pylsp" }, - filetypes = { "python" }, - on_attach = on_attach, - settings = { - pylsp = { - plugins = { - pylsp_mypy = { enabled = true }, - jedi_completion = { fuzzy = true } + -- Disable arrow keys in normal mode + vim.keymap.set('n', '', 'echo "Use h to move!!"') + vim.keymap.set('n', '', 'echo "Use l to move!!"') + vim.keymap.set('n', '', 'echo "Use k to move!!"') + vim.keymap.set('n', '', 'echo "Use j to move!!"') + + -- Window navigation + vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + + -- Cheatsheet + vim.keymap.set("n","§", "Cheatsheet") + require("cheatsheet").setup({ + bundled_cheatsheets = { enabled = { "default" } }, + bundled_plugin_cheatsheets = { disabled = { "gitsigns.nvim" } } + }) + + -- Highlight yanked text + vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight on yank', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() vim.highlight.on_yank() end, + }) + + -- ======================== + -- terminal + -- ======================= + require("runner-nvim").setup({ + position = 'right', -- position of the terminal window when using the shell_handler + -- can be: top, left, right, bottom + -- will be overwritten when using the telescope mapping to open horizontally or vertically + + width = 80, -- width of window when position is left or right + height = 10, -- height of window when position is top or bottom + + handlers = { + lua = function(bufnr) + vim.print('Running lua file in buffer ' .. bufnr) + -- Run the file here + end } - } - } -}) -vim.lsp.config("texlab", { cmd = { "texlab" }, filetypes = { "tex" }, on_attach = on_attach }) + }) -vim.lsp.enable({ "lua_ls", "clangd", "pylsp", "texlab", "nixd"}) - -- ========================= - -- DASHBOARD - -- ========================= - require('dashboard').setup { - theme = 'hyper', - config = { - header = { - " ... ... . ", - " .=*8888n..\"%888: @88> ", - " X ?8888f '8888 u. ... .. %8P .. . : ", - " 88x. '8888X 8888> .u ...ue888b :~\"\"888h.:^\"888: . .888: x888 x888. ", - "'8888k 8888X '\"*8h. ud8888. 888R Y888r 8X `8888X 8888> .@88u ~`8888~'888X`?888f` ", - " \"8888 X888X .xH8 :888'8888. 888R I888> X888n. 8888X ?888> '\"888E` X888 888X '888> ", - " `8\" X888!:888X d888 '88%\" 888R I888> '88888 8888X ?**h. 888E X888 888X '888> ", - " =~` X888 X888X 8888.+\" 888R I888> `*88 8888~ x88x. 888E X888 888X '888> ", - " :h. X8*` !888X 8888L u8888cJ888 ..<\" 88*` 88888X 888E X888 888X '888> ", - " X888xX\" '8888..: '8888c. .+ \"*888*P\" ..XC. `*8888k 888& \"*88%\"\"*88\" '888!` ", - ":~`888f '*888*\" \"88888% 'Y\" :888888H. `%88> R888\" `~ \" `\"` ", - " \"\" `\"` \"YP' < `\"888888: X\" \"\" ", - " %888888x.-` ", - " \"\"**\"\" ", - "", - "" - }, - shortcut = { { desc = " Open File Tree", group = "", key = 't', action = 'NvimTreeOpen' } }, - packages = { enable = false }, - project = { enable = true, limit = 8, icon = ' New file', action = 'Telescope find_files cwd=' }, - mru = { limit = 10, icon = ' History' }, - footer = {}, - } - } + vim.keymap.set("n", "", function() require("runner-nvim").run() end) + -- ========================= + -- SCROLLBAR + -- ========================= + require("scrollbar").setup() - -- jumps cursor when was last cursor last time - require("nvim-lastplace").setup({ - -- Filetypes to ignore - ignore_filetypes = { - "gitcommit", "gitrebase", "svn", "hgcommit", "xxd", "COMMIT_EDITMSG" + -- ========================= + -- UFO FOLDING + -- ========================= + vim.o.foldcolumn = '1' + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + vim.keymap.set('n', '1', "foldopen") + vim.keymap.set('n', '2', "foldclose") + require('ufo').setup({ + provider_selector = function() return {'treesitter', 'indent'} end + }) + + -- ========================= + -- treesitter + -- ======================== + require('nvim-treesitter').setup({ + ensure_installed = {}, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, }, - - -- Buffer types to ignore - ignore_buftypes = { - "quickfix", "nofile", "help", "terminal" - }, - - -- Center cursor after jumping - center_on_jump = true, - - -- Only jump if target line is not visible - jump_only_if_not_visible = false, - - -- Minimum lines required to enable jumping - min_lines = 10, - - -- Maximum line to jump to (0 = no limit) - max_line = 0, - - -- Open folds after jumping - open_folds = true, - - -- Enable debug messages - debug = false, + indent = { enable = true }, }) - -- ====================== - -- gruvbox - -- ====================== + -- ========================= + -- NVIM-TREE + -- ========================= + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + require("nvim-tree").setup({ + sort = { sorter = "case_sensitive" }, + view = { width = 30 }, + renderer = { group_empty = true }, + filters = { dotfiles = true }, + }) - require("gruvbox").setup({ - terminal_colors = false, -- add neovim terminal colors - undercurl = true, - underline = true, - bold = true, - italic = { - strings = false, - emphasis = true, - comments = true, - operators = false, - folds = true, - }, - strikethrough = true, - invert_selection = false, - invert_signs = false, - invert_tabline = false, - inverse = true, -- invert background for search, diffs, statuslines and errors - contrast = "hard", -- can be "hard", "soft" or empty string - palette_overrides = { -- for overrides see https://github.com/ellisonleao/gruvbox.nvim/blob/main/lua/gruvbox.lua - dark0_hard = "#241F17" - }, - overrides = { - String = {fg = "#FFB878", italic = false}, - FoldColumn = {fg = faded_orange, bg = dark0_hard} - }, - dim_inactive = false, - transparent_mode = false, + -- ========================= + -- CMP CONFIGURATION + -- ========================= + local cmp = require'cmp' + cmp.setup({ + snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' } }, { { name = 'buffer' } }), + }) + + cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) + cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }), matching = { disallow_symbol_nonprefix_matching = false } }) + + -- ========================= + -- LSP CONFIGURATION + -- ========================= + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + -- Diagnostics + vim.keymap.set("n", "e1", function() vim.diagnostic.jump({ prev=true, count = 1 }) end, { desc = "Previous diagnostic" }) + vim.keymap.set("n", "e2", function() vim.diagnostic.jump({ prev=false, count = 1 }) end, { desc = "Next diagnostic" }) + vim.keymap.set("n", "e3", vim.diagnostic.open_float, { desc = "Show diagnostic" }) + vim.keymap.set("n", "e4", vim.diagnostic.setloclist, { desc = "Diagnostic list" }) + + vim.diagnostic.config({ + update_in_insert = false, -- i don't get any new error when in insert + }) + require("better-diagnostic-virtual-text").setup({ + ui = { + wrap_line_after = false, -- wrap the line after this length to avoid the virtual text is too long + left_kept_space = 3, --- the number of spaces kept on the left side of the virtual text, make sure it enough to custom for each line + right_kept_space = 3, --- the number of spaces kept on the right side of the virtual text, make sure it enough to custom for each line + arrow = "  ", + up_arrow = "  ", + down_arrow = "  ", + above = false, -- the virtual text will be displayed above the line + }, + priority = 2003, -- the priority of virtual text + inline = false, + + }) + + + -- LSP functionality + vim.keymap.set("n", "g1", vim.lsp.buf.hover, { desc = "Hover documentation" }) + vim.keymap.set("n", "g2", vim.lsp.buf.definition, { desc = "Go to definition" }) + vim.keymap.set("n", "g3", vim.lsp.buf.declaration, { desc = "Go to declaration" }) + vim.keymap.set("n", "g4", vim.lsp.buf.implementation, { desc = "Go to implementation" }) + vim.keymap.set("n", "g5", vim.lsp.buf.references, { desc = "Show references" }) + + -- LSP server setup + vim.lsp.config("lua_ls", { cmd = { "lua-language-server" }, filetypes = { "lua" }, root_dir = vim.fs.dirname, on_attach = on_attach }) + vim.lsp.config("clangd", { + cmd = { "clangd" }, + filetypes = { "c","cpp","objc","objcpp" }, + on_attach = on_attach , + init_options = { + clangdFileStatus = true, + usePlaceholders = true, + completeUnimported = true, + semanticHighlighting = true} + }) + vim.lsp.config("nixd", { + cmd = { "nixd" }, + filetyypes = { "nix" }, + on_attach = on_attach, + }) + vim.lsp.config("pylsp", { + cmd = { "pylsp" }, + filetypes = { "python" }, + on_attach = on_attach, + settings = { + pylsp = { + plugins = { + pylsp_mypy = { enabled = true }, + jedi_completion = { fuzzy = true } + } + } + } }) - vim.opt.termguicolors = false - vim.o.background = "dark" - vim.cmd("colorscheme gruvbox") - -- ========================= - -- LUALINE - -- ========================= - require('lualine').setup { options = { theme = "gruvbox_dark" } } + vim.lsp.config("texlab", { cmd = { "texlab" }, filetypes = { "tex" }, on_attach = on_attach }) + + vim.lsp.enable({ "lua_ls", "clangd", "pylsp", "texlab", "nixd"}) + -- ========================= + -- DASHBOARD + -- ========================= + require('dashboard').setup { + theme = 'hyper', + config = { + header = { + " ... ... . ", + " .=*8888n..\"%888: @88> ", + " X ?8888f '8888 u. ... .. %8P .. . : ", + " 88x. '8888X 8888> .u ...ue888b :~\"\"888h.:^\"888: . .888: x888 x888. ", + "'8888k 8888X '\"*8h. ud8888. 888R Y888r 8X `8888X 8888> .@88u ~`8888~'888X`?888f` ", + " \"8888 X888X .xH8 :888'8888. 888R I888> X888n. 8888X ?888> '\"888E` X888 888X '888> ", + " `8\" X888!:888X d888 '88%\" 888R I888> '88888 8888X ?**h. 888E X888 888X '888> ", + " =~` X888 X888X 8888.+\" 888R I888> `*88 8888~ x88x. 888E X888 888X '888> ", + " :h. X8*` !888X 8888L u8888cJ888 ..<\" 88*` 88888X 888E X888 888X '888> ", + " X888xX\" '8888..: '8888c. .+ \"*888*P\" ..XC. `*8888k 888& \"*88%\"\"*88\" '888!` ", + ":~`888f '*888*\" \"88888% 'Y\" :888888H. `%88> R888\" `~ \" `\"` ", + " \"\" `\"` \"YP' < `\"888888: X\" \"\" ", + " %888888x.-` ", + " \"\"**\"\" ", + "", + "" + }, + shortcut = { { desc = " Open File Tree", group = "", key = 't', action = 'NvimTreeOpen' } }, + packages = { enable = false }, + project = { enable = true, limit = 8, icon = ' New file', action = 'Telescope find_files cwd=' }, + mru = { limit = 10, icon = ' History' }, + footer = {}, + } + } + + -- jumps cursor when was last cursor last time + require("nvim-lastplace").setup({ + -- Filetypes to ignore + ignore_filetypes = { + "gitcommit", "gitrebase", "svn", "hgcommit", "xxd", "COMMIT_EDITMSG" + }, + + -- Buffer types to ignore + ignore_buftypes = { + "quickfix", "nofile", "help", "terminal" + }, + + -- Center cursor after jumping + center_on_jump = true, + + -- Only jump if target line is not visible + jump_only_if_not_visible = false, + + -- Minimum lines required to enable jumping + min_lines = 10, + + -- Maximum line to jump to (0 = no limit) + max_line = 0, + + -- Open folds after jumping + open_folds = true, + + -- Enable debug messages + debug = false, + }) + -- ====================== + -- gruvbox + -- ====================== + + require("gruvbox").setup({ + terminal_colors = false, -- add neovim terminal colors + undercurl = true, + underline = true, + bold = true, + italic = { + strings = false, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "hard", -- can be "hard", "soft" or empty string + palette_overrides = { -- for overrides see https://github.com/ellisonleao/gruvbox.nvim/blob/main/lua/gruvbox.lua + dark0_hard = "#241F17" + }, + overrides = { + String = {fg = "#FFB878", italic = false}, + FoldColumn = {fg = faded_orange, bg = dark0_hard} + }, + dim_inactive = false, + transparent_mode = false, + }) + vim.opt.termguicolors = false + vim.o.background = "dark" + vim.cmd("colorscheme gruvbox") + -- ========================= + -- LUALINE + -- ========================= + require('lualine').setup { options = { theme = "gruvbox_dark" } } - --==================0 - -- Some utils - --================== - vim.keymap.set('n', 'r1', 'Fugit2', { desc = 'Open git helper' }) + --==================0 + -- Some utils + --================== + vim.keymap.set('n', 'r1', 'Fugit2', { desc = 'Open git helper' }) - -- ========================= - -- telescope - -- ======================= - local builtin = require('telescope.builtin') - vim.keymap.set('n', 'f1', builtin.find_files, { desc = 'Telescope find files' }) - vim.keymap.set('n', 'f2', builtin.live_grep, { desc = 'Telescope live grep' }) - vim.keymap.set('n', 'f3', builtin.buffers, { desc = 'Telescope buffers' }) - vim.keymap.set('n', 'f4', builtin.help_tags, { desc = 'Telescope help tags' }) + -- ========================= + -- telescope + -- ======================= + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'f1', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'f2', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'f3', builtin.buffers, { desc = 'Telescope buffers' }) + vim.keymap.set('n', 'f4', builtin.help_tags, { desc = 'Telescope help tags' }) - -- Disable relative numbers even if plugins override - vim.api.nvim_create_autocmd("VimEnter", { callback = function() vim.opt.colorcolumn = ""; vim.opt.relativenumber = false end }) + -- Disable relative numbers even if plugins override + vim.api.nvim_create_autocmd("VimEnter", { callback = function() vim.opt.colorcolumn = ""; vim.opt.relativenumber = false end }) ''; }; } diff --git a/modules/home-manager/obsidian.nix b/modules/home-manager/obsidian.nix index defe0ed..685e624 100644 --- a/modules/home-manager/obsidian.nix +++ b/modules/home-manager/obsidian.nix @@ -1,12 +1,20 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { programs.obsidian = { enable = true; vaults = { - miscellanious = { enable = true; target = "/Documents/Notes/miscellanious"; }; - work = { enable = true; target = "/Documents/Notes/work"; }; + miscellanious = { + enable = true; + target = "/Documents/Notes/miscellanious"; + }; + work = { + enable = true; + target = "/Documents/Notes/work"; + }; }; defaultSettings = { @@ -14,8 +22,8 @@ extraFiles = { ".obsidian/themes/gruvbox/manifest.json" = ../../other/obsidian-theme/manifest.json; - ".obsidian/themes/gruvbox/obsidian.css" = ../../other/obsidian-theme/obsidian.css; - ".obsidian/themes/gruvbox/theme.css" = ../../other/obsidian-theme/theme.css; + ".obsidian/themes/gruvbox/obsidian.css" = ../../other/obsidian-theme/obsidian.css; + ".obsidian/themes/gruvbox/theme.css" = ../../other/obsidian-theme/theme.css; }; }; }; diff --git a/modules/home-manager/quickshell.nix b/modules/home-manager/quickshell.nix index dc6789d..bee6d55 100644 --- a/modules/home-manager/quickshell.nix +++ b/modules/home-manager/quickshell.nix @@ -1,17 +1,16 @@ # pulled from https://codeberg.org/zacoons/rivendell-hyprdots - { config, pkgs, ... }: { - qt.enable =true; + qt.enable = true; programs.quickshell = { systemd.enable = true; enable = true; }; -home.file.".config/quickshell" = { - source = ../../other/quickshell; - recursive = true; -}; + home.file.".config/quickshell" = { + source = ../../other/quickshell; + recursive = true; + }; } diff --git a/modules/qt/qtbatticon.nix b/modules/qt/qtbatticon.nix index 46fe766..9caf25a 100644 --- a/modules/qt/qtbatticon.nix +++ b/modules/qt/qtbatticon.nix @@ -3,13 +3,13 @@ # https://chatgpt.com/c/69da11b3-ba24-8331-b7b0-a58a72e69d42 # at your risk and perils # click on the icon to get a notification with state, percentage and wattage -{ lib -, stdenv -, qt6 -, pkg-config -, pkgs +{ + lib, + stdenv, + qt6, + pkg-config, + pkgs, }: - stdenv.mkDerivation { pname = "qtbatticon"; version = "1.0"; @@ -17,137 +17,137 @@ stdenv.mkDerivation { src = pkgs.writeTextFile { name = "qtbatticon.cpp"; text = '' -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include + #include + #include + #include -QString readFile(const QString &path) { - QFile f(path); - if (!f.open(QIODevice::ReadOnly)) return ""; - QTextStream in(&f); - return in.readAll().trimmed(); -} + QString readFile(const QString &path) { + QFile f(path); + if (!f.open(QIODevice::ReadOnly)) return ""; + QTextStream in(&f); + return in.readAll().trimmed(); + } -int readInt(const QString &path) { - return readFile(path).toInt(); -} + int readInt(const QString &path) { + return readFile(path).toInt(); + } -double readDouble(const QString &path) { - QFile f(path); - if (!f.open(QIODevice::ReadOnly)) return 0; - QTextStream in(&f); - return in.readAll().trimmed().toDouble(); -} + double readDouble(const QString &path) { + QFile f(path); + if (!f.open(QIODevice::ReadOnly)) return 0; + QTextStream in(&f); + return in.readAll().trimmed().toDouble(); + } -int toStep(int capacity) { - return (capacity / 10) * 10; -} + int toStep(int capacity) { + return (capacity / 10) * 10; + } -QString pad3(int n) { - return QString("%1").arg(n, 3, 10, QChar('0')); -} + QString pad3(int n) { + return QString("%1").arg(n, 3, 10, QChar('0')); + } -double getPowerW(const QString &batPath) { - double current_uA = readDouble(batPath + "/current_now"); - double voltage_uV = readDouble(batPath + "/voltage_now"); + double getPowerW(const QString &batPath) { + double current_uA = readDouble(batPath + "/current_now"); + double voltage_uV = readDouble(batPath + "/voltage_now"); - if (current_uA > 0 && voltage_uV > 0) { - return (current_uA * voltage_uV) / 1e12; - } - return -1; -} + if (current_uA > 0 && voltage_uV > 0) { + return (current_uA * voltage_uV) / 1e12; + } + return -1; + } -QIcon batteryIcon(int capacity, bool charging) { - int step = toStep(capacity); - QString num = pad3(step); + QIcon batteryIcon(int capacity, bool charging) { + int step = toStep(capacity); + QString num = pad3(step); - QString base = "/run/current-system/sw/share/icons/Papirus/24x24/panel/"; + QString base = "/run/current-system/sw/share/icons/Papirus/24x24/panel/"; - QString file; - if (charging) { - file = base + "battery-" + num + "-charging.svg"; - } else { - file = base + "battery-" + num + ".svg"; - } + QString file; + if (charging) { + file = base + "battery-" + num + "-charging.svg"; + } else { + file = base + "battery-" + num + ".svg"; + } - QIcon icon(file); + QIcon icon(file); - if (icon.isNull()) { - qDebug() << "FAILED icon:" << file; - icon = QIcon(base + "battery-100.svg"); - } + if (icon.isNull()) { + qDebug() << "FAILED icon:" << file; + icon = QIcon(base + "battery-100.svg"); + } - return icon; -} + return icon; + } -void sendNotification(const QString &title, const QString &body) { - QString cmd = "notify-send \"" + title + "\" \"" + body + "\""; - system(cmd.toUtf8().constData()); -} + void sendNotification(const QString &title, const QString &body) { + QString cmd = "notify-send \"" + title + "\" \"" + body + "\""; + system(cmd.toUtf8().constData()); + } -int main(int argc, char *argv[]) { - QApplication app(argc, argv); + int main(int argc, char *argv[]) { + QApplication app(argc, argv); - QString batPath = "/sys/class/power_supply/BAT1"; - QSystemTrayIcon tray; + QString batPath = "/sys/class/power_supply/BAT1"; + QSystemTrayIcon tray; - auto updateIcon = [&]() { - int capacity = readInt(batPath + "/capacity"); - QString status = readFile(batPath + "/status"); - bool charging = status.contains("Charging"); + auto updateIcon = [&]() { + int capacity = readInt(batPath + "/capacity"); + QString status = readFile(batPath + "/status"); + bool charging = status.contains("Charging"); - tray.setIcon(batteryIcon(capacity, charging)); - }; + tray.setIcon(batteryIcon(capacity, charging)); + }; - auto notify = [&]() { - int capacity = readInt(batPath + "/capacity"); - QString status = readFile(batPath + "/status"); + auto notify = [&]() { + int capacity = readInt(batPath + "/capacity"); + QString status = readFile(batPath + "/status"); - bool charging = status.contains("Charging"); - bool discharging = status.contains("Discharging"); + bool charging = status.contains("Charging"); + bool discharging = status.contains("Discharging"); - double power = getPowerW(batPath); + double power = getPowerW(batPath); - QString state; - if (charging) state = "Charging"; - else if (discharging) state = "Discharging"; - else state = status; + QString state; + if (charging) state = "Charging"; + else if (discharging) state = "Discharging"; + else state = status; - QString powerStr = (power > 0.01) - ? QString::number(power, 'f', 2) + " W" - : "N/A"; + QString powerStr = (power > 0.01) + ? QString::number(power, 'f', 2) + " W" + : "N/A"; - QString msg = - QString("%1\n%2%\n%3") - .arg(state) - .arg(capacity) - .arg(powerStr); + QString msg = + QString("%1\n%2%\n%3") + .arg(state) + .arg(capacity) + .arg(powerStr); - sendNotification("Battery status", msg); - }; + sendNotification("Battery status", msg); + }; - QObject::connect(&tray, &QSystemTrayIcon::activated, - [&](QSystemTrayIcon::ActivationReason r) { - if (r == QSystemTrayIcon::Trigger) { - notify(); - } - }); + QObject::connect(&tray, &QSystemTrayIcon::activated, + [&](QSystemTrayIcon::ActivationReason r) { + if (r == QSystemTrayIcon::Trigger) { + notify(); + } + }); - updateIcon(); - tray.setVisible(true); + updateIcon(); + tray.setVisible(true); - QTimer timer; - QObject::connect(&timer, &QTimer::timeout, updateIcon); - timer.start(5000); + QTimer timer; + QObject::connect(&timer, &QTimer::timeout, updateIcon); + timer.start(5000); - return app.exec(); -} + return app.exec(); + } ''; }; diff --git a/modules/scripts/QSnotifycache.nix b/modules/scripts/QSnotifycache.nix index b82eaa5..a7fbbbf 100644 --- a/modules/scripts/QSnotifycache.nix +++ b/modules/scripts/QSnotifycache.nix @@ -1,17 +1,14 @@ # creates and maintains cache file for the notification history -{ - writeShellApplication, - ... -}: +{writeShellApplication, ...}: writeShellApplication { name = "QS-notifycache"; runtimeInputs = [ ]; text = '' -CACHE="$HOME/.cache/notify_history" -# Create or erase existing cache -mkdir -p "$(dirname "$CACHE")" -: > "$CACHE" # truncate file -echo "Notification history initialized at $(date)" >> "$CACHE" + CACHE="$HOME/.cache/notify_history" + # Create or erase existing cache + mkdir -p "$(dirname "$CACHE")" + : > "$CACHE" # truncate file + echo "Notification history initialized at $(date)" >> "$CACHE" ''; } diff --git a/modules/scripts/QSnotifyhistory.nix b/modules/scripts/QSnotifyhistory.nix index 3f5210b..601dd4d 100644 --- a/modules/scripts/QSnotifyhistory.nix +++ b/modules/scripts/QSnotifyhistory.nix @@ -1,7 +1,4 @@ -{ - writeShellApplication, - ... -}: +{writeShellApplication, ...}: writeShellApplication { name = "QS-notifyhistory"; runtimeInputs = [ diff --git a/modules/scripts/QSsysinfo.nix b/modules/scripts/QSsysinfo.nix index a3b90d5..16f1b25 100644 --- a/modules/scripts/QSsysinfo.nix +++ b/modules/scripts/QSsysinfo.nix @@ -1,80 +1,80 @@ { -writeShellApplication, -ripgrep, -gawkInteractive, -iproute2, -coreutils, -procps, -upower, -... + writeShellApplication, + ripgrep, + gawkInteractive, + iproute2, + coreutils, + procps, + upower, + ... }: writeShellApplication { -name = "QS-sysinfo"; -runtimeInputs = [ - ripgrep - gawkInteractive - iproute2 - coreutils - procps - upower -]; -text = '' -# Pad CPU, MEM, DISK to 2 chars (right-aligned) - -cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat) -cpu=$(printf "%2s" "$cpu") + name = "QS-sysinfo"; + runtimeInputs = [ + ripgrep + gawkInteractive + iproute2 + coreutils + procps + upower + ]; + text = '' + # Pad CPU, MEM, DISK to 2 chars (right-aligned) -sum=0 -count=0 + cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat) + cpu=$(printf "%2s" "$cpu") -for f in /sys/class/hwmon/hwmon*/temp*_input; do - if [ -r "$f" ]; then - val=$(cat "$f" 2>/dev/null) || continue - sum=$((sum + val)) - count=$((count + 1)) - fi -done + sum=0 + count=0 -temp=$(( sum / count / 1000 )) + for f in /sys/class/hwmon/hwmon*/temp*_input; do + if [ -r "$f" ]; then + val=$(cat "$f" 2>/dev/null) || continue + sum=$((sum + val)) + count=$((count + 1)) + fi + done -sum=0 -count=0 + temp=$(( sum / count / 1000 )) -for f in /sys/class/hwmon/hwmon*/fan*_input; do - if [ -r "$f" ]; then - val=$(cat "$f" 2>/dev/null) || continue - sum=$((sum + val)) - count=$((count + 1)) - fi -done -fan=$(( sum / count )) -fan=$(printf "%4s" "$fan") + sum=0 + count=0 -mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}') -mem=$(printf "%2s" "$mem") + for f in /sys/class/hwmon/hwmon*/fan*_input; do + if [ -r "$f" ]; then + val=$(cat "$f" 2>/dev/null) || continue + sum=$((sum + val)) + count=$((count + 1)) + fi + done + fan=$(( sum / count )) + fan=$(printf "%4s" "$fan") -disk=$(df / | awk 'NR==2 {gsub("%",""); print $5}') -disk=$(printf "%2s" "$disk") + mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}') + mem=$(printf "%2s" "$mem") -# Pad POWER to 5 chars (XX.XX) -power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}') -power=$(printf "%5s" "$power") + disk=$(df / | awk 'NR==2 {gsub("%",""); print $5}') + disk=$(printf "%2s" "$disk") -# network calculations -iface=$(ip route get 1.1.1.1 | awk '{print $5; exit}') + # Pad POWER to 5 chars (XX.XX) + power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}') + power=$(printf "%5s" "$power") -rx1=$(cat "/sys/class/net/$iface/statistics/rx_bytes") -tx1=$(cat "/sys/class/net/$iface/statistics/tx_bytes") + # network calculations + iface=$(ip route get 1.1.1.1 | awk '{print $5; exit}') -sleep 1 + rx1=$(cat "/sys/class/net/$iface/statistics/rx_bytes") + tx1=$(cat "/sys/class/net/$iface/statistics/tx_bytes") -rx2=$(cat "/sys/class/net/$iface/statistics/rx_bytes") -tx2=$(cat "/sys/class/net/$iface/statistics/tx_bytes") + sleep 1 -down_speed=$(( (rx2 - rx1) / 1024 )) -up_speed=$(( (tx2 - tx1) / 1024 )) + rx2=$(cat "/sys/class/net/$iface/statistics/rx_bytes") + tx2=$(cat "/sys/class/net/$iface/statistics/tx_bytes") -# Output JSON -echo "{\"cpu\":\"$cpu\",\"temp\":\"$temp\",\"fan\":\"$fan\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\",\"down\":\"$down_speed\",\"up\":\"$up_speed\"}" -''; + down_speed=$(( (rx2 - rx1) / 1024 )) + up_speed=$(( (tx2 - tx1) / 1024 )) + + # Output JSON + echo "{\"cpu\":\"$cpu\",\"temp\":\"$temp\",\"fan\":\"$fan\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\",\"down\":\"$down_speed\",\"up\":\"$up_speed\"}" + ''; } diff --git a/modules/scripts/batterywarning.nix b/modules/scripts/batterywarning.nix index ecab48e..b83d651 100644 --- a/modules/scripts/batterywarning.nix +++ b/modules/scripts/batterywarning.nix @@ -1,48 +1,48 @@ # taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License { -writeShellApplication, -mplayer, -brightnessctl, -... + writeShellApplication, + mplayer, + brightnessctl, + ... }: let -NotifySound = ../../assets/battery_notify.mp3; + NotifySound = ../../assets/battery_notify.mp3; in -writeShellApplication { - name = "custom-batterywarning"; - runtimeInputs = [ - mplayer - brightnessctl - ]; - text = '' + writeShellApplication { + name = "custom-batterywarning"; + runtimeInputs = [ + mplayer + brightnessctl + ]; + text = '' - # Delay for startup - sleep 5 + # Delay for startup + sleep 5 - playsound() { - mplayer ${NotifySound} - } + playsound() { + mplayer ${NotifySound} + } - while true; do - Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" - Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)" + while true; do + Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" + Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)" - if [ "$Battery_Status" == "Discharging" ]; then - if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then - notify-send -e -u critical "Battery Low!" "Power running out: ''${Battery_Capacity}%" - playsound - sleep 180 + if [ "$Battery_Status" == "Discharging" ]; then + if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then + notify-send -e -u critical "Battery Low!" "Power running out: ''${Battery_Capacity}%" + playsound + sleep 180 - elif [ "$Battery_Capacity" -lt 10 ]; then - notify-send -e -u critical "Battery Low!" "Save your works before immediate shutdown." - playsound - sleep 180 - fi - else - sleep 120 - fi - done - ''; -} + elif [ "$Battery_Capacity" -lt 10 ]; then + notify-send -e -u critical "Battery Low!" "Save your works before immediate shutdown." + playsound + sleep 180 + fi + else + sleep 120 + fi + done + ''; + } diff --git a/modules/scripts/obsidianbackup.nix b/modules/scripts/obsidianbackup.nix index 1d500a3..2dfc2ca 100644 --- a/modules/scripts/obsidianbackup.nix +++ b/modules/scripts/obsidianbackup.nix @@ -5,7 +5,6 @@ rsync, ... }: - writeShellApplication { name = "custom-obsidianbackup"; runtimeInputs = [ diff --git a/modules/scripts/obsidianprofiles.nix b/modules/scripts/obsidianprofiles.nix index 44fc7fb..ad98363 100644 --- a/modules/scripts/obsidianprofiles.nix +++ b/modules/scripts/obsidianprofiles.nix @@ -5,7 +5,6 @@ ripgrep, ... }: - writeShellApplication { name = "custom-obsidianvaults"; runtimeInputs = [ @@ -42,5 +41,5 @@ writeShellApplication { # Exit the kitty terminal after selection pkill -f "kitty.*Select Obsidian vault" exit - ''; + ''; } diff --git a/modules/scripts/trimmer.nix b/modules/scripts/trimmer.nix index 8baa855..16a8583 100644 --- a/modules/scripts/trimmer.nix +++ b/modules/scripts/trimmer.nix @@ -10,257 +10,257 @@ writeShellApplication { nix ]; text = '' -set -euo pipefail + set -euo pipefail -## Defaults -keepGensDef=30; keepDaysDef=7 -keepGens=$keepGensDef; keepDays=$keepDaysDef + ## Defaults + keepGensDef=30; keepDaysDef=7 + keepGens=$keepGensDef; keepDays=$keepDaysDef -## Usage -usage () { - printf "Usage:\n\t ./trim-generations.sh \n\n -(defaults are: Keep-Gens=%d Keep-Days=%d Profile=user)\n\n" "$keepGensDef" "$keepDaysDef" - printf "If you enter any parameters, you must enter all three, or none to use defaults.\n" - printf "Example:\n\t trim-generations.sh 15 10 home-manager\n" - printf " this will work on the home-manager profile and keep all generations from the\n" - printf "last 10 days, and keep at least 15 generations no matter how old.\n" - printf "\nProfiles available are:\tuser, home-manager, channels, system (root)\n" - printf "\n-h or --help prints this help text." -} + ## Usage + usage () { + printf "Usage:\n\t ./trim-generations.sh \n\n + (defaults are: Keep-Gens=%d Keep-Days=%d Profile=user)\n\n" "$keepGensDef" "$keepDaysDef" + printf "If you enter any parameters, you must enter all three, or none to use defaults.\n" + printf "Example:\n\t trim-generations.sh 15 10 home-manager\n" + printf " this will work on the home-manager profile and keep all generations from the\n" + printf "last 10 days, and keep at least 15 generations no matter how old.\n" + printf "\nProfiles available are:\tuser, home-manager, channels, system (root)\n" + printf "\n-h or --help prints this help text." + } -if [ $# -eq 1 ]; then # if help requested - if [ "$1" = "-h" ]; then - usage - exit 1; - fi - if [ "$1" = "--help" ]; then - usage - exit 2; - fi - printf "Dont recognise your option exiting..\n\n" - usage - exit 3; - - elif [ $# -eq 0 ]; then # print the defaults - printf "The current defaults are:\n Keep-Gens=%d Keep-Days=%d \n\n" "$keepGensDef" "$keepDaysDef" - read -r -p "Keep these defaults? (y/n):" answer - - case "$answer" in - [yY1] ) - printf "Using defaults..\n" - ;; - [nN0] ) printf "ok, doing nothing, exiting..\n" - exit 6; - ;; - * ) printf "%b" "Doing nothing, exiting.." - exit 7; - ;; - esac -fi - -## Handle parameters (and change if root) -if [[ $EUID -ne 0 ]]; then # if not root - profile=$(readlink /home/"$USER"/.nix-profile) -else - if [ -d /nix/var/nix/profiles/system ]; then # maybe this or the other - profile="/nix/var/nix/profiles/system" - elif [ -d /nix/var/nix/profiles/default ]; then - profile="/nix/var/nix/profiles/default" - else - echo "Cant find profile for root. Exiting" - exit 8 - fi -fi -if (( $# < 1 )); then - printf "Keeping default: %d generations OR %d days, whichever is more\n" "$keepGensDef" "$keepDaysDef" -elif [[ $# -le 2 ]]; then - printf "\nError: Not enough arguments.\n\n" >&2 - usage - exit 1 -elif (( $# > 4)); then - printf "\nError: Too many arguments.\n\n" >&2 - usage - exit 2 -else - if [ "$1" -lt 1 ]; then - printf "using Gen numbers less than 1 not recommended. Setting to min=1\n" - read -r -p "is that ok? (y/n): " answer - printf "%s" "$answer" - case "$answer" in - [yY1] ) - printf "ok, continuing..\n" - ;; - [nN0] ) - printf "ok, doing nothing, exiting..\n" - exit 6; - ;; - * ) - printf "%b" "Doing nothing, exiting.." - exit 7; - ;; - esac - fi - if [ "$2" -lt 0 ]; then - printf "using negative days number not recommended. Setting to min=0\n" - read -r -p "is that ok? (y/n): " answer - - case "$answer" in - [yY1] ) - printf "ok, continuing..\n" - ;; - [nN0] ) - printf "ok, doing nothing, exiting..\n" - exit 6; - ;; - * ) - printf "%b" "Doing nothing, exiting.." - exit 7; - ;; - esac - fi - keepGens=$1; keepDays=$2; - (( keepGens < 1 )) && keepGens=1 - (( keepDays < 0 )) && keepDays=0 - if [[ $EUID -ne 0 ]]; then - if [[ $3 == "user" ]] || [[ $3 == "default" ]]; then - profile=$(readlink /home/"$USER"/.nix-profile) - elif [[ $3 == "home-manager" ]]; then - # home-manager defaults to $XDG_STATE_HOME; otherwise, use - # `home-manager generations` and `nix-store --query --roots - # /nix/store/...` to figure out what reference is keeping the old - # generations alive. - profile="''${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/home-manager" - elif [[ $3 == "channels" ]]; then - profile="/nix/var/nix/profiles/per-user/$USER/channels" - else - printf "\nError: Do not understand your third argument. Should be one of: (user / home-manager/ channels)\n\n" - usage - exit 3 + if [ $# -eq 1 ]; then # if help requested + if [ "$1" = "-h" ]; then + usage + exit 1; fi + if [ "$1" = "--help" ]; then + usage + exit 2; + fi + printf "Dont recognise your option exiting..\n\n" + usage + exit 3; + + elif [ $# -eq 0 ]; then # print the defaults + printf "The current defaults are:\n Keep-Gens=%d Keep-Days=%d \n\n" "$keepGensDef" "$keepDaysDef" + read -r -p "Keep these defaults? (y/n):" answer + + case "$answer" in + [yY1] ) + printf "Using defaults..\n" + ;; + [nN0] ) printf "ok, doing nothing, exiting..\n" + exit 6; + ;; + * ) printf "%b" "Doing nothing, exiting.." + exit 7; + ;; + esac + fi + + ## Handle parameters (and change if root) + if [[ $EUID -ne 0 ]]; then # if not root + profile=$(readlink /home/"$USER"/.nix-profile) else - if [[ $3 == "system" ]]; then + if [ -d /nix/var/nix/profiles/system ]; then # maybe this or the other profile="/nix/var/nix/profiles/system" - elif [[ $3 == "user" ]] || [[ $3 == "default" ]]; then + elif [ -d /nix/var/nix/profiles/default ]; then profile="/nix/var/nix/profiles/default" else - printf "\nError: Do not understand your third argument. Should be one of: (user / system)\n\n" - usage - exit 3 + echo "Cant find profile for root. Exiting" + exit 8 fi fi - printf "OK! \t Keep Gens = %s \t Keep Days = %s \n\n" "$keepGens" "$keepDays" + if (( $# < 1 )); then + printf "Keeping default: %d generations OR %d days, whichever is more\n" "$keepGensDef" "$keepDaysDef" + elif [[ $# -le 2 ]]; then + printf "\nError: Not enough arguments.\n\n" >&2 + usage + exit 1 + elif (( $# > 4)); then + printf "\nError: Too many arguments.\n\n" >&2 + usage + exit 2 + else + if [ "$1" -lt 1 ]; then + printf "using Gen numbers less than 1 not recommended. Setting to min=1\n" + read -r -p "is that ok? (y/n): " answer + printf "%s" "$answer" + case "$answer" in + [yY1] ) + printf "ok, continuing..\n" + ;; + [nN0] ) + printf "ok, doing nothing, exiting..\n" + exit 6; + ;; + * ) + printf "%b" "Doing nothing, exiting.." + exit 7; + ;; + esac + fi + if [ "$2" -lt 0 ]; then + printf "using negative days number not recommended. Setting to min=0\n" + read -r -p "is that ok? (y/n): " answer + + case "$answer" in + [yY1] ) + printf "ok, continuing..\n" + ;; + [nN0] ) + printf "ok, doing nothing, exiting..\n" + exit 6; + ;; + * ) + printf "%b" "Doing nothing, exiting.." + exit 7; + ;; + esac + fi + keepGens=$1; keepDays=$2; + (( keepGens < 1 )) && keepGens=1 + (( keepDays < 0 )) && keepDays=0 + if [[ $EUID -ne 0 ]]; then + if [[ $3 == "user" ]] || [[ $3 == "default" ]]; then + profile=$(readlink /home/"$USER"/.nix-profile) + elif [[ $3 == "home-manager" ]]; then + # home-manager defaults to $XDG_STATE_HOME; otherwise, use + # `home-manager generations` and `nix-store --query --roots + # /nix/store/...` to figure out what reference is keeping the old + # generations alive. + profile="''${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/home-manager" + elif [[ $3 == "channels" ]]; then + profile="/nix/var/nix/profiles/per-user/$USER/channels" + else + printf "\nError: Do not understand your third argument. Should be one of: (user / home-manager/ channels)\n\n" + usage + exit 3 + fi + else + if [[ $3 == "system" ]]; then + profile="/nix/var/nix/profiles/system" + elif [[ $3 == "user" ]] || [[ $3 == "default" ]]; then + profile="/nix/var/nix/profiles/default" + else + printf "\nError: Do not understand your third argument. Should be one of: (user / system)\n\n" + usage + exit 3 + fi + fi + printf "OK! \t Keep Gens = %s \t Keep Days = %s \n\n" "$keepGens" "$keepDays" -fi - -printf "Operating on profile: %s \t \n\n" "$profile" - -## Runs at the end, to decide whether to delete profiles that match chosen parameters. -choose () { - local default="$1" - local prompt="$2" - local answer - - read -r -p "$prompt" answer - [ -z "$answer" ] && answer="$default" - - case "$answer" in - [yY1] ) #printf "answered yes!\n" - nix-env --delete-generations -p "$profile" "''${!gens[@]}" - exit 0 - ;; - [nN0] ) printf "Ok doing nothing exiting..\n" - exit 6; - ;; - * ) printf "%b" "Unexpected answer '$answer'!" >&2 - exit 7; - ;; - esac -} # end of function choose - -# printf "profile = %s \n\n" "$profile" -## Query nix-env for generations list -#IFS=$'\n' nixGens=( $(nix-env --list-generations -p "$profile" | sed 's:^\s*::; s:\s*$::' | tr '\t' ' ' | tr -s ' ') ) -# gave errors replaced by: -mapfile -t nixGens < <( - nix-env --list-generations -p "$profile" | - sed 's:^\s*::; s:\s*$::' | - tr '\t' ' ' | - tr -s ' ' -) -timeNow=$(date +%s) - -## Get info on oldest generation -IFS=' ' read -r -a oldestGenArr <<< "''${nixGens[0]}" -oldestGen=''${oldestGenArr[0]} -oldestDate=''${oldestGenArr[1]} -printf "%-30s %s\n" "oldest generation:" "$oldestGen" -#oldestDate=''${nixGens[0]:3:19} -printf "%-30s %s\n" "oldest generation created:" "$oldestDate" -oldestTime=$(date -d "$oldestDate" +%s) -oldestElapsedSecs=$((timeNow-oldestTime)) -oldestElapsedMins=$((oldestElapsedSecs/60)) -oldestElapsedHours=$((oldestElapsedMins/60)) -oldestElapsedDays=$((oldestElapsedHours/24)) -printf "%-30s %s\n" "minutes before now:" "$oldestElapsedMins" -printf "%-30s %s\n" "hours before now:" "$oldestElapsedHours" -printf "%-30s %s\n\n" "days before now:" "$oldestElapsedDays" - -## Get info on current generation -for i in "''${nixGens[@]}"; do - IFS=' ' read -r -a iGenArr <<< "$i" - genNumber=''${iGenArr[0]} - genDate=''${iGenArr[1]} - if [[ "$i" =~ current ]]; then - currentGen=$genNumber - printf "%-30s %s\n" "current generation:" "$currentGen" - currentDate=$genDate - printf "%-30s %s\n" "current generation created:" "$currentDate" - currentTime=$(date -d "$currentDate" +%s) - currentElapsedSecs=$((timeNow-currentTime)) - currentElapsedMins=$((currentElapsedSecs/60)) - currentElapsedHours=$((currentElapsedMins/60)) - currentElapsedDays=$((currentElapsedHours/24)) - printf "%-30s %s\n" "minutes before now:" "$currentElapsedMins" - printf "%-30s %s\n" "hours before now:" "$currentElapsedHours" - printf "%-30s %s\n\n" "days before now:" "$currentElapsedDays" fi -done -## Compare oldest and current generations -timeBetweenOldestAndCurrent=$((currentTime-oldestTime)) -elapsedDays=$((timeBetweenOldestAndCurrent/60/60/24)) -generationsDiff=$((currentGen-oldestGen)) + printf "Operating on profile: %s \t \n\n" "$profile" -## Figure out what we should do, based on generations and options -if [[ elapsedDays -le keepDays ]]; then - printf "All generations are no more than %s days older than current generation. \nOldest gen days difference from current gen: %s \n\n\tNothing to do!\n" "$keepDays" "$elapsedDays" - exit 4; -elif [[ generationsDiff -lt keepGens ]]; then - printf "Oldest generation (%d) is only %d generations behind current (%d). \n\n\t Nothing to do!\n" "$oldestGen" "$generationsDiff" "$currentGen" - exit 5; -else - printf "\tSomething to do...\n" - declare -a gens + ## Runs at the end, to decide whether to delete profiles that match chosen parameters. + choose () { + local default="$1" + local prompt="$2" + local answer + + read -r -p "$prompt" answer + [ -z "$answer" ] && answer="$default" + + case "$answer" in + [yY1] ) #printf "answered yes!\n" + nix-env --delete-generations -p "$profile" "''${!gens[@]}" + exit 0 + ;; + [nN0] ) printf "Ok doing nothing exiting..\n" + exit 6; + ;; + * ) printf "%b" "Unexpected answer '$answer'!" >&2 + exit 7; + ;; + esac + } # end of function choose + + # printf "profile = %s \n\n" "$profile" + ## Query nix-env for generations list + #IFS=$'\n' nixGens=( $(nix-env --list-generations -p "$profile" | sed 's:^\s*::; s:\s*$::' | tr '\t' ' ' | tr -s ' ') ) + # gave errors replaced by: + mapfile -t nixGens < <( + nix-env --list-generations -p "$profile" | + sed 's:^\s*::; s:\s*$::' | + tr '\t' ' ' | + tr -s ' ' + ) + timeNow=$(date +%s) + + ## Get info on oldest generation + IFS=' ' read -r -a oldestGenArr <<< "''${nixGens[0]}" + oldestGen=''${oldestGenArr[0]} + oldestDate=''${oldestGenArr[1]} + printf "%-30s %s\n" "oldest generation:" "$oldestGen" + #oldestDate=''${nixGens[0]:3:19} + printf "%-30s %s\n" "oldest generation created:" "$oldestDate" + oldestTime=$(date -d "$oldestDate" +%s) + oldestElapsedSecs=$((timeNow-oldestTime)) + oldestElapsedMins=$((oldestElapsedSecs/60)) + oldestElapsedHours=$((oldestElapsedMins/60)) + oldestElapsedDays=$((oldestElapsedHours/24)) + printf "%-30s %s\n" "minutes before now:" "$oldestElapsedMins" + printf "%-30s %s\n" "hours before now:" "$oldestElapsedHours" + printf "%-30s %s\n\n" "days before now:" "$oldestElapsedDays" + + ## Get info on current generation for i in "''${nixGens[@]}"; do IFS=' ' read -r -a iGenArr <<< "$i" genNumber=''${iGenArr[0]} - genDiff=$((currentGen-genNumber)) genDate=''${iGenArr[1]} - genTime=$(date -d "$genDate" +%s) - elapsedSecs=$((timeNow-genTime)) - genDaysOld=$((elapsedSecs/60/60/24)) - if [[ genDaysOld -gt keepDays ]] && [[ genDiff -ge keepGens ]]; then - gens["$genNumber"]="$genDate, $genDaysOld day(s) old" + if [[ "$i" =~ current ]]; then + currentGen=$genNumber + printf "%-30s %s\n" "current generation:" "$currentGen" + currentDate=$genDate + printf "%-30s %s\n" "current generation created:" "$currentDate" + currentTime=$(date -d "$currentDate" +%s) + currentElapsedSecs=$((timeNow-currentTime)) + currentElapsedMins=$((currentElapsedSecs/60)) + currentElapsedHours=$((currentElapsedMins/60)) + currentElapsedDays=$((currentElapsedHours/24)) + printf "%-30s %s\n" "minutes before now:" "$currentElapsedMins" + printf "%-30s %s\n" "hours before now:" "$currentElapsedHours" + printf "%-30s %s\n\n" "days before now:" "$currentElapsedDays" fi done - printf "\nFound the following generation(s) to delete:\n" - for K in "''${!gens[@]}"; do - printf "generation %d \t ''${gens[$K]}\n" "$K" - done - printf "\n" - choose "y" "Do you want to delete these? [Y/n]: " -fi + + ## Compare oldest and current generations + timeBetweenOldestAndCurrent=$((currentTime-oldestTime)) + elapsedDays=$((timeBetweenOldestAndCurrent/60/60/24)) + generationsDiff=$((currentGen-oldestGen)) + + ## Figure out what we should do, based on generations and options + if [[ elapsedDays -le keepDays ]]; then + printf "All generations are no more than %s days older than current generation. \nOldest gen days difference from current gen: %s \n\n\tNothing to do!\n" "$keepDays" "$elapsedDays" + exit 4; + elif [[ generationsDiff -lt keepGens ]]; then + printf "Oldest generation (%d) is only %d generations behind current (%d). \n\n\t Nothing to do!\n" "$oldestGen" "$generationsDiff" "$currentGen" + exit 5; + else + printf "\tSomething to do...\n" + declare -a gens + for i in "''${nixGens[@]}"; do + IFS=' ' read -r -a iGenArr <<< "$i" + genNumber=''${iGenArr[0]} + genDiff=$((currentGen-genNumber)) + genDate=''${iGenArr[1]} + genTime=$(date -d "$genDate" +%s) + elapsedSecs=$((timeNow-genTime)) + genDaysOld=$((elapsedSecs/60/60/24)) + if [[ genDaysOld -gt keepDays ]] && [[ genDiff -ge keepGens ]]; then + gens["$genNumber"]="$genDate, $genDaysOld day(s) old" + fi + done + printf "\nFound the following generation(s) to delete:\n" + for K in "''${!gens[@]}"; do + printf "generation %d \t ''${gens[$K]}\n" "$K" + done + printf "\n" + choose "y" "Do you want to delete these? [Y/n]: " + fi ''; }