From 68dfc234c60fad28aad2359b4ad9a3f9b938f74c Mon Sep 17 00:00:00 2001 From: Martin Benonisen Date: Mon, 18 Mar 2024 12:58:34 +0100 Subject: [PATCH] nizplz --- configuration.nix | 227 ---------------- flake.nix | 51 ++++ hosts/zedd/configuration.nix | 32 +++ hosts/zedd/default.nix | 8 + .../zedd/hardware-configuration.nix | 0 system/default.nix | 1 + system/fonts.nix | 15 ++ system/hardware.nix | 18 ++ system/programs.nix | 45 ++++ system/security.nix | 7 + system/services.nix | 45 ++++ system/users.nix | 29 +++ user/default.nix | 35 +++ user/packages/default.nix | 79 ++++++ user/programs/dunst/default.nix | 76 ++++++ user/programs/firefox/default.nix | 6 + user/programs/neovim/default.nix | 58 +++++ user/programs/neovim/keybinds.lua | 31 +++ user/programs/neovim/options.lua | 13 + user/programs/neovim/plugins.lua | 245 ++++++++++++++++++ user/programs/obs-studio/default.nix | 23 ++ user/programs/rofi/config.rasi | 17 ++ user/programs/rofi/default.nix | 24 ++ user/programs/tmux/default.nix | 13 + user/programs/vscode/default.nix | 19 ++ user/scripts/default.nix | 6 + user/scripts/rofi-launcher.sh | 8 + user/sops/default.nix | 6 + user/ssh/default.nix | 1 + user/ssh/zedd.nix | 15 ++ user/zsh/default.nix | 30 +++ 31 files changed, 956 insertions(+), 227 deletions(-) delete mode 100644 configuration.nix create mode 100644 flake.nix create mode 100644 hosts/zedd/configuration.nix create mode 100644 hosts/zedd/default.nix rename hardware-configuration.nix => hosts/zedd/hardware-configuration.nix (100%) create mode 100644 system/default.nix create mode 100644 system/fonts.nix create mode 100644 system/hardware.nix create mode 100644 system/programs.nix create mode 100644 system/security.nix create mode 100644 system/services.nix create mode 100644 system/users.nix create mode 100644 user/default.nix create mode 100644 user/packages/default.nix create mode 100644 user/programs/dunst/default.nix create mode 100644 user/programs/firefox/default.nix create mode 100644 user/programs/neovim/default.nix create mode 100644 user/programs/neovim/keybinds.lua create mode 100644 user/programs/neovim/options.lua create mode 100644 user/programs/neovim/plugins.lua create mode 100644 user/programs/obs-studio/default.nix create mode 100644 user/programs/rofi/config.rasi create mode 100644 user/programs/rofi/default.nix create mode 100644 user/programs/tmux/default.nix create mode 100644 user/programs/vscode/default.nix create mode 100644 user/scripts/default.nix create mode 100644 user/scripts/rofi-launcher.sh create mode 100644 user/sops/default.nix create mode 100644 user/ssh/default.nix create mode 100644 user/ssh/zedd.nix create mode 100644 user/zsh/default.nix diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 41b6476..0000000 --- a/configuration.nix +++ /dev/null @@ -1,227 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: -let - unstable = import {config = { allowUnfree = true; };}; -in -{ - # Enable OpenGL - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - hardware.ckb-next.enable = true; - networking.firewall.enable = false; - # Load nvidia driver for Xorg and Wayland - services.xserver.videoDrivers = ["nvidia"]; # or "nvidiaLegacy470 etc. - security.polkit.enable = true; - environment.pathsToLink = [ "/libexec" ]; - hardware.nvidia = { - - # Modesetting is required. - modesetting.enable = true; - - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - # Enable this if you have graphical corruption issues or application crashes after waking - # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead - # of just the bare essentials. - powerManagement.enable = false; - - # Fine-grained power management. Turns off GPU when not in use. - # Experimental and only works on modern Nvidia GPUs (Turing or newer). - powerManagement.finegrained = false; - - # Use the NVidia open source kernel module (not to be confused with the - # independent third-party "nouveau" open source driver). - # Support is limited to the Turing and later architectures. Full list of - # supported GPUs is at: - # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus - # Only available from driver 515.43.04+ - # Currently alpha-quality/buggy, so false is currently the recommended setting. - open = false; - - # Enable the Nvidia settings menu, - # accessible via `nvidia-settings`. - nvidiaSettings = true; - - # Optionally, you may need to select the appropriate driver version for your specific GPU. - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "Europe/Oslo"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - # Enable the X11 windowing system. - services.xserver.enable = true; - - - # Configure keymap in X11 - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; - - # Enable CUPS to print documents. - services.printing.enable = 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; - }; - - programs.zsh.enable = true; - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - users.defaultUserShell = pkgs.zsh; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.mbeno = { - shell = pkgs.zsh; - isNormalUser = true; - description = "Martin"; - extraGroups = [ "networkmanager" "wheel" "docker" ]; - packages = with pkgs; [ - firefox - alacritty - mumble - zoom - mattermost-desktop - # thunderbird - ]; - }; -programs.steam = { - enable = true; - remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play - dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server -}; - -security.sudo.extraRules= [ - { users = [ "mbeno" ]; - commands = [ - { command = "ALL" ; - options= [ "NOPASSWD" ]; # "SETENV" # Adding the following could be a good idea - } - ]; - } -]; - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - services.xserver = { - - desktopManager = { - xterm.enable = false; - }; - - displayManager = { - defaultSession = "none+i3"; - autoLogin.enable = true; - autoLogin.user = "mbeno"; - }; - - windowManager.i3 = { - enable = true; - extraPackages = with pkgs; [ - dmenu #application launcher most people use - i3status # gives you the default i3 status bar - i3lock #default i3 screen locker - i3blocks #if you are planning on using i3blocks over i3status - polybar - rofi - picom - nitrogen - ]; - }; - }; -systemd = { - user.services.polkit-gnome-authentication-agent-1 = { - description = "polkit-gnome-authentication-agent-1"; - wantedBy = [ "graphical-session.target" ]; - wants = [ "graphical-session.target" ]; - after = [ "graphical-session.target" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; - }; - }; -}; - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - steam-run - xdg-utils - xdg-desktop-portal - xdg-desktop-portal-gtk - unstable.zoom-us - neovim - git - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - ]; - - virtualisation.docker.enable = true; - # 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 = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.11"; # Did you read the comment? - -} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fd61afe --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Benny nixos config flake"; + + inputs = { + # nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-23.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager?ref=release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + sops-nix.url = "github:Mic92/sops-nix"; + }; + + outputs = + { self + , nixpkgs + , nixpkgs-unstable + , sops-nix + , notlistener + , ghettoptt + , ... + }@inputs: + let + system = "x86_64-linux"; + user = "mbeno"; + overlay-unstable = final: prev: { + unstable = import nixpkgs-unstable { + inherit system; + config.allowUnfree = true; + }; + }; + in + { + nixosConfigurations = { + zedd = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit inputs self user sops-nix; }; + modules = [ + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ + overlay-unstable + ]; + }) + ./hosts/mbeno + sops-nix.nixosModules.sops + ]; + }; + }; + }; +} diff --git a/hosts/zedd/configuration.nix b/hosts/zedd/configuration.nix new file mode 100644 index 0000000..4d3a0c7 --- /dev/null +++ b/hosts/zedd/configuration.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: +let + unstable = import { config = { allowUnfree = true; }; }; +in +{ + # Enable OpenGL + # Load nvidia driver for Xorg and Wayland + environment.pathsToLink = [ "/libexec" ]; + imports = + [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "nixos"; # Define your hostname. + networking.networkmanager.enable = true; + time.timeZone = "Europe/Oslo"; + i18n.defaultLocale = "en_US.UTF-8"; + + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + virtualisation.docker.enable = true; + system.stateVersion = "23.11"; # Did you read the comment? + +} diff --git a/hosts/zedd/default.nix b/hosts/zedd/default.nix new file mode 100644 index 0000000..a0f343f --- /dev/null +++ b/hosts/zedd/default.nix @@ -0,0 +1,8 @@ +{ inputs, self, pks, ... }: { + imports = [ + ./configuration.nix + ./hardware-configuration.nix + ../../system + ../../user + ]; +} diff --git a/hardware-configuration.nix b/hosts/zedd/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to hosts/zedd/hardware-configuration.nix diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..86d86fd --- /dev/null +++ b/system/default.nix @@ -0,0 +1 @@ +{ imports = [ ./users ./services ./hardware ./fonts ./security ./programs ] } diff --git a/system/fonts.nix b/system/fonts.nix new file mode 100644 index 0000000..5bfe305 --- /dev/null +++ b/system/fonts.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ twemoji-color-font ]; + fonts.packages = with pkgs; [ + fira-code + fira-code-symbols + nerdfonts + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + noto-fonts-monochrome-emoji + source-sans-pro + twemoji-color-font + font-awesome + ]; +} diff --git a/system/hardware.nix b/system/hardware.nix new file mode 100644 index 0000000..7332a07 --- /dev/null +++ b/system/hardware.nix @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: +{ + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + hardware.ckb-next.enable = true; + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + hardware.pulseaudio.enable = false; +} diff --git a/system/programs.nix b/system/programs.nix new file mode 100644 index 0000000..c6fc877 --- /dev/null +++ b/system/programs.nix @@ -0,0 +1,45 @@ +{ config, pkgs, ... }: { + + programs.zsh.enable = true; + programs.steam = { + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + }; + programs.gnupg.agent = { + enable = true; + pinentryFlavor = "curses"; + enableSSHSupport = true; + }; + environment.systemPackages = with pkgs; [ + steam-run + xdg-utils + xdg-desktop-portal + xdg-desktop-portal-gtk + unstable.zoom-us + neovim + git + gnupg + pinentry-rofi + pinentry + rofi-rbw-x11 + rbw + nil + nixpkgs-fmt + ]; + systemd = { + user.services.polkit-gnome-authentication-agent-1 = { + description = "polkit-gnome-authentication-agent-1"; + wantedBy = [ "graphical-session.target" ]; + wants = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; + }; + }; +} diff --git a/system/security.nix b/system/security.nix new file mode 100644 index 0000000..5f0fc90 --- /dev/null +++ b/system/security.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: { + # Enable sudo + security.sudo = { + enable = true; + wheelNeedsPassword = false; + }; +} diff --git a/system/services.nix b/system/services.nix new file mode 100644 index 0000000..a9fef01 --- /dev/null +++ b/system/services.nix @@ -0,0 +1,45 @@ +{ config, pkgs, ... }: { + + sound.enable = true; + security.rtkit.enable = true; + networking.firewall.enable = false; + security.polkit.enable = true; + services = { + xserver = { + enable = true; + layout = "us"; + xkbVariant = ""; + desktopManager = { + xterm.enable = false; + }; + videoDrivers = [ "nvidia" ]; + displayManager = { + defaultSession = "none+i3"; + autoLogin.enable = true; + autoLogin.user = "mbeno"; + }; + + windowManager.i3 = { + enable = true; + extraPackages = with pkgs; [ + dmenu #application launcher most people use + i3status # gives you the default i3 status bar + i3lock #default i3 screen locker + i3blocks #if you are planning on using i3blocks over i3status + polybar + rofi + picom + nitrogen + ]; + }; + }; + }; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + services.pcscd.enable = true; + services.dbus.packages = [ pkgs.gcr ]; +} diff --git a/system/users.nix b/system/users.nix new file mode 100644 index 0000000..11294f8 --- /dev/null +++ b/system/users.nix @@ -0,0 +1,29 @@ +{ config, pkgs, ... }: { + + users.defaultUserShell = pkgs.zsh; + users.users.mbeno = { + shell = pkgs.zsh; + isNormalUser = true; + description = "Martin"; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + packages = with pkgs; [ + firefox + alacritty + mumble + zoom + mattermost-desktop + # thunderbird + ]; + }; + security.sudo.extraRules = [ + { + users = [ "mbeno" ]; + commands = [ + { + command = "ALL"; + options = [ "NOPASSWD" ]; # "SETENV" # Adding the following could be a good idea + } + ]; + } + ]; +} diff --git a/user/default.nix b/user/default.nix new file mode 100644 index 0000000..11d0e5f --- /dev/null +++ b/user/default.nix @@ -0,0 +1,35 @@ +{ pkgs, inputs, user, ... }: { + imports = [ inputs.home-manager.nixosModules.home-manager ]; + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + extraSpecialArgs = { inherit pkgs inputs user; }; + users.${user} = { pkgs, ... }: { + imports = [ + inputs.sops-nix.homeManagerModules.sops + ./sops + ./programs/neovim + ./programs/firefox + ./programs/tmux + ./programs/dunst + ./programs/kitty + ./programs/rofi + ./programs/obs-studio + ./programs/vscode + ./scripts + ./zsh + ./packages + ./ssh + ]; + firefox.enable = true; + tmux.enable = true; + hyprland.enable = true; + home = { + username = "${user}"; + homeDirectory = "/home/${user}"; + stateVersion = "23.11"; + }; + programs.home-manager.enable = true; + }; + }; +} diff --git a/user/packages/default.nix b/user/packages/default.nix new file mode 100644 index 0000000..eeab285 --- /dev/null +++ b/user/packages/default.nix @@ -0,0 +1,79 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ + # Generic tools + age + alacritty + unstable.btop + bzip2 + croc + easyeffects + fd + ffmpeg + file + go-task + glib + jq + kitty + kubectl + ncdu + nwg-look + mumble + mpv + pamixer + pinentry + pre-commit + pulseaudio + pulsemixer + rbw + restic + ripgrep + rofi-rbw-wayland + sops + spotify + spicetify-cli + sshfs + unstable.ventoy + + # k8s tools + unstable.talosctl + unstable.k9s + unstable.cilium-cli + unstable.kubernetes-helm + unstable.cmctl + unstable.krew + + # steam + # steam-run + # steamcmd + # gamescope + tokei + unzip + yt-dlp + unstable.zoom-us + unstable.vmware-horizon-client + + # Editors + # vscode + + # Go stuff + go + delve + gopls + + # js/ts + nodejs + nodePackages.pnpm + typescript + + # Py stuff + (unstable.python312.withPackages (p: with p; [ + requests + ])) + poetry + ruff + + # Rust + rustup + + ]; +} diff --git a/user/programs/dunst/default.nix b/user/programs/dunst/default.nix new file mode 100644 index 0000000..b90b005 --- /dev/null +++ b/user/programs/dunst/default.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +{ + services.dunst = { + enable = true; + iconTheme = { + name = "Papirus-Dark"; + package = pkgs.papirus-icon-theme; + }; + settings = { + global = { + rounded = "yes"; + origin = "top-right"; + monitor = "3"; + alignment = "left"; + vertical_alignment = "center"; + width = "400"; + height = "400"; + scale = 0; + gap_size = 0; + progress_bar = true; + transparency = 0; + text_icon_padding = 0; + separator_color = "frame"; + sort = "yes"; + idle_threshold = 120; + line_height = 0; + markup = "full"; + show_age_threshold = 60; + ellipsize = "middle"; + ignore_newline = "no"; + stack_duplicates = true; + sticky_history = "yes"; + history_length = 20; + always_run_script = true; + corner_radius = 10; + # follow = "mouse"; + font = "Source Sans Pro 10"; + format = "%s\\n%b"; #format = "%s %p\n%b" + frame_color = "#232323"; + frame_width = 1; + offset = "15x15"; + horizontal_padding = 10; + icon_position = "left"; + indicate_hidden = "yes"; + min_icon_size = 0; + max_icon_size = 64; + mouse_left_click = "do_action, close_current"; + mouse_middle_click = "close_current"; + mouse_right_click = "close_all"; + padding = 10; + plain_text = "no"; + separator_height = 2; + show_indicators = "yes"; + shrink = "no"; + word_wrap = "yes"; + browser = "/usr/bin/env firefox -new-tab"; + }; + + fullscreen_delay_everything = { fullscreen = "delay"; }; + + urgency_critical = { + background = "#d64e4e"; + foreground = "#f0e0e0"; + }; + urgency_low = { + background = "#232323"; + foreground = "#2596be"; + }; + urgency_normal = { + background = "#1e1e2a"; + foreground = "#2596be"; + }; + }; + }; +} diff --git a/user/programs/firefox/default.nix b/user/programs/firefox/default.nix new file mode 100644 index 0000000..e6d3445 --- /dev/null +++ b/user/programs/firefox/default.nix @@ -0,0 +1,6 @@ +{ pkgs, config, lib, inputs, user, ... }: { + options.firefox.enable = lib.mkEnableOption "Firefox"; + + config = + lib.mkIf config.firefox.enable { programs.firefox = { enable = true; }; }; +} diff --git a/user/programs/neovim/default.nix b/user/programs/neovim/default.nix new file mode 100644 index 0000000..e382622 --- /dev/null +++ b/user/programs/neovim/default.nix @@ -0,0 +1,58 @@ +{ pkgs, ... }: { + programs = { + neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + plugins = with pkgs.vimPlugins; [ + vim-fugitive + undotree + telescope-nvim + nvim-cmp + cmp-nvim-lsp + nvim-lspconfig + lsp-zero-nvim + vim-floaterm + luasnip + cmp_luasnip + lualine-nvim + vim-sleuth + copilot-lua + copilot-cmp + cmp-cmdline + cmp-buffer + catppuccin-nvim + (nvim-treesitter.withPlugins (p: [ + p.tree-sitter-yaml + p.tree-sitter-nix + p.tree-sitter-go + p.tree-sitter-lua + p.tree-sitter-vim + p.tree-sitter-bash + p.tree-sitter-json + p.tree-sitter-python + ])) + ]; + extraLuaConfig = '' + ${builtins.readFile ./options.lua} + ${builtins.readFile ./plugins.lua} + ${builtins.readFile ./keybinds.lua} + ''; + }; + }; + home.packages = with pkgs; [ + # nix stuff + nixpkgs-fmt + statix + + # LSPs + gopls + nodePackages.pyright + nodePackages.typescript-language-server + nodePackages.typescript + nil + yaml-language-server + lua-language-server + ]; + home.sessionVariables.EDITOR = "nvim"; +} diff --git a/user/programs/neovim/keybinds.lua b/user/programs/neovim/keybinds.lua new file mode 100644 index 0000000..19562e9 --- /dev/null +++ b/user/programs/neovim/keybinds.lua @@ -0,0 +1,31 @@ +-- Keybinds + +-- Term +vim.g.floaterm_keymap_toggle = 'ft' + +-- Tabs +vim.keymap.set('n', 'n', ':tabnew', + { silent = true, desc = '[N]ew tab' }) +vim.keymap.set('n', 'p', ':tabnext', + { silent = true, desc = '[p]Next tab' }) +vim.keymap.set('n', 'P', ':tabprev', + { silent = true, desc = '[P]Previous tab' }) + +-- Telescope +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, + { desc = '[?] FInd recently opened files' }) +vim.keymap.set('n', 'ff', require('telescope.builtin').find_files, + { desc = '[F]ind [F]iles' }) +vim.keymap.set('n', 'ff', require('telescope.builtin').find_files, + { desc = '[F]ind [F]iles' }) +vim.keymap.set('n', 'fg', require('telescope.builtin').live_grep, + { desc = '[F]ind by [G]rep' }) + +-- Tabs +vim.keymap.set('n', 'tt', ':tabnew') +vim.keymap.set('n', 'tn', ':tabnext') +vim.keymap.set('n', 'tp', ':tabprevious') + +-- LSP +vim.keymap.set('n', 'gD', vim.lsp.buf.declaration) +vim.keymap.set('n', 'gd', vim.lsp.buf.definition) diff --git a/user/programs/neovim/options.lua b/user/programs/neovim/options.lua new file mode 100644 index 0000000..f43e875 --- /dev/null +++ b/user/programs/neovim/options.lua @@ -0,0 +1,13 @@ +-- Options +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +vim.opt.cursorline = true +vim.opt.scrolloff = 15 +vim.opt.wrap = true +vim.o.number = true +vim.o.relativenumber = true + +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true diff --git a/user/programs/neovim/plugins.lua b/user/programs/neovim/plugins.lua new file mode 100644 index 0000000..bcae021 --- /dev/null +++ b/user/programs/neovim/plugins.lua @@ -0,0 +1,245 @@ +-- Plugins + +-- LSP stuff +local lsp_zero = require('lsp-zero') + + +lsp_zero.on_attach(function(_, bufnr) + lsp_zero.default_keymaps({ buffer = bufnr }) +end) + +lsp_zero.format_on_save({ + format_opts = { + async = false, + timeout_ms = 10000, + }, + servers = { + ['gopls'] = { 'go' }, + ['nil_ls'] = { 'nix' }, + ['lua_ls'] = { 'lua' }, + ['tsserver'] = { 'typescript', 'javascript' }, + }, +}) +-- LSP: go +local lspconfig = require('lspconfig') +lspconfig.gopls.setup({ + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + } + } +}) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { "source.organizeImports" } } + -- buf_request_sync defaults to a 1000ms timeout. Depending on your + -- machine and codebase, you may want longer. Add an additional + -- argument after params if you find that you have to write the file + -- twice for changes to be saved. + -- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000) + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format({ async = false }) + end +}) + +-- LSP: nix +lspconfig.nil_ls.setup({ + autostart = true, + settings = { + ['nil'] = { + formatting = { + command = { "nixpkgs-fmt" }, + }, + }, + }, +}) + +-- LSP: lua +lspconfig.lua_ls.setup({ + on_init = function(client) + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then + return + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = { + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = "2", + } + } + } + } +}) + +-- LSP: ts/js +lspconfig.tsserver.setup({ + init_options = { + plugins = { + }, + }, + filetypes = { + "typescript", + "javascript", + }, +}) + + +-- Telescope +require('telescope').setup({ + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + } + }, +}) + +-- Tresitter stuff +require('nvim-treesitter.configs').setup { + ensure_installed = {}, + auto_install = false, + highlight = { enable = true }, + indent = { enable = true }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + } + } + } +} + +-- Lualine +require('lualine').setup({ + options = { + icons_enabled = false, + component_separators = '|', + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { + { + 'filename', + file_status = true, + newfile_status = true, + path = 3, + shorting_target = 30, + symbols = { + modified = '[+]', + readonly = '[-]', + unnamed = '[No name]', + newfile = '[New]' + } + } + }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + } +}) + +-- Copilot +require('copilot').setup({ + suggestions = { enabled = false }, + panel = { enabled = false }, +}) +require('copilot_cmp').setup() + +-- Cmp +local cmp = require('cmp') +local cmp_action = lsp_zero.cmp_action() + +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + -- Enter to confirm completion + [''] = cmp.mapping.confirm({ select = false }), + -- Ctrl+Space to open completion menu + [''] = cmp.mapping.complete(), + -- Move between snippet placeholders + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + -- Scroll in completion docs + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + }), + sources = cmp.config.sources({ + }, { + { name = "copilot", group_index = 2 }, + { name = "nvim_lsp", group_index = 2 }, + -- { name = "luasnip" }, + -- { name = "buffer" }, + }) +}) + + +-- Colorscheme +require('catppuccin').setup({ +}) +vim.cmd.colorscheme "catppuccin" diff --git a/user/programs/obs-studio/default.nix b/user/programs/obs-studio/default.nix new file mode 100644 index 0000000..c7ba16e --- /dev/null +++ b/user/programs/obs-studio/default.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: +# let +# obs-backgroundremoval_1_1_10 = (pkgs.obs-studio-plugins.obs-backgroundremoval.overrideAttrs { +# version = "1.1.10"; +# src = pkgs.fetchFromGitHub { +# owner = "occ-ai"; +# repo = "obs-backgroundremoval"; +# rev = "1.1.10"; +# hash = "sha256-6OTtmjXS3fiorEPUSjjqrS8u9fVJnnZZoD722W3JQO8="; +# }; +# }).override { +# onnxruntime = pkgs.unstable.onnxruntime; +# }; +# in +{ + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + obs-backgroundremoval + ]; + #plugins = [ obs-backgroundremoval_1_1_10 ]; + }; +} diff --git a/user/programs/rofi/config.rasi b/user/programs/rofi/config.rasi new file mode 100644 index 0000000..f4c53ed --- /dev/null +++ b/user/programs/rofi/config.rasi @@ -0,0 +1,17 @@ +configuration{ + modi: "run,drun,window"; + icon-theme: "Oranchelo"; + show-icons: true; + terminal: "alacritty"; + drun-display-format: "{icon} {name}"; + location: 0; + disable-history: false; + hide-scrollbar: true; + display-drun: "  Apps "; + display-run: "  Run "; + display-window: " 﩯 Window"; + display-Network: " 󰤨 Network"; + sidebar-mode: true; +} + +@theme "latte" diff --git a/user/programs/rofi/default.nix b/user/programs/rofi/default.nix new file mode 100644 index 0000000..33860c3 --- /dev/null +++ b/user/programs/rofi/default.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: { + xdg.configFile."rofi/config.rasi" = { + source = ./config.rasi; + }; + + xdg.configFile."rofi/macchiato.rasi" = { + source = pkgs.fetchFromGitHub + { + owner = "catppuccin"; + repo = "rofi"; + rev = "5350da41a11814f950c3354f090b90d4674a95ce"; + sha256 = "DNorfyl3C4RBclF2KDgwvQQwixpTwSRu7fIvihPN8JY="; + } + "/basic/.local/share/rofi/themes/catppuccin-macchiato.rasi"; + }; + xdg.configFile."rofi/latte.rasi" = { + source = pkgs.fetchFromGitHub + { + owner = "catppuccin"; + repo = "rofi"; + rev = "5350da41a11814f950c3354f090b90d4674a95ce"; + sha256 = "DNorfyl3C4RBclF2KDgwvQQwixpTwSRu7fIvihPN8JY="; + } + "/basic/.local/share/rofi/themes/catppuccin-latte.rasi"; + }; +} diff --git a/user/programs/tmux/default.nix b/user/programs/tmux/default.nix new file mode 100644 index 0000000..fdb2647 --- /dev/null +++ b/user/programs/tmux/default.nix @@ -0,0 +1,13 @@ +{ pkgs, lib, config, ... }: +with lib; +let cfg = config.tmux.enable; +in { + options.tmux.enable = mkEnableOption "tmux"; + config = mkIf cfg { + programs.tmux = { + enable = true; + prefix = "C-a"; + terminal = "screen-256color"; + }; + }; +} diff --git a/user/programs/vscode/default.nix b/user/programs/vscode/default.nix new file mode 100644 index 0000000..276d916 --- /dev/null +++ b/user/programs/vscode/default.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + programs.vscode = { + enable = true; + enableUpdateCheck = true; + enableExtensionUpdateCheck = true; + extensions = with pkgs.vscode-extensions; [ + catppuccin.catppuccin-vsc + catppuccin.catppuccin-vsc-icons + golang.go + vscodevim.vim + ms-python.python + ms-vscode-remote.remote-ssh + bbenoist.nix + ]; + userSettings = { + "window.titleBarStyle" = "custom"; + }; + }; +} diff --git a/user/scripts/default.nix b/user/scripts/default.nix new file mode 100644 index 0000000..f8026cf --- /dev/null +++ b/user/scripts/default.nix @@ -0,0 +1,6 @@ +{ pkgs, config, ... }: { + home.file.".local/bin/rofi-launcher" = { + source = ./rofi-launcher.sh; + executable = true; + }; +} diff --git a/user/scripts/rofi-launcher.sh b/user/scripts/rofi-launcher.sh new file mode 100644 index 0000000..cc0ff0d --- /dev/null +++ b/user/scripts/rofi-launcher.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +rofi \ + -show drun \ + -modi run,drun,ssh \ + -scroll-method 0 \ + -drun-match-fields all \ + -drun-display-format "{name}" \ + -terminal alacritty diff --git a/user/sops/default.nix b/user/sops/default.nix new file mode 100644 index 0000000..1a212ff --- /dev/null +++ b/user/sops/default.nix @@ -0,0 +1,6 @@ +{ user, ... }: { + sops = { + age.keyFile = "/home/${user}/.config/sops/age/keys.txt"; + defaultSopsFile = ../../secrets/${user}/secret.yaml; + }; +} diff --git a/user/ssh/default.nix b/user/ssh/default.nix new file mode 100644 index 0000000..e2202b9 --- /dev/null +++ b/user/ssh/default.nix @@ -0,0 +1 @@ +{ imports = [ ./zedd.nix ]; } diff --git a/user/ssh/zedd.nix b/user/ssh/zedd.nix new file mode 100644 index 0000000..847b0da --- /dev/null +++ b/user/ssh/zedd.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + programs.ssh = { + enable = true; + controlMaster = "auto"; + + matchBlocks."dresden.uio.no" = { + setEnv = { + TERM = "xterm-256color"; + }; + hostname = "dresden.uio.no"; + forwardAgent = false; + proxyJump = "mbeno@rlogin.uio.no"; + }; + }; +} diff --git a/user/zsh/default.nix b/user/zsh/default.nix new file mode 100644 index 0000000..1623b2b --- /dev/null +++ b/user/zsh/default.nix @@ -0,0 +1,30 @@ +{ user, pkgs, ... }: { + home.packages = with pkgs; [ fd ]; + programs.zsh = { + enable = true; + autocd = false; + enableAutosuggestions = true; + enableCompletion = true; + syntaxHighlighting.enable = true; + shellAliases = { + nrebuild = "sudo nixos-rebuild switch --flake /home/${user}/nixos"; + }; + initExtra = '' + bindkey -v + bindkey '^R' history-incremental-search-backward + + # Prompt stuff + autoload -Uz promptinit + promptinit + prompt pure + export PATH="''${KREW_ROOT:-$HOME/.krew}/bin:$PATH" + ''; + zplug = { + enable = true; + plugins = [ + ({ name = "plugins/git"; tags = [ "from:oh-my-zsh" ]; }) + ({ name = "modules/prompt"; tags = [ "from:prezto" ]; }) + ]; + }; + }; +}