From 87be395fcc1b2b04587257e395585ea83e0dcdc2 Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Sun, 24 Mar 2024 19:02:22 +0100 Subject: [PATCH] lots of changes, damn so much, mostly neovim --- flake.nix | 64 +++++++------- hosts/bengal/configuration.nix | 93 +++----------------- hosts/bengal/hardware-configuration.nix | 44 +++++----- modules/common/default.nix | 38 ++++++-- modules/common/home.nix | 17 ++-- modules/common/neovim.nix | 62 ------------- modules/common/nvim/default.nix | 101 ++++++++++++++++++++++ modules/common/nvim/keymap.lua | 25 ++++++ modules/common/nvim/plugins/conform.lua | 12 +++ modules/common/nvim/plugins/dashboard.lua | 32 +++++++ modules/common/nvim/plugins/neo-tree.lua | 41 +++++++++ modules/common/nvim/plugins/noice.lua | 18 ++++ modules/common/yubikey.nix | 6 +- modules/graphical/default.nix | 47 +++++++++- users/default.nix | 11 ++- 15 files changed, 394 insertions(+), 217 deletions(-) delete mode 100644 modules/common/neovim.nix create mode 100644 modules/common/nvim/default.nix create mode 100644 modules/common/nvim/plugins/conform.lua create mode 100644 modules/common/nvim/plugins/dashboard.lua create mode 100644 modules/common/nvim/plugins/neo-tree.lua create mode 100644 modules/common/nvim/plugins/noice.lua diff --git a/flake.nix b/flake.nix index ab048bb..be6f6fb 100644 --- a/flake.nix +++ b/flake.nix @@ -6,38 +6,44 @@ url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; }; - }; - outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, ... }: - let - mkHost = hostname: graphical: { - imports = [ - ./hosts/${hostname}/configuration.nix - ./modules/common - (import "${home-manager}/nixos") - (if graphical then ./modules/graphical else null) - ]; - - deployment = { - targetUser = "root"; - targetHost = hostname; - allowLocalDeployment = true; - }; - }; - in - { - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; - colmena = { - meta = { - nixpkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ ]; - }; - }; - - bengal = mkHost "bengal" true; + outputs = inputs @ { + self, + nixpkgs, + nixpkgs-unstable, + home-manager, + ... + }: let + mkHost = hostname: graphical: { + imports = [ + ./hosts/${hostname}/configuration.nix + ./modules/common + (import "${home-manager}/nixos") + ( + if graphical + then ./modules/graphical + else null + ) + ]; + deployment = { + targetUser = "root"; + targetHost = hostname; + allowLocalDeployment = true; }; }; + in { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; + colmena = { + meta = { + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = []; + }; + }; + + bengal = mkHost "bengal" true; + }; + }; } diff --git a/hosts/bengal/configuration.nix b/hosts/bengal/configuration.nix index e377477..16317f2 100644 --- a/hosts/bengal/configuration.nix +++ b/hosts/bengal/configuration.nix @@ -1,96 +1,25 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page, on # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). - -{ config, lib, pkgs, ... }: - { - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + config, + lib, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; boot.loader.systemd-boot.enable = true; - networking.hostName = "bengal"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.hostName = "bengal"; + networking.networkmanager.enable = true; - # Set your time zone. - time.timeZone = "Europe/Berlin"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - console = { - font = "Lat2-Terminus16"; - keyMap = lib.mkForce "de"; - useXkbConfig = true; # use xkb.options in tty. - }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - services.xserver.displayManager.sddm.enable = true; - services.xserver.desktopManager.plasma5.enable = true; - services.xserver.libinput.enable = true; - - services.xserver.xkb.layout = "de"; - services.xserver.xkb.options = "caps:escape"; - - # Enable CUPS to print documents. services.printing.enable = true; - # Enable sound. - # sound.enable = true; hardware.pulseaudio.enable = true; - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - wget - curl - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - # Open ports in the firewall. - networking.firewall.allowedTCPPorts = [ 22 ]; - - nix.extraOptions = - '' - experimental-features = nix-command flakes - ''; - - # This option defines the first version of NixOS you have installed on this particular machine, - # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. - # - # Most users should NEVER change this value after the initial install, for any reason, - # even if you've upgraded your system to a new NixOS release. - # - # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, - # so changing it will NOT upgrade your system. - # - # This value being lower than the current NixOS release does NOT mean your system is - # out of date, out of support, or vulnerable. - # - # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, - # and migrated your data accordingly. - # - # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . system.stateVersion = "23.11"; # Did you read the comment? - } - diff --git a/hosts/bengal/hardware-configuration.nix b/hosts/bengal/hardware-configuration.nix index 6426f6d..bf34bd3 100644 --- a/hosts/bengal/hardware-configuration.nix +++ b/hosts/bengal/hardware-configuration.nix @@ -1,35 +1,35 @@ # 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") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-amd"]; + boot.extraModulePackages = []; - fileSystems."/" = - { - device = "/dev/disk/by-uuid/7a713df7-7027-4ae6-b1a3-839dda62dcbc"; - fsType = "btrfs"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/7a713df7-7027-4ae6-b1a3-839dda62dcbc"; + fsType = "btrfs"; + }; boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/fbd8d597-8cdb-4c6b-9fa0-b05f4cbfce86"; - fileSystems."/boot" = - { - device = "/dev/disk/by-uuid/B4A7-702B"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/B4A7-702B"; + fsType = "vfat"; + }; - swapDevices = - [{ device = "/dev/disk/by-uuid/8cca600e-735e-4486-92e3-01ff6c0b7599"; }]; + swapDevices = [{device = "/dev/disk/by-uuid/8cca600e-735e-4486-92e3-01ff6c0b7599";}]; # 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 diff --git a/modules/common/default.nix b/modules/common/default.nix index 6d8964d..a3a5ed5 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -1,14 +1,45 @@ -{ lib, config, pkgs, ... }: { +{ + lib, + config, + pkgs, + ... +}: { imports = [ ../../users ./home.nix ./yubikey.nix ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = ["nix-command" "flakes"]; + services.openssh.enable = true; + networking.firewall.allowedTCPPorts = [22]; time.timeZone = "Europe/Berlin"; + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = lib.mkForce "de"; + useXkbConfig = true; # use xkb.options in tty. + }; + + fonts = { + enableDefaultFonts = true; + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + monaspace + nerdfonts + ]; + fontconfig = { + defaultFonts.emoji = ["Noto Emoji"]; + defaultFonts.serif = ["Monaspace Xenon" "FiraCode Nerd Font" "Hack Nerd Font" "NotoSans Nerd Font"]; + defaultFonts.sansSerif = ["Monaspace Xenon" "FiraCode Nerd Font" "Hack Nerd Font" "NotoSerif Nerd Font"]; + defaultFonts.monospace = ["Monaspace Xenon" "FiraCode Nerd Font" "Hack Nerd Font"]; + }; + }; + # Packages used on all systems environment.systemPackages = with pkgs; [ git @@ -17,7 +48,4 @@ pinentry wget ]; - } - - diff --git a/modules/common/home.nix b/modules/common/home.nix index ccafe4c..a399b69 100644 --- a/modules/common/home.nix +++ b/modules/common/home.nix @@ -1,9 +1,12 @@ -{ lib, config, pkgs, ... }: { - - +{ + lib, + config, + pkgs, + ... +}: { home-manager.useGlobalPkgs = true; home-manager.users.sammy = { - imports = [ ./neovim.nix ]; + imports = [./nvim]; home.username = "sammy"; home.homeDirectory = "/home/sammy"; home.stateVersion = "23.11"; # Please read the comment before changing. @@ -12,6 +15,7 @@ lsd gnupg kitty + tmux ]; programs = { @@ -24,11 +28,10 @@ signing.key = "0xC01A7CBBA617BD5F"; signing.signByDefault = true; extraConfig = { - init = { defaultBranch = "main"; }; - core = { editor = "nvim"; }; + init = {defaultBranch = "main";}; + core = {editor = "nvim";}; pull.rebase = true; }; - }; nushell = { diff --git a/modules/common/neovim.nix b/modules/common/neovim.nix deleted file mode 100644 index ff59e52..0000000 --- a/modules/common/neovim.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ config, pkgs, inputs, ... }: - -{ - - programs.neovim = - let - toLua = str: "lua << EOF\n${str}\nEOF\n"; - toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; - in - { - enable = true; - - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - - extraPackages = with pkgs; [ - lua-language-server - rnix-lsp - - xclip - wl-clipboard - ]; - - plugins = with pkgs.vimPlugins; [ - - { - plugin = comment-nvim; - config = toLua "require(\"Comment\").setup()"; - } - - { - plugin = catppuccin-nvim; - config = "colorscheme catppuccin"; - } - - { plugin = which-key-nvim; - config = toLua "require(\"which-key\").setup()"; - } - - nvim-cmp - neodev-nvim - - cmp_luasnip - cmp-nvim-lsp - - luasnip - friendly-snippets - - - lualine-nvim - nvim-web-devicons - - vim-nix - ]; - - extraLuaConfig = '' - ${builtins.readFile ./nvim/options.lua} - ${builtins.readFile ./nvim/keymap.lua} - ''; - }; -} diff --git a/modules/common/nvim/default.nix b/modules/common/nvim/default.nix new file mode 100644 index 0000000..0fb2698 --- /dev/null +++ b/modules/common/nvim/default.nix @@ -0,0 +1,101 @@ +{ + config, + pkgs, + inputs, + ... +}: { + programs.neovim = let + toLua = str: "lua << EOF\n${str}\nEOF\n"; + toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; + in { + enable = true; + + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + extraPackages = with pkgs; [ + lua-language-server + rnix-lsp + + xclip + wl-clipboard + + rustfmt + black + isort + alejandra + prettierd + codespell + stylua + ]; + + plugins = with pkgs.vimPlugins; [ + plenary-nvim + persistence-nvim + nvim-web-devicons + nui-nvim + + { + plugin = comment-nvim; + config = toLua "require(\"Comment\").setup()"; + } + + { + plugin = catppuccin-nvim; + config = "colorscheme catppuccin"; + } + + { + plugin = which-key-nvim; + config = toLua "require(\"which-key\").setup()"; + } + + { + plugin = neo-tree-nvim; + config = toLuaFile ./plugins/neo-tree.lua; + } + + { + plugin = conform-nvim; + config = toLuaFile ./plugins/conform.lua; + } + + { + plugin = dressing-nvim; + config = toLua "require(\"dressing\").setup()"; + } + + { + plugin = bufferline-nvim; + config = toLua "require(\"bufferline\").setup()"; + } + + { + plugin = lualine-nvim; + config = toLua "require(\"lualine\").setup()"; + } + + { + plugin = indent-blankline-nvim; + config = toLua "require(\"ibl\").setup()"; + } + { + plugin = noice-nvim; + config = toLuaFile ./plugins/noice.lua; + } + { + plugin = dashboard-nvim; + config = toLuaFile ./plugins/dashboard.lua; + } + + nvim-notify + vim-nix + ]; + + extraLuaConfig = '' + ${builtins.readFile ./options.lua} + ${builtins.readFile ./keymap.lua} + ''; + }; +} diff --git a/modules/common/nvim/keymap.lua b/modules/common/nvim/keymap.lua index 262f0b4..960c5a4 100644 --- a/modules/common/nvim/keymap.lua +++ b/modules/common/nvim/keymap.lua @@ -67,3 +67,28 @@ map("n", "]", "tabnext", { desc = "Next Tab" }) map("n", "d", "tabclose", { desc = "Close Tab" }) map("n", "[", "tabprevious", { desc = "Previous Tab" }) + +-- NeoTree +map("n", "fe", + function() + require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() }) + end, { desc = "NeoTree" } +) +map("n", "e", "fe", { desc = "NeoTree", remap = true }) + +map("n", "ge", + function() + require("neo-tree.command").execute({ source = "git_status", toggle = true }) + end, { desc = "Git explorer" } +) +map("n", "be", + function() + require("neo-tree.command").execute({ source = "buffers", toggle = true }) + end, { desc = "Buffer explorer" } +) + +map({"n", "v"}, "cf", + function() + require("conform").format() + end, { desc = "Format Code" } +) diff --git a/modules/common/nvim/plugins/conform.lua b/modules/common/nvim/plugins/conform.lua new file mode 100644 index 0000000..6a4c4f6 --- /dev/null +++ b/modules/common/nvim/plugins/conform.lua @@ -0,0 +1,12 @@ +require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + python = { "isort", "black" }, + javascript = { "prettier" }, + rust = { "rustfmt" }, + nix = { "alejandra" }, + ["*"] = { "codespell" }, + }, + log_level = vim.log.levels.ERROR, + notify_on_error = true, +}) diff --git a/modules/common/nvim/plugins/dashboard.lua b/modules/common/nvim/plugins/dashboard.lua new file mode 100644 index 0000000..3b343b3 --- /dev/null +++ b/modules/common/nvim/plugins/dashboard.lua @@ -0,0 +1,32 @@ +local logo = [[ +Nyanyanyanyanyanyanyanyanyanyanyanyanyanyanyanyanyanya +██╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗ +████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║ +██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║ +██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║ +██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║ +╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ +]] + +logo = string.rep("\n", 8) .. logo .. "\n\n" + +require("dashboard").setup({ + theme = "doom", + hide = { + statusline = false, + tabline = true, -- hide the tabline + }, + config = { + header = vim.split(logo, "\n"), + -- stylua: ignore + center = { + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, + }, + footer = { "Meow!!!" }, --your footer + }, +}) diff --git a/modules/common/nvim/plugins/neo-tree.lua b/modules/common/nvim/plugins/neo-tree.lua new file mode 100644 index 0000000..5e7e242 --- /dev/null +++ b/modules/common/nvim/plugins/neo-tree.lua @@ -0,0 +1,41 @@ +local opts = { + sources = { "filesystem", "buffers", "git_status", "document_symbols" }, + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, + filesystem = { + bind_to_cwd = false, + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, + }, + window = { + mappings = { + [""] = "none", + }, + }, + default_component_configs = { + indent = { + indent_size = 2, + padding = 1, -- extra padding on left hand side + -- indent guides + with_markers = true, + indent_marker = "│", + last_indent_marker = "└", + highlight = "NeoTreeIndentMarker", + -- expander config, needed for nesting files + with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = "", + expander_expanded = "", + expander_highlight = "NeoTreeExpander", + }, + icon = { + folder_closed = "", + folder_open = "", + folder_empty = "󰜌", + -- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there + -- then these will never be used. + default = "*", + highlight = "NeoTreeFileIcon", + }, + }, +} + +require("neo-tree").setup(opts) diff --git a/modules/common/nvim/plugins/noice.lua b/modules/common/nvim/plugins/noice.lua new file mode 100644 index 0000000..9b8e296 --- /dev/null +++ b/modules/common/nvim/plugins/noice.lua @@ -0,0 +1,18 @@ +require("noice").setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) diff --git a/modules/common/yubikey.nix b/modules/common/yubikey.nix index 67c687d..8edc4f9 100644 --- a/modules/common/yubikey.nix +++ b/modules/common/yubikey.nix @@ -1,13 +1,11 @@ -{ pkgs, ... }: { - services.udev.packages = with pkgs; [ libu2f-host yubikey-personalization ]; +{pkgs, ...}: { + services.udev.packages = with pkgs; [libu2f-host yubikey-personalization]; programs.gnupg.agent = { enable = true; enableSSHSupport = true; enableExtraSocket = true; - }; services.pcscd.enable = true; } - diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index 4600a9f..24e7f56 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -1,12 +1,55 @@ -{ pkgs, config, lib, ... }: { +{ + pkgs, + config, + lib, + ... +}: { + services.xserver = { + enable = true; + displayManager.sddm.enable = true; + desktopManager.plasma5.enable = true; + desktopManager.plasma5.bigscreen.enable = true; + libinput.enable = true; + + xkb.layout = "de"; + xkb.options = "caps:escape"; + }; + home-manager.users.sammy = { programs = { - librewolf.enable = true; kitty = { enable = true; theme = "Catppuccin-Mocha"; + font = { + name = "Monaspace Xenon"; + size = 12; + }; + settings = { + # Seti-UI + Custom + "symbol_map U+E5FA-U+E62B" = "Symbols Nerd Font"; + # Devicons + "symbol_map U+E700-U+E7C5" = "Symbols Nerd Font"; + # Font Awesome + "symbol_map U+F000-U+F2E0" = "Symbols Nerd Font"; + # Font Awesome Extension + "symbol_map U+E200-U+E2A9" = "Symbols Nerd Font"; + # Material Design Icons + "symbol_map U+F500-U+FD46" = "Symbols Nerd Font"; + # Weather + "symbol_map U+E300-U+E3EB" = "Symbols Nerd Font"; + # Octicons + "symbol_map U+F400-U+F4A8,U+2665,U+26A1,U+F27C" = "Symbols Nerd Font"; + # Powerline Extra Symbols + "symbol_map U+E0A3,U+E0B4-U+E0C8,U+E0CC-U+E0D2,U+E0D4" = "Symbols Nerd Font"; + # IEC Power Symbols + "symbol_map U+23FB-U+23FE,U+2b58" = "Symbols Nerd Font"; + # Font Logos + "symbol_map U+F300-U+F313" = "Symbols Nerd Font"; + # Pomicons + "symbol_map U+E000-U+E00D" = "Symbols Nerd Font"; + }; }; }; }; diff --git a/users/default.nix b/users/default.nix index c7d711f..4cd90b7 100644 --- a/users/default.nix +++ b/users/default.nix @@ -1,11 +1,14 @@ -{ lib, config, pkgs, ... }: { +{ + lib, + config, + pkgs, + ... +}: { users.users = { sammy = { isNormalUser = true; - extraGroups = [ "networkmanager" "wheel" "docker" ]; + extraGroups = ["networkmanager" "wheel" "docker"]; shell = pkgs.nushell; - }; }; } -