diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1e3b8d --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# ❄️ NixOS dotfiles + +*My configuration files for NixOS. Feel free to look around and copy!* + +# Special thanks to: +- [Sioodmy's dotfiles](https://github.com/sioodmy/dotfiles) +- [Syndrizzle's dotfiles](https://github.com/syndrizzle/hotfiles) +- [Javacafe01's dotfiles](https://github.com/javacafe01/dotfiles) +- [Siduck76's NvChad](https://github.com/siduck76/nvchad/) +- [NixOS Manual](https://nixos.org/manual/nixos/stable/) +- [Epsyle's NixOS Dotfiles](https://github.com/epsyle/snowflake/) \ No newline at end of file diff --git a/flake.lock b/flake.lock index 3708ed1..78eb6ca 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1710532761, - "narHash": "sha256-SUXGZNrXX05YA9G6EmgupxhOr3swI1gcxLUeDMUhrEY=", + "lastModified": 1711133180, + "narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=", "owner": "nix-community", "repo": "home-manager", - "rev": "206f457fffdb9a73596a4cb2211a471bd305243d", + "rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb", "type": "github" }, "original": { @@ -22,25 +22,26 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1710123225, - "narHash": "sha256-j3oWlxRZxB7cFsgEntpH3rosjFHRkAo/dhX9H3OfxtY=", + "lastModified": 1710783728, + "narHash": "sha256-eIsfu3c9JUBgm3cURSKTXLEI9Dlk1azo+MWKZVqrmkc=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "ad2fd7b978d5e462048729a6c635c45d3d33c9ba", + "rev": "1e679b9a9970780cd5d4dfe755a74a8f96d33388", "type": "github" }, "original": { - "id": "nixos-hardware", - "type": "indirect" + "owner": "NixOS", + "repo": "nixos-hardware", + "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1710451336, - "narHash": "sha256-pP86Pcfu3BrAvRO7R64x7hs+GaQrjFes+mEPowCfkxY=", + "lastModified": 1711001935, + "narHash": "sha256-URtGpHue7HHZK0mrHnSf8wJ6OmMKYSsoLmJybrOLFSQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d691274a972b3165335d261cc4671335f5c67de9", + "rev": "20f77aa09916374aa3141cbc605c955626762c9a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e28ec78..ba885f1 100644 --- a/flake.nix +++ b/flake.nix @@ -2,35 +2,58 @@ description = "Jet's Nix Config"; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; - nixos-hardware.url = "nixos-hardware"; - # nixos-raspberrypi.url = "github:ramblurr/nixos-raspberrypi"; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + nixpkgs.url = "nixpkgs/nixos-unstable"; + nixos-hardware.url = "github:NixOS/nixos-hardware"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - nixConfig = { - }; + # All outputs for the system (configs) + outputs = { home-manager, nixpkgs, nixos-hardware, ... }@inputs: + let + system = "x86_64-linux"; #current system + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + lib = nixpkgs.lib; - outputs = { - self, - nixpkgs, - nixos-hardware, - home-manager, - ... - } @ inputs: { - nixosConfigurations = { - laptop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = {inherit inputs;}; - modules = [ - home-manager.nixosModules.home-manager - nixos-hardware.nixosModules.lenovo-thinkpad-x1-6th-gen - ./laptop.nix - ]; - }; - }; - }; + # This lets us reuse the code to "create" a system + # Credits go to sioodmy on this one! + # https://github.com/sioodmy/dotfiles/blob/main/flake.nix + mkSystem = pkgs: system: hostname: + let + hardwareConfig = { + "laptop" = "${inputs.nixos-hardware}.nixosModules.lenovo-thinkpad-x1-6th-gen"; + # Add other hostnames and their respective hardware configurations here + }; + in + pkgs.lib.nixosSystem { + inherit system; + modules = [ + { networking.hostName = hostname; } + ./modules/system/configuration.nix + (./. + "/hosts/${hostname}/hardware-configuration.nix") + (hardwareConfig.${hostname} or (lib.mkForce {})) # Import hardware configuration if exists for hostname + home-manager.nixosModules.home-manager + { + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + extraSpecialArgs = { inherit inputs; }; + users.jet = (./. + "/hosts/${hostname}/user.nix"); + }; + } + ]; + specialArgs = { inherit inputs; }; + }; + + + in { + nixosConfigurations = { + # Now, defining a new system is can be done in one line + # Architecture Hostname + laptop = mkSystem inputs.nixpkgs "x86_64-linux" "laptop"; + #desktop = mkSystem inputs.nixpkgs "x86_64-linux" "desktop"; + }; + }; } diff --git a/home.nix b/home.nix deleted file mode 100644 index 8da0832..0000000 --- a/home.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - # pkgs, - # inputs, - ... -}: { - programs = { - neovim = { - enable = true; - }; - }; - - home.username = "jet"; - home.homeDirectory = "/home/jet"; - home.stateVersion = "23.11"; -} diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix new file mode 100644 index 0000000..6c7a573 --- /dev/null +++ b/hosts/desktop/hardware-configuration.nix @@ -0,0 +1,31 @@ +# USE YOUR OWN +{ config, lib, pkgs, modulesPath, ... }: +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot = { + initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + initrd.kernelModules = [ "amdgpu" ]; + kernelModules = [ "wireguard" "kvm-amd" "msr" ]; + extraModulePackages = [ ]; + }; + + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/bd1e247e-9db1-4871-ae5a-f1d9dd0d09fb"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/62D7-547D"; + fsType = "vfat"; + }; + + swapDevices = [ { device = "/dev/disk/by-uuid/e8eac985-dcd4-4f52-8681-751e13b37e28"; } ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; +} diff --git a/hosts/desktop/user.nix b/hosts/desktop/user.nix new file mode 100644 index 0000000..8db5f18 --- /dev/null +++ b/hosts/desktop/user.nix @@ -0,0 +1,25 @@ +{ config, lib, inputs, ...}: + +{ + imports = [ ../../modules/default.nix ]; + config.modules = { + # gui + firefox.enable = true; + foot.enable = true; + eww.enable = true; + dunst.enable = true; + hyprland.enable = true; + wofi.enable = true; + + # cli + nvim.enable = true; + zsh.enable = true; + git.enable = true; + gpg.enable = true; + direnv.enable = true; + + # system + xdg.enable = true; + packages.enable = true; + }; +} diff --git a/hosts/laptop/hardware-configuration.nix b/hosts/laptop/hardware-configuration.nix new file mode 100644 index 0000000..0b89762 --- /dev/null +++ b/hosts/laptop/hardware-configuration.nix @@ -0,0 +1,40 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ad656dd1-ef88-4930-b8dd-f61765bdc067"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/16AA-5446"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/cc53c40a-4c06-4fcf-844e-8e55147fc2ae"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/laptop/user.nix b/hosts/laptop/user.nix new file mode 100644 index 0000000..82c2e9c --- /dev/null +++ b/hosts/laptop/user.nix @@ -0,0 +1,24 @@ +{ config, lib, inputs, ...}: + +{ + imports = [ ../../modules/default.nix ]; + config.modules = { + # gui + firefox.enable = true; + kitty.enable = true; + eww.enable = true; + dunst.enable = true; + hyprland.enable = true; + wofi.enable = true; + + # cli + nvim.enable = true; + git.enable = true; + nushell.enable = true; + direnv.enable = true; + + # system + xdg.enable = true; + packages.enable = true; + }; +} diff --git a/laptop.nix b/laptop.nix deleted file mode 100644 index bde01e0..0000000 --- a/laptop.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ - inputs, - pkgs, - lib, - config, - modulesPath, - ... -}: { - environment.systemPackages = with pkgs; [ - # c - gcc - gdb - gnumake - clang - clang-tools - - # nix - nil - alejandra - - # else - bat - wget - firefox - git - tree - neovim - nushell - kitty - ]; - - hardware.bluetooth.enable = true; - - networking.networkmanager.enable = true; - services.automatic-timezoned.enable = true; - services.xserver.enable = true; - services.desktopManager.plasma6.enable = true; - services.xserver.displayManager.sddm.enable = true; - services.xserver.xkb.layout = "us"; - - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - wireplumber.enable = true; - }; - - environment.variables = { - EDITOR = "nvim"; - VISUAL = "nvim"; - PAGER = "bat"; - }; - environment.sessionVariables = { - EDITOR = "nvim"; - VISUAL = "nvim"; - PAGER = "bat"; - }; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; - # boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-intel"]; - # boot.extraModulePackages = []; - - fileSystems."/" = { - device = "/dev/disk/by-uuid/ecfaab5f-dc2e-4bf0-a4cc-9a873de92c6f"; - fsType = "ext4"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/5426-5447"; - fsType = "vfat"; - }; - - swapDevices = [ - {device = "/dev/disk/by-uuid/db16204a-f762-4252-a7bb-1ff4f333fc17";} - ]; - - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - - fonts.packages = with pkgs; [ - noto-fonts-cjk - noto-fonts-color-emoji - ]; - - i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; - - users.users.jet = { - isNormalUser = true; - extraGroups = ["wheel"]; - shell = pkgs.nushell; - }; - home-manager.useGlobalPkgs = true; - home-manager.users.jet = import ./home.nix {inherit inputs pkgs;}; - - nix.settings = { - experimental-features = "nix-command flakes"; - auto-optimise-store = true; - trusted-users = ["root" "@wheel"]; - }; - nixpkgs.config = {allowUnfree = true;}; - - networking.hostName = "laptop"; - - imports = [(modulesPath + "/installer/scan/not-detected.nix")]; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - system.stateVersion = "23.05"; -} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..c9d221d --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,3 @@ +inputs: { + mkSystem = import ./mkSystem.nix inputs; +} diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix new file mode 100644 index 0000000..5ae4789 --- /dev/null +++ b/lib/mkSystem.nix @@ -0,0 +1,11 @@ +{ self, ... } @ inputs: name: system: inputs.nixpkgs.lib.nixosSystem ( + { + inherit system; + specialArgs = { inherit inputs self; }; + modules = [ + "${self}/hosts/${name}/system.nix" + "${self}/hosts/${name}/user.nix" + inputs.home-manager.nixosModule + ]; + } +) diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..4e52b9a --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,24 @@ +{ inputs, pkgs, config, ... }: + +{ + home.stateVersion = "21.03"; + imports = [ + # gui + ./firefox + ./foot + ./eww + ./dunst + ./hyprland + ./wofi + + # cli + ./nvim + ./zsh + ./git + ./direnv + + # system + ./xdg + ./packages + ]; +} diff --git a/modules/direnv/default.nix b/modules/direnv/default.nix new file mode 100644 index 0000000..9db2079 --- /dev/null +++ b/modules/direnv/default.nix @@ -0,0 +1,14 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.direnv; + +in { + options.modules.direnv= { enable = mkEnableOption "direnv"; }; + config = mkIf cfg.enable { + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; + }; +} diff --git a/modules/dunst/default.nix b/modules/dunst/default.nix new file mode 100644 index 0000000..1dc85ac --- /dev/null +++ b/modules/dunst/default.nix @@ -0,0 +1,42 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.dunst; + +in { + options.modules.dunst = { enable = mkEnableOption "dunst"; }; + config = mkIf cfg.enable { + home.packages = with pkgs; [ + dunst + ]; + + services.dunst = { + enable = true; + settings = { + global = { + origin = "top-left"; + offset = "60x12"; + separator_height = 2; + padding = 12; + horizontal_padding = 12; + text_icon_padding = 12; + frame_width = 4; + separator_color = "frame"; + idle_threshold = 120; + font = "JetBrainsMono Nerdfont 12"; + line_height = 0; + format = "%s\n%b"; + alignment = "center"; + icon_position = "off"; + startup_notification = "false"; + corner_radius = 12; + + frame_color = "#44465c"; + background = "#303241"; + foreground = "#d9e0ee"; + timeout = 2; + }; + }; + }; + }; +} diff --git a/modules/eww/default.nix b/modules/eww/default.nix new file mode 100644 index 0000000..2eae452 --- /dev/null +++ b/modules/eww/default.nix @@ -0,0 +1,50 @@ +{ inputs, lib, config, pkgs, ... }: +with lib; +let + cfg = config.modules.eww; +in { + options.modules.eww = { enable = mkEnableOption "eww"; }; + + config = mkIf cfg.enable { + # theres no programs.eww.enable here because eww looks for files in .config + # thats why we have all the home.files + + # eww package + home.packages = with pkgs; [ + eww + pamixer + brightnessctl + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + + # configuration + home.file.".config/eww/eww.scss".source = ./eww.scss; + home.file.".config/eww/eww.yuck".source = ./eww.yuck; + + # scripts + home.file.".config/eww/scripts/battery.sh" = { + source = ./scripts/battery.sh; + executable = true; + }; + + home.file.".config/eww/scripts/wifi.sh" = { + source = ./scripts/wifi.sh; + executable = true; + }; + + home.file.".config/eww/scripts/brightness.sh" = { + source = ./scripts/brightness.sh; + executable = true; + }; + + home.file.".config/eww/scripts/workspaces.sh" = { + source = ./scripts/workspaces.sh; + executable = true; + }; + + home.file.".config/eww/scripts/workspaces.lua" = { + source = ./scripts/workspaces.lua; + executable = true; + }; + }; +} diff --git a/modules/eww/eww.scss b/modules/eww/eww.scss new file mode 100644 index 0000000..88f0320 --- /dev/null +++ b/modules/eww/eww.scss @@ -0,0 +1,291 @@ +$base: #44465c; +$blue: #3fc6de; +$surface0: #44465c; +$surface1: #44465c; +$text: #d9e0ee; +$overlay0: #6e738d; +$red: #ec6a88; +$peach: #efb993; +$yellow: #efb993; +$mauve: #b072d1; +$green: #3fdaa4; +$mantle: #292a37; +$crust: #2e303e; +$light-gray: #9699b7; + +* { + all: unset; //Unsets everything so you can style everything from scratch + font-family: "JetBrainsMono" +} + +.icon { + font-family: monospace; + font-size: 1.4rem; +} + + +button { + transition: background-color 200ms, color 200ms; +} + +.active { + color: $green; + font-size: 1.4rem; +} + +.inactive { + color: $base; + font-size: 1.4rem; +} + +.inactive:hover { + color: $light-gray; +} + +.bar { + background-color: $mantle; + border-left: 4px dotted $red; +} + +.dashboard { + background-color: $mantle; + padding: 1rem; + margin-bottom: 1rem; +} + +.cal-box { + padding: 1rem 1rem .2rem; +} + +.cal { + padding: 0; + border-radius: 8px; +} + +.calendar_box { + padding: 1rem; + calendar:selected { + color: $blue; + } + + calendar.header { + color: $blue; + font-weight: bold; + } + + calendar.button { + color: $blue; + } + + calendar.highlight { + color: $green; + font-weight: bold; + } + + calendar:indeterminate { + color: rgba(205, 219, 249, 0.3); + } +} + +.sysinfo_box { + padding: 1rem; + .iconmem { + font-size: 3rem; + color: $yellow; + } + .iconcpu { + font-size: 3rem; + color: $blue; + } + .icondisk { + font-size: 3rem; + color: $green; + } + .cpubar, .membar, .diskbar { + background-color: $crust; + } +} +.slider_box { + padding: 0 1rem; + scale { + background-color: $crust; + border-radius: 100px; + margin: 0.5rem 0; + } + + scale trough { + border-radius: 100px; + } + + scale highlight { + padding: 8px; + margin: 8px; + border-radius: 100px; + } + + .brightness_slider highlight { + background-color: $yellow; + } + + .volume_slider highlight { + background-color: $blue; + } + + .micvolume_slider highlight { + background-color: $green; + } + + .slider_icon { + font-size: 2rem; + padding-right: 0.75rem; + } +} + +.notification_box { +} + +.wifi { + font-size: 2rem; + color: $blue; +} + +.clock { + font-weight: bold; + background-color: $base; + color: $text; + border-radius: 10px; + padding: 0.2rem; + margin: 0.5rem; +} + +.cpubar { + color: $blue; + background-color: $surface1; + margin: 4px 0; +} + +.diskbar { + color: $green; + background-color: $surface1; + margin: 4px 0; +} + +.membar { + color: $yellow; + background-color: $surface1; + margin: 4px 0; +} + +.iconmem, .iconcpu, .icondisk { + color: $base; + font-size: 2.5rem; +} + +.date { + font-size: 1.5rem; +} + +.reg-btn { + font-size: 2rem; + margin: 2px 8px; + border-radius: 10px; +} + +.dashbutton { + color: $mauve; +} + +.dashbutton:hover { + background-color: $base; +} + +.dashbutton:active { + background-color: $mauve; + color: $mantle; +} + +.powerbutton { + color: $red; +} + +.powerbutton:hover { + background-color: $base; +} + +.powerbutton:active { + background-color: $red; + color: $mantle; +} + +.launchbutton { + background-color: $blue; + color: $mantle; + margin-top: 6px; +} + +.launchbutton:hover { + background-color: $mauve; +} + +.launchbutton:active { + color: $mauve; + background-color: $mantle; +} + +.battery { + font-size: 1.5rem; + color: $blue; +} + +// Credits AlphaTechnolog +.powermenu-box { + padding: 0 2px; + margin: 7px 7px 7px 0px; + background: inherit; + .dispatcher { + border-radius: 15px; + background: $base; + color: $red; + font-size: 14px; + padding: 0 14px 0 10px; + &:hover { background-color: $surface0; } + &:active { background-color: $surface1; } + } +} + +// powermenu +.powermenu-container { + background: $crust; + color: $text; + padding: 10px; + font-size: 55px; + + transition: all 200ms cubic-bezier(.1,-0.00,.0,1.49); + + .btn { margin: 1rem;} + // shutdown + .shutdown-btn-box .btn { + color: $red; + border-radius: 15px; + background-color: $mantle; + &:hover { background-color: $base; } + &:active { background-color: $surface1; } + } + // reboot + .reboot-btn-box .btn { + color: $mauve; + border-radius: 15px; + background-color: $mantle; + &:hover { background-color: $base; } + &:active { background-color: $surface1; } + } + // exit + .exit-btn-box .btn { + color: $yellow; + border-radius: 15px; + background-color: $mantle; + &:hover { background-color: $base; } + &:active { background-color: $surface1; } + } +} + diff --git a/modules/eww/eww.yuck b/modules/eww/eww.yuck new file mode 100644 index 0000000..0b85bde --- /dev/null +++ b/modules/eww/eww.yuck @@ -0,0 +1,295 @@ +(defwidget bar [] + (centerbox :orientation "v" :hexpand false + (box :valign "start" :hexpand false :vexpand true :orientation "v" :space-evenly false + (launch) + (dashbutton) + (powerbutton) + ) + + (workspaces :halign "center" :vexpand true :hexpand false :orientation "v") + + (box :valign "end" :hexpand false :vexpand true :orientation "v" :space-evenly false + (battery) + (wifi) + (mem :thickness 4 :icon "") + (cpu :thickness 4 :icon "") + (disk :thickness 4 :icon "") + (time) + ) + ) +) + +(defpoll brightness :interval "999h" :initial 0 `brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}'`) +(defpoll volume :interval "999h" :initial 0 `pamixer --get-volume`) +(defpoll micvolume :interval "999h" :initial 0 `pamixer --get-volume --source 1`) +(defwidget dashboard [] + (box :orientation "v" + (box :class "info_box" :orientation "v" :space-evenly false + (box :class "calendar_box" + (calendar :width 200 :class "cal") + ) + + (box :class "slider_box" :orientation "v" :vexpand false :hexpand false + (box :space-evenly false + (label :class "slider_icon" :text "") + (scale :min 1 :max 101 :width 315 :class "brightness_slider" :value brightness :onchange "brightnessctl set {}%" :height 10) + ) + (box :space-evenly false + (label :class "slider_icon" :text "墳") + (scale :min 1 :max 101 :width 315 :class "volume_slider" :value volume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//')") + ) + (box :space-evenly false + (label :class "slider_icon" :text "") + (scale :min 1 :max 101 :width 315 :class "micvolume_slider" :value micvolume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//') --source 1") + ) + ) + (box :class "sysinfo_box" :orientation "h" :vexpand true :spacing 15 + (mem :thickness 12 :icon "") + (cpu :thickness 12 :icon "") + (disk :thickness 12 :icon "") + ) + ) + (box :class "notification_box" + ) + ) +) + + + + +;; Variables +(defvar time false) +(defvar cal false) + +;; ━━━ WIDGETS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defwidget dashbutton[] + (button :class "reg-btn dashbutton" :onclick "eww open dashboard --toggle" "舘") +) + + + +;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defwidget mem [icon thickness] + (box :vexpand "false" :hexpand "false" + (circular-progress :value {EWW_RAM.used_mem_perc} + :class "membar" + :thickness {thickness} + :start-at 75 + + (label :class "iconmem" :text {icon}) + ) + ) +) + +;; ━━━ CPU ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defwidget cpu [icon thickness] + (box :vexpand "false" :hexpand "false" + (circular-progress :value {EWW_CPU.avg} + :class "cpubar" + :thickness {thickness} + :start-at 75 + + (label :class "iconcpu" :text {icon}) + ) + ) +) + +;; ━━━ DISK ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defwidget disk [icon thickness] + (box :vexpand "false" :hexpand "false" + (circular-progress :value {EWW_DISK["/"].used_perc} + :class "diskbar" + :thickness {thickness} + :start-at 75 + (label :class "icondisk" :text {icon}) + + ) + ) +) + + +;; ━━━ WIFI ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defvar wifi "{}") +(defpoll wifi :interval "30s" "./scripts/wifi.sh") + +(defwidget wifi [] + (box :vexpand false :hexpand false :orientation "v" + (label :text {wifi.icon} + :limit-width 10 + :tooltip {wifi.status} + :class "wifi" + ) + ) +) + +;; ━━━ BATTERY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defvar battery "{}") +(defpoll battery :interval "60s" "./scripts/battery.sh") + +(defwidget battery [] + (label :text {battery.icon} + :limit-width 10 + :tooltip "${battery.status}: ${battery.percent}" + :class "battery" + ) +) + + +;; ━━━ VOLUME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +(defvar volume-level 50) +(defvar volume-muted false) + +(defwindow volume + :monitor 0 + :geometry (geometry :y "100px" :x "0px" :width "250px" :height "200px" :anchor "center bottom") + :windowtype "dock" + :wm-ignore true + :stacking "fg" + + (box :class "volume-window" + :orientation "v" + :space-evenly "false" + (box :class "volume-widget" + :orientation "h" + :space-evenly false + :spacing 10 + (label :text {volume-muted ? "" : + volume-level == 0 ? "" : + volume-level < 32 ? "" : + volume-level < 65 ? "" : + ""} + + :class 'volume-icon ${volume-muted ? "volume-icon-muted" : ""}' + ) + (scale :class 'volume-slider ${volume-muted ? "volume-slider-muted" : ""}' + :hexpand "true" + :min 0 + :max 100 + :height 8 + :marks true + :value volume-level + :onchange "pamixer --set-volume {}")))) + +;; ━━━ TIME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +(defpoll hour :interval "10s" "date +%H") +(defpoll minute :interval "10s" "date +%M") +(defpoll dateVar :interval "600s" "date '+%A %d.%m.%y'") + +(defwidget time [] + (eventbox :cursor "hand" :hexpand false :vexpand false + :tooltip "${dateVar}" + (box :orientation "v" :hexpand false :vexpand false :space-evenly false :class "clock" + (button :class "date" + :onclick "" "${hour}") + + (button :class "date" + :onclick "" "${minute}") + ) + ) +) + + + + +(defvar bright-level 50) +(defvar bright-muted false) +(defwindow brightness + :monitor 0 + :geometry (geometry :y "-60px" :x "60px" :width "300px" :height "150px" :anchor "bottom left") + :wm-ignore true + :stacking "fg" + + (box :class "volume-window" + :orientation "v" + :space-evenly "false" + (box :class "volume-widget" + :orientation "h" + :space-evenly false + :spacing 10 + (label :text "" + :class 'volume-icon' + ) + (scale :class 'volume-slider' + :hexpand "true" + :min 0 + :max 100 + :height 8 + :marks true + :value bright-level + :onchange "brightnessctl set {}%")))) +(defwidget launch [] + (button :class "reg-btn launchbutton" + :hexpand true + :onclick "wofi --show run --xoffset=1670 --yoffset=12 --width=230px --height=984 --style=$HOME/.config/wofi.css --term=footclient --prompt=Run &" "") +) + +(defwidget powerbutton [] + (eventbox :cursor "hand" + (button :class "reg-btn powerbutton" + :onclick "eww open powermenu --toggle &" "") + ) +) + (defwidget powermenucontent [] + (box :orientation "h" + :class "powermenu-container" + (box :class "shutdown-btn-box" + :orientation "h" + (button :class "btn" + :tooltip "Shutdown" + :onclick "eww close powermenu && shutdown now" + "⏻") + ) + (box :class "reboot-btn-box" + :orientation "h" + (button :class "btn" + :tooltip "Reboot" + :onclick "eww close powermenu && reboot" + "") + ) + (box :class "exit-btn-box" + :orientation "h" + (button :class "btn" + :tooltip "Suspend" + :onclick "systemctl suspend" + "") + ) + ) +) + +(defwindow powermenu + :monitor 0 + :geometry (geometry :x "0%" + :y "0%" + :width "30%" + :height "15%" + :anchor "center center") + :wm-ignore true + (powermenucontent)) + +(deflisten workspaces_listen "./scripts/workspaces.sh") +(defwidget workspaces [] + (literal :content workspaces_listen)) + +(defwindow dashboard + :monitor 0 + :geometry (geometry + :height "1080px" + :width "350px" + :x "48px" + :y "0px" + :anchor "top left") + :stacking "fg" + :class "dashboard" + (dashboard)) + +(defwindow bar + :monitor 0 + :exclusive false + :geometry (geometry :height "1080px" :x "-4px" :y "0px" + :width "52px" + :anchor "top left") + :stacking "fg" + (bar)) diff --git a/modules/eww/scripts/battery.sh b/modules/eww/scripts/battery.sh new file mode 100755 index 0000000..46fe3f8 --- /dev/null +++ b/modules/eww/scripts/battery.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +bat=/sys/class/power_supply/BAT1/ +per="$(cat "$bat/capacity")" +status="$(cat "$bat/status")" + +if [ "$per" -gt "90" ]; then + icon="" +elif [ "$per" -gt "80" ]; then + icon="" +elif [ "$per" -gt "70" ]; then + icon="" +elif [ "$per" -gt "60" ]; then + icon="" +elif [ "$per" -gt "50" ]; then + icon="" +elif [ "$per" -gt "40" ]; then + icon="" +elif [ "$per" -gt "30" ]; then + icon="" +elif [ "$per" -gt "20" ]; then + icon="" +elif [ "$per" -gt "10" ]; then + icon="" +elif [ "$per" -gt "0" ]; then + icon="" +else + icon="" +fi + + + + +if [ -s /sys/class/power_supply/BAT1/capacity ]; then + echo "{\"percent\": \"$per\", \"icon\": \"$icon\", \"charging\": \"$charging\", \"visible\": \"true\", \"status\": \"$status\"}" +else + echo "{\"visible\": \"false\" }" +fi diff --git a/modules/eww/scripts/brightness.sh b/modules/eww/scripts/brightness.sh new file mode 100755 index 0000000..47f9d4e --- /dev/null +++ b/modules/eww/scripts/brightness.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +if eww windows | grep -q "\*brightness"; then + eww update bright-level="$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%')" +else + eww close volume + eww open brightness + + eww update bright-level="$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%')" + sleep 2 + sleep 1 + eww close brightness +fi diff --git a/modules/eww/scripts/volume.sh b/modules/eww/scripts/volume.sh new file mode 100755 index 0000000..974530b --- /dev/null +++ b/modules/eww/scripts/volume.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if eww windows | rg -q "\*volume"; then + eww update volume-level=$(pamixer --get-volume) + eww update volume-muted=$(pamixer --get-mute) + eww update volume-hidden=false +else + eww close brightness + eww open volume + + eww update volume-level=$(pamixer --get-volume) + eww update volume-muted=$(pamixer --get-mute) + eww update volume-hidden=false + sleep 2 + eww update volume-hidden=true + sleep 1 + eww close volume +fi diff --git a/modules/eww/scripts/wifi.sh b/modules/eww/scripts/wifi.sh new file mode 100755 index 0000000..02cbf34 --- /dev/null +++ b/modules/eww/scripts/wifi.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if iwctl station wlan0 show | grep -q "connected"; then + icon="" + ssid=Amadeus + status="Connected to ${ssid}" +else + icon="睊" + status="offline" +fi + +echo "{\"icon\": \"${icon}\", \"status\": \"${status}\"}" diff --git a/modules/eww/scripts/workspaces.lua b/modules/eww/scripts/workspaces.lua new file mode 100755 index 0000000..cb0ec28 --- /dev/null +++ b/modules/eww/scripts/workspaces.lua @@ -0,0 +1,30 @@ +#!/usr/bin/env lua + +function trim(s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +aw = io.popen("hyprctl monitors | grep active | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'") +active_workspace = aw:read("*a") +aw:close() + +ew = io.popen("hyprctl workspaces | grep ID | sed 's/()/(1)/g' | sort | awk 'NR>1{print $1}' RS='(' FS=')'") +existing_workspaces = ew:read("*a") +ew:close() + +box = "(box :orientation \"v\" :spacing 1 :space-evenly \"true\" " + +for i = 1, #existing_workspaces do + local c = existing_workspaces:sub(i,i) + if tonumber(c) == tonumber(active_workspace) then + local btn = "(button :class \"active\" :onclick \"hyprctl dispatch workspace "..c.." \" \"\")" + box = box .. btn + elseif c ~= "\n" then + local btn = "(button :class \"inactive\" :onclick \"hyprctl dispatch workspace "..c.."\" \"\")" + box = box .. btn + end +end + +box = box .. ")" + +print(box) diff --git a/modules/eww/scripts/workspaces.sh b/modules/eww/scripts/workspaces.sh new file mode 100755 index 0000000..9ff9739 --- /dev/null +++ b/modules/eww/scripts/workspaces.sh @@ -0,0 +1,9 @@ +#!/bin/sh +workspaces() { +./scripts/workspaces.lua +} +workspaces +tail -f /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log | grep --line-buffered "Changed to workspace" | while read -r; do +workspaces +done + diff --git a/modules/firefox/default.nix b/modules/firefox/default.nix new file mode 100644 index 0000000..ed756b6 --- /dev/null +++ b/modules/firefox/default.nix @@ -0,0 +1,98 @@ +{ inputs, lib, config, pkgs, ... }: +with lib; +let + cfg = config.modules.eww; + +in { + options.modules.firefox = { enable = mkEnableOption "firefox"; }; + + config = mkIf cfg.enable { + programs.firefox = { + profiles = { + default = { + enable = true; + + # Install extensions from NUR + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + decentraleyes + ublock-origin + clearurls + sponsorblock + darkreader + h264ify + df-youtube + ]; + + # Privacy about:config settings + profiles.notus = { + settings = { + "browser.send_pings" = false; + "browser.urlbar.speculativeConnect.enabled" = false; + "dom.event.clipboardevents.enabled" = true; + "media.navigator.enabled" = false; + "network.cookie.cookieBehavior" = 1; + "network.http.referer.XOriginPolicy" = 2; + "network.http.referer.XOriginTrimmingPolicy" = 2; + "beacon.enabled" = false; + "browser.safebrowsing.downloads.remote.enabled" = false; + "network.IDN_show_punycode" = true; + "extensions.activeThemeID" = "firefox-compact-dark@mozilla.org"; + "app.shield.optoutstudies.enabled" = false; + "dom.security.https_only_mode_ever_enabled" = true; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.toolbars.bookmarks.visibility" = "never"; + "geo.enabled" = false; + + # Disable telemetry + "browser.newtabpage.activity-stream.feeds.telemetry" = false; + "browser.ping-centre.telemetry" = false; + "browser.tabs.crashReporting.sendReport" = false; + "devtools.onboarding.telemetry.logged" = false; + "toolkit.telemetry.enabled" = false; + "toolkit.telemetry.unified" = false; + "toolkit.telemetry.server" = ""; + + # Disable Pocket + "browser.newtabpage.activity-stream.feeds.discoverystreamfeed" = false; + "browser.newtabpage.activity-stream.feeds.section.topstories" = false; + "browser.newtabpage.activity-stream.section.highlights.includePocket" = false; + "browser.newtabpage.activity-stream.showSponsored" = false; + "extensions.pocket.enabled" = false; + + # Disable prefetching + "network.dns.disablePrefetch" = true; + "network.prefetch-next" = false; + + # Disable JS in PDFs + "pdfjs.enableScripting" = false; + + # Harden SSL + "security.ssl.require_safe_negotiation" = true; + + # Extra + "identity.fxaccounts.enabled" = false; + "browser.search.suggest.enabled" = false; + "browser.urlbar.shortcuts.bookmarks" = false; + "browser.urlbar.shortcuts.history" = false; + "browser.urlbar.shortcuts.tabs" = false; + "browser.urlbar.suggest.bookmark" = false; + "browser.urlbar.suggest.engines" = false; + "browser.urlbar.suggest.history" = false; + "browser.urlbar.suggest.openpage" = false; + "browser.urlbar.suggest.topsites" = false; + "browser.uidensity" = 1; + "media.autoplay.enabled" = false; + "toolkit.zoomManager.zoomValues" = ".8,.90,.95,1,1.1,1.2"; + + "privacy.firstparty.isolate" = true; + "network.http.sendRefererHeader" = 0; + }; + + # userChome.css to make it look better + userChrome = buildins.readFile ./userChrome.css; + }; + }; + }; + }; + }; +} diff --git a/modules/firefox/userChrome.css b/modules/firefox/userChrome.css new file mode 100644 index 0000000..a5a4a4e --- /dev/null +++ b/modules/firefox/userChrome.css @@ -0,0 +1,69 @@ +* { + box-shadow: none !important; + border: 0px solid !important; +} + +#tabbrowser-tabs { + --user-tab-rounding: 8px; +} + +.tab-background { + border-radius: var(--user-tab-rounding) var(--user-tab-rounding) 0px 0px !important; + /* Connected */ + margin-block: 1px 0 !important; + /* Connected */ +} + +#scrollbutton-up, +#scrollbutton-down { + /* 6/10/2021 */ + border-top-width: 1px !important; + border-bottom-width: 0 !important; +} + +.tab-background:is([selected], [multiselected]):-moz-lwtheme { + --lwt-tabs-border-color: rgba(0, 0, 0, 0.5) !important; + border-bottom-color: transparent !important; +} + +[brighttext='true'] .tab-background:is([selected], [multiselected]):-moz-lwtheme { + --lwt-tabs-border-color: rgba(255, 255, 255, 0.5) !important; + border-bottom-color: transparent !important; +} + +/* Container color bar visibility */ +.tabbrowser-tab[usercontextid]>.tab-stack>.tab-background>.tab-context-line { + margin: 0px max(calc(var(--user-tab-rounding) - 3px), 0px) !important; +} + +#TabsToolbar, +#tabbrowser-tabs { + --tab-min-height: 29px !important; +} + +#main-window[sizemode='true'] #toolbar-menubar[autohide='true']+#TabsToolbar, +#main-window[sizemode='true'] #toolbar-menubar[autohide='true']+#TabsToolbar #tabbrowser-tabs { + --tab-min-height: 30px !important; +} + +#scrollbutton-up, +#scrollbutton-down { + border-top-width: 0 !important; + border-bottom-width: 0 !important; +} + +#TabsToolbar, +#TabsToolbar>hbox, +#TabsToolbar-customization-target, +#tabbrowser-arrowscrollbox { + max-height: calc(var(--tab-min-height) + 1px) !important; +} + +#TabsToolbar-customization-target toolbarbutton>.toolbarbutton-icon, +#TabsToolbar-customization-target .toolbarbutton-text, +#TabsToolbar-customization-target .toolbarbutton-badge-stack, +#scrollbutton-up, +#scrollbutton-down { + padding-top: 7px !important; + padding-bottom: 6px !important; +} \ No newline at end of file diff --git a/modules/git/default.nix b/modules/git/default.nix new file mode 100644 index 0000000..b2d9f65 --- /dev/null +++ b/modules/git/default.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.git; + +in { + options.modules.git = { enable = mkEnableOption "git"; }; + config = mkIf cfg.enable { + programs.git = { + enable = true; + userName = "notusknot"; + userEmail = "notusknot@gmail.com"; + extraConfig = { + init = { defaultBranch = "main"; }; + core = { + excludesfile = "$NIXOS_CONFIG_DIR/scripts/gitignore"; + }; + }; + }; + }; +} diff --git a/modules/hyprland/default.nix b/modules/hyprland/default.nix new file mode 100644 index 0000000..5138eb4 --- /dev/null +++ b/modules/hyprland/default.nix @@ -0,0 +1,15 @@ +{ inputs, pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.hyprland; + +in { + options.modules.hyprland= { enable = mkEnableOption "hyprland"; }; + config = mkIf cfg.enable { + home.packages = with pkgs; [ + wofi swaybg wlsunset wl-clipboard hyprland + ]; + + home.file.".config/hypr/hyprland.conf".source = ./hyprland.conf; + }; +} diff --git a/modules/hyprland/hyprland.conf b/modules/hyprland/hyprland.conf new file mode 100644 index 0000000..f0edd2f --- /dev/null +++ b/modules/hyprland/hyprland.conf @@ -0,0 +1,91 @@ +monitor=eDP-1,1920x1080@60,0x0,1 +monitor=eDP-1,addreserved,0,0,48,0 + +exec-once=swaybg -i $NIXOS_CONFIG_DIR/pics/wallpaper.png +exec-once=foot --server +exec-once=wlsunset -l -23 -L -46 +exec-once=eww daemon +exec-once=eww open bar +exec-once=dunst + +input { + follow_mouse=0 +} + +general { + sensitivity=1 + main_mod=ALT + + gaps_in=6 + gaps_out=12 + border_size=4 + col.active_border=0xffb072d1 + col.inactive_border=0xff292a37 + + damage_tracking=full +} + +decoration { + rounding=8 + blur=0 + drop_shadow=0 + shadow_range=60 + col.shadow=0x66000000 +} + +animations { + enabled=1 + animation=windows,1,4,default,slide + animation=borders,1,5,default + animation=fadein,1,5,default + animation=workspaces,1,3,default,vertslide +} + +dwindle { + pseudotile=0 # enable pseudotiling on dwindle +} + +# example window rules +# for windows named/classed as abc and xyz +windowrule=float,move 0 0,pqiv +windowrule=float,foot-notes +#windowrule=size 420 69,abc +#windowrule=tile,xyz +#windowrule=float,abc +#windowrule=pseudo,abc +#windowrule=monitor 0,xyz + +# example binds +bind=ALT,Return,exec,footclient +bind=ALTSHIFT,Q,killactive, +bind=ALT,V,togglefloating, +bind=ALT,R,exec,wofi --show run --xoffset=1670 --yoffset=12 --width=230px --height=984 --style=$HOME/.config/wofi.css --term=footclient --prompt=Run +bind=ALT,N,exec,cd ~/stuff/notes && footclient -a foot-notes sh -c "nvim ~/stuff/notes/$(date '+%Y-%m-%d').md" +bind=ALT,F,fullscreen,0 + +bind=ALT,h,movefocus,l +bind=ALT,l,movefocus,r +bind=ALT,k,movefocus,u +bind=ALT,j,movefocus,d + +bind=ALTSHIFT,h,movewindow,l +bind=ALTSHIFT,l,movewindow,r +bind=ALTSHIFT,k,movewindow,u +bind=ALTSHIFT,j,movewindow,d + +bind=ALT,1,workspace,1 +bind=ALT,2,workspace,2 +bind=ALT,3,workspace,3 +bind=ALT,4,workspace,4 +bind=ALT,5,workspace,5 + +bind=ALTSHIFT,exclam,movetoworkspacesilent,1 +bind=ALTSHIFT,at,movetoworkspacesilent,2 +bind=ALTSHIFT,numbersign,movetoworkspacesilent,3 +bind=ALTSHIFT,dollar,movetoworkspacesilent,4 +bind=ALTSHIFT,percent,movetoworkspacesilent,5 + +bind=,XF86MonBrightnessUp,exec,brightnessctl set +5% +bind=,XF86MonBrightnessDown,exec,brightnessctl set 5%- +bind=,XF86AudioRaiseVolume,exec,pamixer -i 5 +bind=,XF86AudioLowerVolume,exec,pamixer -d 5 diff --git a/modules/kitty/default.nix b/modules/kitty/default.nix new file mode 100644 index 0000000..4b9fde2 --- /dev/null +++ b/modules/kitty/default.nix @@ -0,0 +1,14 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.foot; + +in { + options.modules.foot = { enable = mkEnableOption "foot"; }; + config = mkIf cfg.enable { + programs.kitty = { + enable = true; + extraConfig = buildins.readFile ./kitty.conf; + }; + }; +} diff --git a/modules/kitty/kitty.conf b/modules/kitty/kitty.conf new file mode 100644 index 0000000..5629bfa --- /dev/null +++ b/modules/kitty/kitty.conf @@ -0,0 +1,243 @@ +# vim:fileencoding=utf-8:ft=conf + +# Font family. You can also specify different fonts for the +# bold/italic/bold-italic variants. By default they are derived automatically, +# by the OSes font system. Setting them manually is useful for font families +# that have many weight variants like Book, Medium, Thick, etc. For example: +# font_family Operator Mono Book +# bold_font Operator Mono Thick +# bold_italic_font Operator Mono Medium +# font_family Input Mono +font_family JetBrainsMono Nerdfont +italic_font auto +bold_font auto +bold_italic_font auto + +# Font size (in pts) +font_size 12.0 + +# The foreground color +foreground #c0b18b + +# The background color +background #262626 + +# The foreground for selections +selection_foreground #2f2f2f + +# The background for selections +selection_background #d75f5f + +# The cursor color +cursor #8fee96 + +# The cursor shape can be one of (block, beam, underline) +shell_integration no-cursor +cursor_shape block + +# The interval (in seconds) at which to blink the cursor. Set to zero to +# disable blinking. +cursor_blink_interval 0.5 + +# Stop blinking cursor after the specified number of seconds of keyboard inactivity. Set to +# zero or a negative number to never stop blinking. +cursor_stop_blinking_after 15.0 + +# Number of lines of history to keep in memory for scrolling back +scrollback_lines 2000 + +# Program with which to view scrollback in a new window. The scrollback buffer is passed as +# STDIN to this program. If you change it, make sure the program you use can +# handle ANSI escape sequences for colors and text formatting. +scrollback_pager less +G -R + +# Wheel scroll multiplier (modify the amount scrolled by the mouse wheel) +wheel_scroll_multiplier 5.0 + +# The interval between successive clicks to detect double/triple clicks (in seconds) +click_interval 0.5 + +# Characters considered part of a word when double clicking. In addition to these characters +# any character that is marked as an alpha-numeric character in the unicode +# database will be matched. +select_by_word_characters :@-./_~?&=%+# + +# Hide mouse cursor after the specified number of seconds of the mouse not being used. Set to +# zero or a negative number to disable mouse cursor hiding. +mouse_hide_wait 0.0 + +# The enabled window layouts. A comma separated list of layout names. The special value * means +# all layouts. The first listed layout will be used as the startup layout. +# For a list of available layouts, see the file layouts.py +enabled_layouts * + +# If enabled, the window size will be remembered so that new instances of kitty will have the same +# size as the previous instance. If disabled, the window will initially have size configured +# by initial_window_width/height, in pixels. +remember_window_size no +initial_window_width 640 +initial_window_height 400 + +# Delay (in milliseconds) between screen updates. Decreasing it, increases fps +# at the cost of more CPU usage. The default value yields ~100fps which is more +# that sufficient for most uses. +# repaint_delay 10 +repaint_delay 10 + +# Delay (in milliseconds) before input from the program running in the terminal +# is processed. Note that decreasing it will increase responsiveness, but also +# increase CPU usage and might cause flicker in full screen programs that +# redraw the entire screen on each loop, because kitty is so fast that partial +# screen updates will be drawn. +input_delay 3 + +# Visual bell duration. Flash the screen when a bell occurs for the specified number of +# seconds. Set to zero to disable. +visual_bell_duration 0.0 + +# Enable/disable the audio bell. Useful in environments that require silence. +enable_audio_bell yes + +# The modifier keys to press when clicking with the mouse on URLs to open the URL +open_url_modifiers ctrl+shift + +# The program with which to open URLs that are clicked on. The special value "default" means to +# use the operating system's default URL handler. +open_url_with default + +# The value of the TERM environment variable to set +term xterm-kitty + +# The width (in pts) of window borders. Will be rounded to the nearest number of pixels based on screen resolution. +window_border_width 0 + +window_margin_width 15 + +# The color for the border of the active window +active_border_color #ffffff + +# The color for the border of inactive windows +inactive_border_color #cccccc + +# Tab-bar colors +active_tab_foreground #000 +active_tab_background #eee +inactive_tab_foreground #444 +inactive_tab_background #999 + + +# The 16 terminal colors. There are 8 basic colors, each color has a dull and +# bright version. + +# black +color0 #2f2f2f +color8 #656565 + +# red +color1 #d75f5f +color9 #d75f5f + +# green +color2 #d4d232 +color10 #8fee96 + +# yellow +color3 #af865a +color11 #cd950c + +# blue +color4 #22c3a1 +color12 #22c3a1 + +# magenta +color5 #775759 +color13 #775759 + +# cyan +color6 #84edb9 +color14 #84edb9 + +# white +color7 #c0b18b +color15 #d8d8d8 + +# Key mapping +# For a list of key names, see: http://www.glfw.org/docs/latest/group__keys.html +# For a list of modifier names, see: http://www.glfw.org/docs/latest/group__mods.html +# You can use the special action no_op to unmap a keyboard shortcut that is +# assigned in the default configuration. + +# Clipboard +map super+v paste_from_clipboard +map ctrl+shift+s paste_from_selection +map super+c copy_to_clipboard +map shift+insert paste_from_selection + +# Scrolling +map ctrl+shift+up scroll_line_up +map ctrl+shift+down scroll_line_down +map ctrl+shift+k scroll_line_up +map ctrl+shift+j scroll_line_down +map ctrl+shift+page_up scroll_page_up +map ctrl+shift+page_down scroll_page_down +map ctrl+shift+home scroll_home +map ctrl+shift+end scroll_end +map ctrl+shift+h show_scrollback + +# Window management +map super+n new_os_window +map super+w close_window +map ctrl+shift+enter new_window +map ctrl+shift+] next_window +map ctrl+shift+[ previous_window +map ctrl+shift+f move_window_forward +map ctrl+shift+b move_window_backward +map ctrl+shift+` move_window_to_top +map ctrl+shift+1 first_window +map ctrl+shift+2 second_window +map ctrl+shift+3 third_window +map ctrl+shift+4 fourth_window +map ctrl+shift+5 fifth_window +map ctrl+shift+6 sixth_window +map ctrl+shift+7 seventh_window +map ctrl+shift+8 eighth_window +map ctrl+shift+9 ninth_window +map ctrl+shift+0 tenth_window + +# Tab management +map ctrl+shift+right next_tab +map ctrl+shift+left previous_tab +map ctrl+shift+t new_tab +map ctrl+shift+q close_tab +map ctrl+shift+l next_layout +map ctrl+shift+. move_tab_forward +map ctrl+shift+, move_tab_backward + +# Miscellaneous +map ctrl+shift+up increase_font_size +map ctrl+shift+down decrease_font_size +map ctrl+shift+backspace restore_font_size + +# Symbol mapping (special font for specified unicode code points). Map the +# specified unicode codepoints to a particular font. Useful if you need special +# rendering for some symbols, such as for Powerline. Avoids the need for +# patched fonts. Each unicode code point is specified in the form U+. You can specify multiple code points, separated by commas +# and ranges separated by hyphens. symbol_map itself can be specified multiple times. +# Syntax is: +# +# symbol_map codepoints Font Family Name +# +# For example: +# +#symbol_map U+E0A0-U+E0A2,U+E0B0-U+E0B3 PowerlineSymbols +hide_window_decorations titlebar-only +macos_option_as_alt no + +# Change the color of the kitty window's titlebar on macOS. A value of "system" +# means to use the default system color, a value of "background" means to use +# the default background color and finally you can use an arbitrary color, such +# as #12af59 or "red". +macos_titlebar_color background + +allow_remote_control yes \ No newline at end of file diff --git a/modules/laptopHardware/default.nix b/modules/laptopHardware/default.nix new file mode 100644 index 0000000..da4664a --- /dev/null +++ b/modules/laptopHardware/default.nix @@ -0,0 +1,11 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.laptopHardware; + +in { + options.modules.laptopHardware = { enable = mkEnableOption "laptopHardware"; }; + config = mkIf cfg.enable { + + }; +} diff --git a/modules/nushell/config.nu b/modules/nushell/config.nu new file mode 100644 index 0000000..2017b7c --- /dev/null +++ b/modules/nushell/config.nu @@ -0,0 +1,730 @@ +# Nushell Config File +# +# version = 0.83.1 + +# For more information on defining custom themes, see +# https://www.nushell.sh/book/coloring_and_theming.html +# And here is the theme collection +# https://github.com/nushell/nu_scripts/tree/main/themes +let dark_theme = { + # color for nushell primitives + separator: white + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + bool: {|| if $in { 'light_cyan' } else { 'light_gray' } } + int: white + filesize: {|e| + if $e == 0b { + 'white' + } else if $e < 1mb { + 'cyan' + } else { 'blue' } + } + duration: white + date: {|| (date now) - $in | + if $in < 1hr { + 'purple' + } else if $in < 6hr { + 'red' + } else if $in < 1day { + 'yellow' + } else if $in < 3day { + 'green' + } else if $in < 1wk { + 'light_green' + } else if $in < 6wk { + 'cyan' + } else if $in < 52wk { + 'blue' + } else { 'dark_gray' } + } + range: white + float: white + string: white + nothing: white + binary: white + cellpath: white + row_index: green_bold + record: white + list: white + block: white + hints: dark_gray + search_result: {bg: red fg: white} + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_closure: green_bold + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: white bg: red attr: b} + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_match_pattern: green + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple + shape_vardecl: purple +} + + +# External completer example +# let carapace_completer = {|spans| +# carapace $spans.0 nushell $spans | from json +# } + + +# The default config record. This is where much of your global configuration is setup. +$env.config = { + show_banner: false # true or false to enable or disable the welcome banner at startup + + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. + } + + rm: { + always_trash: false # always act as if -t was given. Can be overridden with -p + } + + + table: { + mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + show_empty: true # show 'empty list' and 'empty record' placeholders for command output + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + } + + # datetime_format determines what a datetime rendered in the shell would look like. + # Behavior without this configuration point will be to "humanize" the datetime display, + # showing something like "a day ago." + datetime_format: { + # normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables + # table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format + } + + explore: { + try: { + border_color: {fg: "white"} + }, + status_bar_background: {fg: "#1D1F21", bg: "#C4C9C6"}, + command_bar_text: {fg: "#C4C9C6"}, + highlight: {fg: "black", bg: "yellow"}, + status: { + error: {fg: "white", bg: "red"}, + warn: {} + info: {} + }, + table: { + split_line: {fg: "#404040"}, + selected_cell: {}, + selected_row: {}, + selected_column: {}, + cursor: true, + line_head_top: true, + line_head_bottom: true, + line_shift: true, + line_index: true, + }, + config: { + border_color: {fg: "white"} + cursor_color: {fg: "black", bg: "light_yellow"} + }, + } + + history: { + max_size: 100_000 # Session has to be reloaded for this to take effect + sync_on_enter: false # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "plaintext" # "sqlite" or "plaintext" + isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. + } + + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "fuzzy" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } + } + + filesize: { + metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto + } + + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default) + vi_insert: line # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default) + vi_normal: block # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default) + } + + color_config: {} # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + use_grid_icons: true + footer_mode: "25" # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + buffer_editor: "" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: emacs # emacs, vi + shell_integration: false # enables terminal shell integration. Off by default, as some terminals have issues with this. + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + + hooks: { + pre_prompt: [{ null }] # run before the prompt is shown + pre_execution: [{ null }] # run before the repl input is run + env_change: { + PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input + } + display_output: { + if (term size).columns >= 80 { + table -e + } else { + table + } + } + command_not_found: { null } # return an error message when a command is not found + } + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + ] + } + } + { + name: history_menu + modifier: control + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: history_menu } + } + { + name: help_menu + modifier: none + keycode: f1 + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: next_page_menu + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page_menu + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: escape + modifier: none + keycode: escape + mode: [emacs, vi_normal, vi_insert] + event: { send: esc } # NOTE: does not appear to work + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [emacs, vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolineend} + } + { + name: move_up + modifier: control + keycode: char_p + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: control + keycode: char_t + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: char_h + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: {edit: moveleft} + } + { + name: newline_or_run_command + modifier: none + keycode: enter + mode: emacs + event: {send: enter} + } + { + name: move_left + modifier: control + keycode: char_b + mode: emacs + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: control + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: redo_change + modifier: control + keycode: char_g + mode: emacs + event: {edit: redo} + } + { + name: undo_change + modifier: control + keycode: char_z + mode: emacs + event: {edit: undo} + } + { + name: paste_before + modifier: control + keycode: char_y + mode: emacs + event: {edit: pastecutbufferbefore} + } + { + name: cut_word_left + modifier: control + keycode: char_w + mode: emacs + event: {edit: cutwordleft} + } + { + name: cut_line_to_end + modifier: control + keycode: char_k + mode: emacs + event: {edit: cuttoend} + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: emacs + event: {edit: cutfromstart} + } + { + name: swap_graphemes + modifier: control + keycode: char_t + mode: emacs + event: {edit: swapgraphemes} + } + { + name: move_one_word_left + modifier: alt + keycode: left + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: right + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_one_word_left + modifier: alt + keycode: char_b + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: delete_one_word_forward + modifier: alt + keycode: delete + mode: emacs + event: {edit: deleteword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: backspace + mode: emacs + event: {edit: backspaceword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: char_m + mode: emacs + event: {edit: backspaceword} + } + { + name: cut_word_to_right + modifier: alt + keycode: char_d + mode: emacs + event: {edit: cutwordright} + } + { + name: upper_case_word + modifier: alt + keycode: char_u + mode: emacs + event: {edit: uppercaseword} + } + { + name: lower_case_word + modifier: alt + keycode: char_l + mode: emacs + event: {edit: lowercaseword} + } + { + name: capitalize_char + modifier: alt + keycode: char_c + mode: emacs + event: {edit: capitalizechar} + } + ] +} + diff --git a/modules/nushell/default.nix b/modules/nushell/default.nix new file mode 100644 index 0000000..dbbc391 --- /dev/null +++ b/modules/nushell/default.nix @@ -0,0 +1,16 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.nushell; + +in { + options.modules.nushell = { enable = mkEnableOption "nushell"; }; + config = mkIf cfg.enable { + programs.nushell = { + enable = true; + configFile.source = ./config.nu; + envFile.source = ./env.nu; + extraConfig = buildins.readFile ./extra.nu; + } + }; +} diff --git a/modules/nushell/env.nu b/modules/nushell/env.nu new file mode 100644 index 0000000..51ed547 --- /dev/null +++ b/modules/nushell/env.nu @@ -0,0 +1,82 @@ +# Nushell Environment Config File +# +# version = 0.83.1 + +def create_left_prompt [] { + mut home = "" + try { + if $nu.os-info.name == "windows" { + $home = $env.USERPROFILE + } else { + $home = $env.HOME + } + } + + let dir = ([ + ($env.PWD | str substring 0..($home | str length) | str replace $home "~"), + ($env.PWD | str substring ($home | str length)..) + ] | str join) + + let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) + let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) + let path_segment = $"($path_color)($dir)" + + $path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)" +} + +def create_right_prompt [] { + # create a right prompt in magenta with green separators and am/pm underlined + let time_segment = ([ + (ansi reset) + (ansi magenta) + (date now | date format '%Y/%m/%d %r') + ] | str join | str replace --all "([/:])" $"(ansi green)${1}(ansi magenta)" | + str replace --all "([AP]M)" $"(ansi magenta_underline)${1}") + + let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + (ansi rb) + ($env.LAST_EXIT_CODE) + ] | str join) + } else { "" } + + ([$last_exit_code, (char space), $time_segment] | str join) +} + +# Use nushell functions to define your right and left prompt +$env.PROMPT_COMMAND = {|| create_left_prompt } +# $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } + +# The prompt indicators are environmental variables that represent +# the state of the prompt +$env.PROMPT_INDICATOR = {|| " > " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| " : " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| " > " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +$env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +$env.NU_LIB_DIRS = [ + # ($nu.default-config-dir | path join 'scripts') # add /scripts +] + +# Directories to search for plugin binaries when calling register +$env.NU_PLUGIN_DIRS = [ + # ($nu.default-config-dir | path join 'plugins') # add /plugins +] + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') diff --git a/modules/nushell/extra.nu b/modules/nushell/extra.nu new file mode 100644 index 0000000..0d58793 --- /dev/null +++ b/modules/nushell/extra.nu @@ -0,0 +1,16 @@ +#source ~/.cache/starship/init.nu +#source ~/.zoxide.nu +#alias cringe = sudo bootctl set-oneshot auto-windows +#alias fetch = neofetch +#alias ff = firefox +#alias gc = sudo nix-collect-garbage -d +#alias js = jj status +#alias jd = jj diff +#alias pu = pueue +#alias rb = sudo nice -n19 nixos-rebuild boot --flake ~/projects/NOflake/ +#alias rs = sudo nice -n19 nixos-rebuild switch --flake ~/projects/NOflake/ +#alias t = task +#alias ts = tailscale +#alias tss = tailscale status +#alias tsx = tailscale exit-node list +#alias zl = zellij diff --git a/modules/nvim/default.nix b/modules/nvim/default.nix new file mode 100644 index 0000000..65cad85 --- /dev/null +++ b/modules/nvim/default.nix @@ -0,0 +1,97 @@ +{ lib, config, pkgs, ... }: +with lib; +let + cfg = config.modules.nvim; + # Source my theme + jabuti-nvim = pkgs.vimUtils.buildVimPlugin { + name = "jabuti-nvim"; + src = pkgs.fetchFromGitHub { + owner = "jabuti-theme"; + repo = "jabuti-nvim"; + rev = "17f1b94cbf1871a89cdc264e4a8a2b3b4f7c76d2"; + sha256 = "sha256-iPjwx/rTd98LUPK1MUfqKXZhQ5NmKx/rN8RX1PIuDFA="; + }; + }; +in { + options.modules.nvim = { enable = mkEnableOption "nvim"; }; + config = mkIf cfg.enable { + + home.file.".config/nvim/settings.lua".source = ./init.lua; + + home.packages = with pkgs; [ + nixfmt # Nix + sumneko-lua-language-server stylua # Lua + ]; + + programs.zsh = { + initExtra = '' + export EDITOR="nvim" + ''; + + shellAliases = { + v = "nvim -i NONE"; + nvim = "nvim -i NONE"; + }; + }; + + programs.neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + vim-nix + plenary-nvim + { + plugin = zk-nvim; + config = "require('zk').setup()"; + } + { + plugin = jabuti-nvim; + config = "colorscheme jabuti"; + } + { + plugin = impatient-nvim; + config = "lua require('impatient')"; + } + { + plugin = lualine-nvim; + config = "lua require('lualine').setup()"; + } + { + plugin = telescope-nvim; + config = "lua require('telescope').setup()"; + } + { + plugin = indent-blankline-nvim; + config = "lua require('indent_blankline').setup()"; + } + { + plugin = nvim-lspconfig; + config = '' + lua << EOF + require('lspconfig').rust_analyzer.setup{} + require('lspconfig').sumneko_lua.setup{} + require('lspconfig').rnix.setup{} + require('lspconfig').zk.setup{} + EOF + ''; + } + { + plugin = nvim-treesitter; + config = '' + lua << EOF + require('nvim-treesitter.configs').setup { + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + } + EOF + ''; + } + ]; + + extraConfig = '' + luafile ~/.config/nvim/settings.lua + ''; + }; + }; +} diff --git a/modules/nvim/init.lua b/modules/nvim/init.lua new file mode 100644 index 0000000..a34d108 --- /dev/null +++ b/modules/nvim/init.lua @@ -0,0 +1,83 @@ +local o = vim.opt +local g = vim.g + +-- Autocmds +vim.cmd [[ +augroup CursorLine + au! + au VimEnter * setlocal cursorline + au WinEnter * setlocal cursorline + au BufWinEnter * setlocal cursorline + au WinLeave * setlocal nocursorline +augroup END + +autocmd FileType nix setlocal shiftwidth=4 +]] + +-- Keybinds +local map = vim.api.nvim_set_keymap +local opts = { silent = true, noremap = true } + +map("n", "", "h", opts) +map("n", "", "j", opts) +map("n", "", "k", opts) +map("n", "", "l", opts) +map('n', '', ':Telescope live_grep ', opts) +map('n', '', ':Telescope find_files ', opts) +map('n', 'j', 'gj', opts) +map('n', 'k', 'gk', opts) +map('n', ';', ':', { noremap = true } ) + +g.mapleader = ' ' + +-- Performance +o.lazyredraw = true; +o.shell = "zsh" +o.shadafile = "NONE" + +-- Colors +o.termguicolors = true + +-- Undo files +o.undofile = true + +-- Indentation +o.smartindent = true +o.tabstop = 4 +o.shiftwidth = 4 +o.shiftround = true +o.expandtab = true +o.scrolloff = 3 + +-- Set clipboard to use system clipboard +o.clipboard = "unnamedplus" + +-- Use mouse +o.mouse = "a" + +-- Nicer UI settings +o.cursorline = true +o.relativenumber = true +o.number = true + +-- Get rid of annoying viminfo file +o.viminfo = "" +o.viminfofile = "NONE" + +-- Miscellaneous quality of life +o.ignorecase = true +o.ttimeoutlen = 5 +o.hidden = true +o.shortmess = "atI" +o.wrap = false +o.backup = false +o.writebackup = false +o.errorbells = false +o.swapfile = false +o.showmode = false +o.laststatus = 3 +o.pumheight = 6 +o.splitright = true +o.splitbelow = true +o.completeopt = "menuone,noselect" + diff --git a/modules/packages/default.nix b/modules/packages/default.nix new file mode 100644 index 0000000..fb782ed --- /dev/null +++ b/modules/packages/default.nix @@ -0,0 +1,34 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = + config.modules.packages; + screen = pkgs.writeShellScriptBin "screen" ''${builtins.readFile ./screen}''; + bandw = pkgs.writeShellScriptBin "bandw" ''${builtins.readFile ./bandw}''; + maintenance = pkgs.writeShellScriptBin "maintenance" ''${builtins.readFile ./maintenance}''; + +in { + options.modules.packages = { enable = mkEnableOption "packages"; }; + config = mkIf cfg.enable { + home.packages = with pkgs; [ + # C + gcc + gdb + gnumake + clang + clang-tools + # nix + nil + alejandra + # cli tools + bat + eza + fzf + ripgrep + unzip + tealdeer + ffmpeg + btop + ]; + }; +} diff --git a/modules/packages/maintenance b/modules/packages/maintenance new file mode 100755 index 0000000..4d10d6d --- /dev/null +++ b/modules/packages/maintenance @@ -0,0 +1,8 @@ +sudo nix-collect-garbage -d +sudo nix store verify --all +sudo nix store repair --all +cd $NIXOS_CONFIG_DIR +nix flake update +sudo nixos-rebuild switch --flake . --upgrade +nix run nixpkgs#bleachbit +nix run nixpkgs#pcmanfm diff --git a/modules/system/configuration.nix b/modules/system/configuration.nix new file mode 100755 index 0000000..d4627ef --- /dev/null +++ b/modules/system/configuration.nix @@ -0,0 +1,160 @@ +{ config, pkgs, inputs, ... }: + +{ + # Remove unecessary preinstalled packages + environment.defaultPackages = [ ]; + services.xserver.desktopManager.xterm.enable = false; + + programs.zsh.enable = true; + + # Laptop-specific packages (the other ones are installed in `packages.nix`) + environment.systemPackages = with pkgs; [ + acpi tlp git + ]; + + # Install fonts + fonts = { + packages = with pkgs; [ + jetbrains-mono + roboto + openmoji-color + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + + fontconfig = { + hinting.autohint = true; + defaultFonts = { + emoji = [ "OpenMoji Color" ]; + }; + }; + }; + + + # Wayland stuff: enable XDG integration, allow sway to use brillo +xdg = { + portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + config = { + common = { + default = "gtk"; + }; + preferred = { + "org.freedesktop.impl.portal.Screencast" = "wlr"; + }; + }; + }; +}; + + + # Nix settings, auto cleanup and enable flakes + nix = { + settings.auto-optimise-store = true; + settings.allowed-users = [ "jet" ]; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + extraOptions = '' + experimental-features = nix-command flakes + keep-outputs = true + keep-derivations = true + ''; + }; + + # Boot settings: clean /tmp/, latest kernel and enable bootloader + boot = { + tmp.cleanOnBoot = true; + loader = { + systemd-boot.enable = true; + systemd-boot.editor = false; + efi.canTouchEfiVariables = true; + timeout = 0; + }; + }; + + # Set up locales (timezone and keyboard layout) + time.timeZone = "America/Los_Angeles"; + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "us"; + }; + + # Set up user and enable sudo + users.users.jet = { + isNormalUser = true; + extraGroups = [ "input" "wheel" "networkmanager"]; + shell = pkgs.zsh; + }; + + # Set up networking and secure it + networking = { + # Enable networking + networkmanager.enable = true; + firewall = { + #enable = true; + #allowedTCPPorts = [ 443 80 ]; + #allowedUDPPorts = [ 443 80 44857 ]; + #allowPing = false; + }; + }; + + # Set environment variables + environment.variables = { + NIXOS_CONFIG = "$HOME/.config/nixos/configuration.nix"; + NIXOS_CONFIG_DIR = "$HOME/.config/nixos/"; + XDG_DATA_HOME = "$HOME/.local/share"; + PASSWORD_STORE_DIR = "$HOME/.local/share/password-store"; + GTK_RC_FILES = "$HOME/.local/share/gtk-1.0/gtkrc"; + GTK2_RC_FILES = "$HOME/.local/share/gtk-2.0/gtkrc"; + MOZ_ENABLE_WAYLAND = "1"; + ZK_NOTEBOOK_DIR = "$HOME/stuff/notes/"; + EDITOR = "nvim"; + DIRENV_LOG_FORMAT = ""; + ANKI_WAYLAND = "1"; + DISABLE_QT5_COMPAT = "0"; + GTK_USE_PORTAL = "1"; + }; + + # Security + security = { + # Extra security + protectKernelImage = true; + }; + # Allow unfree package + nixpkgs.config.allowUnfree = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # enable pulseaudio, enable opengl (for Wayland) + hardware = { + bluetooth.enable = true; + opengl = { + enable = true; + driSupport = true; + }; + }; + + # Do not touch + system.stateVersion = "23.11"; +} diff --git a/modules/template.nix b/modules/template.nix new file mode 100644 index 0000000..ce7f29b --- /dev/null +++ b/modules/template.nix @@ -0,0 +1,10 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.PROGRAM; + +in { + options.modules.PROGRAM = { enable = mkEnableOption "PROGRAM"; }; + config = mkIf cfg.enable { + }; +} diff --git a/modules/wofi/default.nix b/modules/wofi/default.nix new file mode 100644 index 0000000..956dc36 --- /dev/null +++ b/modules/wofi/default.nix @@ -0,0 +1,11 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.wofi; + +in { + options.modules.wofi = { enable = mkEnableOption "wofi"; }; + config = mkIf cfg.enable { + home.file.".config/wofi.css".source = ./wofi.css; + }; +} diff --git a/modules/wofi/wofi.css b/modules/wofi/wofi.css new file mode 100644 index 0000000..6f2ca04 --- /dev/null +++ b/modules/wofi/wofi.css @@ -0,0 +1,35 @@ +* { + all: unset; + font-family: "JetBrainsMono"; + font-size: 16px; +} + +#window { + background-color: #292a37; + border-radius: 12px; +} + +#outer-box { + background-color: #292a37; + border: 4px solid #44465c; + border-radius: 12px; +} + +#input{ + margin: 1rem; + padding: 0.5rem; + border-radius: 10px; + background-color: #303241; +} + +#entry { + margin: 0.25rem 0.75rem 0.25rem 0.75rem; + padding: 0.25rem 0.75rem 0.25rem 0.75rem; + color: #9699b7; + border-radius: 8px; +} + +#entry:selected { + background-color: #303241; + color: #d9e0ee; +} diff --git a/modules/xdg/default.nix b/modules/xdg/default.nix new file mode 100644 index 0000000..82109b0 --- /dev/null +++ b/modules/xdg/default.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, config, ... }: + +with lib; +let cfg = config.modules.xdg; + +in { + options.modules.xdg = { enable = mkEnableOption "xdg"; }; + config = mkIf cfg.enable { + xdg.userDirs = { + enable = true; + documents = "$HOME/stuff/other/"; + download = "$HOME/stuff/other/"; + videos = "$HOME/stuff/other/"; + music = "$HOME/stuff/music/"; + pictures = "$HOME/stuff/pictures/"; + desktop = "$HOME/stuff/other/"; + publicShare = "$HOME/stuff/other/"; + templates = "$HOME/stuff/other/"; + }; + }; +} diff --git a/modules/zsh/default.nix b/modules/zsh/default.nix new file mode 100755 index 0000000..aa5aed8 --- /dev/null +++ b/modules/zsh/default.nix @@ -0,0 +1,79 @@ +{ pkgs, lib, config, ... }: +with lib; +let cfg = config.modules.zsh; +in { + options.modules.zsh = { enable = mkEnableOption "zsh"; }; + + config = mkIf cfg.enable { + home.packages = [ + pkgs.zsh + ]; + + programs.zsh = { + enable = true; + + # directory to put config files in + dotDir = ".config/zsh"; + + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + # .zshrc + initExtra = '' + PROMPT="%F{blue}%m %~%b "$'\n'"%(?.%F{green}%Bλ%b |.%F{red}?) %f" + + export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store"; + export ZK_NOTEBOOK_DIR="~/stuff/notes"; + export DIRENV_LOG_FORMAT=""; + bindkey '^ ' autosuggest-accept + + edir() { tar -cz $1 | age -p > $1.tar.gz.age && rm -rf $1 &>/dev/null && echo "$1 encrypted" } + ddir() { age -d $1 | tar -xz && rm -rf $1 &>/dev/null && echo "$1 decrypted" } + ''; + + # basically aliases for directories: + # `cd ~dots` will cd into ~/.config/nixos + dirHashes = { + dots = "$HOME/.config/nixos"; + stuff = "$HOME/stuff"; + media = "/run/media/$USER"; + junk = "$HOME/stuff/other"; + }; + + # Tweak settings for history + history = { + save = 1000; + size = 1000; + path = "$HOME/.cache/zsh_history"; + }; + + # Set some aliases + shellAliases = { + c = "clear"; + mkdir = "mkdir -vp"; + rm = "rm -rifv"; + mv = "mv -iv"; + cp = "cp -riv"; + cat = "bat --paging=never --style=plain"; + ls = "exa -a --icons"; + tree = "exa --tree --icons"; + nd = "nix develop -c $SHELL"; + rebuild = "sudo nixos-rebuild switch --flake $NIXOS_CONFIG_DIR --fast; notify-send 'Rebuild complete\!'"; + }; + + # Source all plugins, nix-style + plugins = [ + { + name = "auto-ls"; + src = pkgs.fetchFromGitHub { + owner = "notusknot"; + repo = "auto-ls"; + rev = "62a176120b9deb81a8efec992d8d6ed99c2bd1a1"; + sha256 = "08wgs3sj7hy30x03m8j6lxns8r2kpjahb9wr0s0zyzrmr4xwccj0"; + }; + } + ]; + }; +}; +}