From e698f4de803ecdd91c4d7939314e6c176dd50dff Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Tue, 5 Mar 2024 11:30:24 +0530 Subject: [PATCH] [feat] nixfmt and change the hyprpaper module --- config/nix/common/firefox.nix | 26 ++++++++-------- config/nix/common/home.nix | 41 ++++++++++++------------- config/nix/common/nvim/default.nix | 17 +++-------- config/nix/common/tmux.nix | 9 +++--- config/nix/common/wezterm.nix | 2 +- config/nix/darwin/configuration.nix | 2 +- config/nix/flake.nix | 47 +++++++++++------------------ config/nix/linux/hyprland.nix | 20 +++--------- config/nix/modules/hyprpaper.nix | 35 ++++++++++----------- config/nix/nixos/configuration.nix | 35 +++++++++------------ config/nix/nixos/ryu.nix | 34 ++++++++++----------- config/nix/themes/catppuccin.nix | 8 ++--- config/nix/utils/wallhaven.nix | 22 ++++++++++++++ 13 files changed, 139 insertions(+), 159 deletions(-) create mode 100644 config/nix/utils/wallhaven.nix diff --git a/config/nix/common/firefox.nix b/config/nix/common/firefox.nix index 43c6888a..7f030826 100644 --- a/config/nix/common/firefox.nix +++ b/config/nix/common/firefox.nix @@ -2,20 +2,18 @@ programs.firefox = { enable = device.isLinux; profiles.default = { - userChrome = - let - csshacks = pkgs.fetchFromGitHub { - owner = "MrOtherGuy"; - repo = "firefox-csshacks"; - rev = "master"; - sha256 = "sha256-XJ+MTEADzOsCIh0I8EAxbtIpDHfMJsN68sKBy7/1l60="; - }; - in - '' - @import url(${csshacks}/chrome/toolbars_below_content.css); - @import url(${csshacks}/chrome/scrollable_menupopups.css); - @import url(${csshacks}/chrome/linux_gtk_window_control_patch.css); - ''; + userChrome = let + csshacks = pkgs.fetchFromGitHub { + owner = "MrOtherGuy"; + repo = "firefox-csshacks"; + rev = "master"; + sha256 = "sha256-XJ+MTEADzOsCIh0I8EAxbtIpDHfMJsN68sKBy7/1l60="; + }; + in '' + @import url(${csshacks}/chrome/toolbars_below_content.css); + @import url(${csshacks}/chrome/scrollable_menupopups.css); + @import url(${csshacks}/chrome/linux_gtk_window_control_patch.css); + ''; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ privacy-badger bitwarden diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index cb082a04..acb78137 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -3,14 +3,13 @@ let # https://mipmip.github.io/home-manager-option-search/ start-tmux = (import ../scripts/start-tmux.nix) pkgs; lazy = false; -in -{ +in { imports = [ # Include the results of the hardware scan. ./tmux.nix ./wezterm.nix ] ++ (if device.isLinux then [ ../linux ] else [ ]) - ++ (if !lazy then [ ./nvim ] else [ ]); + ++ (if !lazy then [ ./nvim ] else [ ]); home.packages = with pkgs; [ @@ -158,14 +157,13 @@ in enable = true; enableFishIntegration = true; enableNushellIntegration = true; - settings = - let flavour = "mocha"; # Replace with your preferred palette - in { - # Other config here - format = "$all"; # Remove this line to disable the default prompt format - palette = "catppuccin_${flavour}"; - } // builtins.fromTOML (builtins.readFile (pkgs.catppuccinThemes.starship - + /palettes/${flavour}.toml)); + settings = let flavour = "mocha"; # Replace with your preferred palette + in { + # Other config here + format = "$all"; # Remove this line to disable the default prompt format + palette = "catppuccin_${flavour}"; + } // builtins.fromTOML (builtins.readFile + (pkgs.catppuccinThemes.starship + /palettes/${flavour}.toml)); }; eza = { enable = true; @@ -193,11 +191,10 @@ in enable = true; config = { theme = "catppuccin"; }; themes = { - catppuccin = - { - src = "${pkgs.catppuccinThemes.bat}/themes"; - file = "Catppuccin Mocha.tmTheme"; - }; + catppuccin = { + src = "${pkgs.catppuccinThemes.bat}/themes"; + file = "Catppuccin Mocha.tmTheme"; + }; }; }; @@ -206,7 +203,8 @@ in settings = { email = "uttarayan21@gmail.com"; base_url = "https://pass.uttarayan.me"; - pinenttry = if device.isMac then pkgs.pinentry_mac else pkgs.pinentry-qt; + pinenttry = + if device.isMac then pkgs.pinentry_mac else pkgs.pinentry-qt; }; }; # Let Home Manager install and manage itself. @@ -218,11 +216,10 @@ in # Home Manager needs a bit of information about you and the paths it should # manage. username = device.user; - homeDirectory = - if device.isMac then - lib.mkForce "/Users/${device.user}" - else - lib.mkForce "/home/${device.user}"; + homeDirectory = if device.isMac then + lib.mkForce "/Users/${device.user}" + else + lib.mkForce "/home/${device.user}"; stateVersion = "23.11"; diff --git a/config/nix/common/nvim/default.nix b/config/nix/common/nvim/default.nix index 48ecffde..a12832cb 100644 --- a/config/nix/common/nvim/default.nix +++ b/config/nix/common/nvim/default.nix @@ -21,9 +21,7 @@ undofile = true; }; - globals = { - mapleader = " "; - }; + globals = { mapleader = " "; }; plugins = { lspconfig = { enable = true; @@ -31,7 +29,7 @@ nil = { enable = true; extraConfig = - /* lua */ + # lua '' settings = { ['nil'] = { @@ -53,7 +51,7 @@ # rust-analyzer.enable = true; }; extraLua.pre = - /* lua */ + # lua '' local lsp_zero = require'lsp-zero' local lspconfig = require 'lspconfig' @@ -71,9 +69,7 @@ nvim-dap.enable = true; todo-comments.enable = true; - lualine = { - enable = true; - }; + lualine = { enable = true; }; commentary.enable = true; surround.enable = true; which-key.enable = true; @@ -92,9 +88,7 @@ refactor = { smartRename = { enable = true; - keymaps = { - smartRename = "rn"; - }; + keymaps = { smartRename = "rn"; }; }; }; }; @@ -170,7 +164,6 @@ noice-nvim nvim-web-devicons - ]; extraConfigLua = builtins.readFile ./extraConfig.lua; package = pkgs.neovim-nightly; diff --git a/config/nix/common/tmux.nix b/config/nix/common/tmux.nix index 64dda7b7..0a2a2af5 100644 --- a/config/nix/common/tmux.nix +++ b/config/nix/common/tmux.nix @@ -9,8 +9,7 @@ let tmux popup -d '#{pane_current_path}' -xC -yC -w$width -h$height -E "tmux attach -t scratch || tmux new -s scratch" fi ''; -in -{ +in { programs.tmux = { enable = true; shell = "${pkgs.nushellFull}/bin/nu"; @@ -28,7 +27,7 @@ in { plugin = tmuxPlugins.catppuccin; extraConfig = - /* tmux */ + # tmux '' set -g @catppuccin_flavour 'mocha' set -g @catppuccin_window_default_text '''''' @@ -37,14 +36,14 @@ in { plugin = tmuxPlugins.battery; extraConfig = - /* tmux */ + # tmux '' set -g @catppuccin_status_modules_right "battery application session date_time" ''; } ]; extraConfig = - /* tmux */ + # tmux '' set -gw mode-keys vi set -g status-keys vi diff --git a/config/nix/common/wezterm.nix b/config/nix/common/wezterm.nix index f150d22c..c2be0daf 100644 --- a/config/nix/common/wezterm.nix +++ b/config/nix/common/wezterm.nix @@ -1,7 +1,7 @@ { pkgs, ... }: { programs.wezterm = { enable = true; - extraConfig = /* lua */ + extraConfig = # lua '' local wezterm = require 'wezterm'; return { diff --git a/config/nix/darwin/configuration.nix b/config/nix/darwin/configuration.nix index d42b42d7..e8dda5e2 100644 --- a/config/nix/darwin/configuration.nix +++ b/config/nix/darwin/configuration.nix @@ -18,7 +18,7 @@ # security.pam.enableSudoTouchIdAuth = true; system.patches = [ (pkgs.writeText "pam-reattach.patch" - /* diff */ + # diff '' new file mode 100644 index 0000000..e4293c0 diff --git a/config/nix/flake.nix b/config/nix/flake.nix index e591071b..e4d8341f 100644 --- a/config/nix/flake.nix +++ b/config/nix/flake.nix @@ -78,16 +78,8 @@ }; - outputs = - { nixpkgs - , home-manager - , nix-darwin - , flake-utils - , anyrun - , nur - , neovim-nightly-overlay - , ... - }@inputs: + outputs = { nixpkgs, home-manager, nix-darwin, flake-utils, anyrun, nur + , neovim-nightly-overlay, ... }@inputs: let config_devices = [ { @@ -174,9 +166,8 @@ }; catppuccinThemes = final: prev: { - catppuccinThemes = import ./themes/catppuccin.nix { - pkgs = final.pkgs; - }; + catppuccinThemes = + import ./themes/catppuccin.nix { pkgs = final.pkgs; }; }; overlays = [ @@ -189,24 +180,20 @@ inputs.nixneovimplugins.overlays.default nur.overlay ]; - in - { - nixosConfigurations = - let devices = nixos_devices; - in import ./nixos/device.nix { - inherit devices inputs nixpkgs home-manager overlays nur; - }; + in { + nixosConfigurations = let devices = nixos_devices; + in import ./nixos/device.nix { + inherit devices inputs nixpkgs home-manager overlays nur; + }; - darwinConfigurations = - let devices = darwin_devices; - in import ./darwin/device.nix { - inherit devices inputs nixpkgs home-manager overlays nix-darwin; - }; + darwinConfigurations = let devices = darwin_devices; + in import ./darwin/device.nix { + inherit devices inputs nixpkgs home-manager overlays nix-darwin; + }; - homeConfigurations = - let devices = linux_devices; - in import ./linux/device.nix { - inherit devices inputs nixpkgs home-manager overlays; - }; + homeConfigurations = let devices = linux_devices; + in import ./linux/device.nix { + inherit devices inputs nixpkgs home-manager overlays; + }; }; } diff --git a/config/nix/linux/hyprland.nix b/config/nix/linux/hyprland.nix index d3122a14..c8d133a7 100644 --- a/config/nix/linux/hyprland.nix +++ b/config/nix/linux/hyprland.nix @@ -1,29 +1,19 @@ { pkgs, ... }: { imports = [ ../modules/hyprpaper.nix ]; programs.hyprpaper = - let - wallpapers = [ - (builtins.fetchurl - { - url = "https://w.wallhaven.cc/full/zy/wallhaven-zy2x7v.png"; - sha256 = - "1vy4knw8cdwb5gszgvjahnwa2g0hh5lmz3v2hbx1nylmjg2rzpda"; - }) - ]; - in - { + let wallpapers = import ../utils/wallhaven.nix { inherit pkgs; }; + in { enable = true; systemd.enable = true; systemd.target = "hyprland-session.target"; - settings.preload = wallpapers; - settings.wallpapers = (map (wallpaper: "DP-1," + wallpaper) wallpapers); + settings.preload = wallpapers.all; + settings.wallpapers = { "DP-1" = wallpapers.shapes; }; }; wayland.windowManager.hyprland = { enable = true; settings = { - source = - "${pkgs.catppuccinThemes.hyprland}/themes/mocha.conf"; + source = "${pkgs.catppuccinThemes.hyprland}/themes/mocha.conf"; monitor = [ ",preferred,auto,auto" "DP-1, 2560x1440@170, 0x0, 1, transform, 0" diff --git a/config/nix/modules/hyprpaper.nix b/config/nix/modules/hyprpaper.nix index 10e12475..b6bc3450 100644 --- a/config/nix/modules/hyprpaper.nix +++ b/config/nix/modules/hyprpaper.nix @@ -2,10 +2,8 @@ with lib; -let - cfg = config.programs.hyprpaper; -in -{ +let cfg = config.programs.hyprpaper; +in { options = { programs.hyprpaper = { enable = mkEnableOption "Hyprpaper - Wayland wallpaper utility"; @@ -34,8 +32,9 @@ in }; wallpapers = mkOption { - type = listOf str; - default = [ ]; + type = attrsOf str; + default = { }; + example = { "DP-1" = ./wallpapers/tensura.png; }; description = '' Wallpaper to monitor mapper ''; @@ -44,7 +43,8 @@ in extraConfig = mkOption { type = str; default = ""; - description = "Check https://github.com/hyprwm/hyprpaper#usage for info"; + description = + "Check https://github.com/hyprwm/hyprpaper#usage for info"; example = '' newConfigOption = foo,bar ''; @@ -54,9 +54,7 @@ in }; config = { - home.packages = mkIf cfg.enable [ - pkgs.hyprpaper - ]; + home.packages = mkIf cfg.enable [ pkgs.hyprpaper ]; systemd.user.services.hyprpaper = mkIf cfg.systemd.enable { Unit = { @@ -73,11 +71,7 @@ in KillMode = "mixed"; }; - Install = { - WantedBy = [ - cfg.systemd.target - ]; - }; + Install = { WantedBy = [ cfg.systemd.target ]; }; }; xdg.configFile = mkIf cfg.enable { @@ -85,10 +79,17 @@ in # Auto-generated by Nix home-manager module # hyprpaper.settings.preload - ${(lists.foldl (acc: v: acc + "preload = ${v}\n") "" cfg.settings.preload)} + ${(lists.foldl (acc: v: + acc + '' + preload = ${v} + '') "" cfg.settings.preload)} # hyprpaper.settings.wallpapers - ${(lists.foldl (acc: v: acc + "wallpaper = ${v}\n") "" cfg.settings.wallpapers)} + ${(lists.foldl (acc: v: + acc + '' + wallpaper = ${v} + '') "" (pkgs.lib.attrsets.mapAttrsToList (name: val: name + "," + val) + cfg.settings.wallpapers))} # hyprpaper.settings.extraConfig ${cfg.settings.extraConfig} diff --git a/config/nix/nixos/configuration.nix b/config/nix/nixos/configuration.nix index ad0eb355..7e4a3add 100644 --- a/config/nix/nixos/configuration.nix +++ b/config/nix/nixos/configuration.nix @@ -10,7 +10,6 @@ security.polkit.enable = true; security.pam.services.greetd.enableGnomeKeyring = true; - services.mullvad-vpn.enable = true; services.resolved.enable = true; services.devmon.enable = true; @@ -29,27 +28,22 @@ }; boot.plymouth.enable = true; boot.plymouth.theme = "catppuccin-mocha"; - boot.plymouth.themePackages = with pkgs; [ - (catppuccin-plymouth.override - { - variant = "mocha"; - }) - ]; + boot.plymouth.themePackages = with pkgs; + [ (catppuccin-plymouth.override { variant = "mocha"; }) ]; - services.greetd = - let - tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet"; - hyprland-session = "${pkgs.hyprland}/share/wayland-sessions"; - in - { - enable = true; - settings = { - default_session = { - command = "${tuigreet} --time --remember --remember-session --sessions ${hyprland-session}"; - user = "greeter"; - }; + services.greetd = let + tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet"; + hyprland-session = "${pkgs.hyprland}/share/wayland-sessions"; + in { + enable = true; + settings = { + default_session = { + command = + "${tuigreet} --time --remember --remember-session --sessions ${hyprland-session}"; + user = "greeter"; }; }; + }; systemd.services.greetd.serviceConfig = { Type = "idle"; @@ -149,8 +143,7 @@ fish nushellFull (pkgs.wrapFirefox - (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) - { }) + (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) { }) gnumake python3 (nerdfonts.override { fonts = [ "FiraCode" "Hasklig" ]; }) diff --git a/config/nix/nixos/ryu.nix b/config/nix/nixos/ryu.nix index 51afb015..e831c16e 100644 --- a/config/nix/nixos/ryu.nix +++ b/config/nix/nixos/ryu.nix @@ -4,29 +4,28 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/11d8beef-2a63-4231-af35-b9b8d3a17e9b"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/11d8beef-2a63-4231-af35-b9b8d3a17e9b"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/4E27-DAC0"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/4E27-DAC0"; + fsType = "vfat"; + }; - fileSystems."/home" = - { device = "/dev/disk/by-uuid/d0835bd2-62fd-48d3-a0d1-8ae659f2e727"; - fsType = "ext4"; - }; + fileSystems."/home" = { + device = "/dev/disk/by-uuid/d0835bd2-62fd-48d3-a0d1-8ae659f2e727"; + fsType = "ext4"; + }; swapDevices = [ ]; @@ -39,5 +38,6 @@ # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/config/nix/themes/catppuccin.nix b/config/nix/themes/catppuccin.nix index f7bc6f21..b6195207 100644 --- a/config/nix/themes/catppuccin.nix +++ b/config/nix/themes/catppuccin.nix @@ -1,9 +1,10 @@ { pkgs, ... }: let - mkCatppuccin = { owner ? "catppuccin", item, rev ? "main", sha256 ? pkgs.lib.fakeSha256 }: + mkCatppuccin = { owner ? "catppuccin", version ? "0.0.1", item, rev ? "main" + , sha256 ? pkgs.lib.fakeSha256 }: pkgs.stdenv.mkDerivation { + inherit version; pname = item; - version = "0.0.1"; src = pkgs.fetchFromGitHub { inherit owner rev sha256; repo = item; @@ -14,8 +15,7 @@ let cp -r ./* $out/ ''; }; -in -{ +in { bat = mkCatppuccin { item = "bat"; diff --git a/config/nix/utils/wallhaven.nix b/config/nix/utils/wallhaven.nix new file mode 100644 index 00000000..216bda8c --- /dev/null +++ b/config/nix/utils/wallhaven.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: +let + getWall = { url, sha256 ? pkgs.lib.fakeSha256 }: + builtins.fetchurl { inherit url sha256; }; +in rec { + inherit getWall; + # Some predefined wallpapers + lights = getWall { + url = "https://w.wallhaven.cc/full/p2/wallhaven-p2el93.jpg"; + sha256 = "1fzxqdrxh7mbd18lgq1kqnzwf1nsgl7rj04idaq35cgf2fh0914v"; + }; + shapes = getWall { + url = "https://w.wallhaven.cc/full/p8/wallhaven-p8o29m.jpg"; + sha256 = "005qrq6dnzzwia9v9cv69krkcn86zv44s3790mxv7dfzj09r5amq"; + }; + cloud = getWall { + url = "https://w.wallhaven.cc/full/gp/wallhaven-gpv6rd.jpg"; + sha256 = "18hpaxwi1npcfkmyw42plivmjlpgvxgblp8fy2glxh7g1yxh6qds"; + }; + + all = [ lights shapes cloud ]; +}