diff --git a/flake.nix b/flake.nix index 70b3550..da21285 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,7 @@ ]; }; desktop = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; + specialArgs = { inherit inputs; cfg = defaultCfg; }; modules = [ hyprland.nixosModules.default ./hosts/desktop/configuration.nix diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 8d07eee..34e9396 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, inputs, ... }: +{ cfg, config, lib, pkgs, inputs, ... }: { imports = [ @@ -6,17 +6,34 @@ inputs.home-manager.nixosModules.default ]; - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.plymouth.enable = true; + boot = { + loader.systemd-boot.enable = true; + loader.efi.canTouchEfiVariables = true; + plymouth.enable = true; + }; networking = { + hostName = "lm_desktop"; + networkmanager = { enable = true; wifi.backend = "iwd"; }; - hostName = "nixos-desktop"; - firewall.enable = false; + + firewall = { + enable = true; + + # Open ports in the firewall. + allowedTCPPorts = [ 21 22 80 443 4070 5037 ]; + allowedUDPPorts = [ 4070 ]; + + allowedTCPPortRanges = [ + { from = 8000; to = 8010; } + ]; + + allowPing = true; + }; + wireless.iwd = { enable = true; settings = { @@ -24,14 +41,6 @@ Settings.Autoconnect = true; }; }; - - # Configure network proxy if necessary - # proxy.default = "http://user:password@proxy:port/"; - # proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; }; time.timeZone = "Europe/Dublin"; @@ -53,7 +62,14 @@ }; services = { - libinput.enable = true; + avahi = { + enable = true; + nssmdns4 = true; + publish = { + enable = true; + userServices = true; + }; + }; greetd = { enable = true; @@ -63,16 +79,22 @@ command = "${pkgs.greetd.tuigreet}/bin/tuigreet --cmd Hyprland"; }; }; - }; - - xserver.videoDrivers = [ "nvidia" ]; + + udev = { + packages = [ pkgs.android-udev-rules ]; + }; + + libinput.enable = true; blueman.enable = true; gvfs.enable = true; auto-cpufreq.enable = true; + thermald.enable = true; power-profiles-daemon.enable = false; pulseaudio.enable = false; + + xserver.videoDrivers = [ "nvidia" ]; }; security.pam.services.hyprlock = {}; @@ -85,8 +107,6 @@ bluetooth.enable = true; graphics = { enable = true; - extraPackages = with pkgs;[ - ]; }; nvidia = { modesetting.enable = true; @@ -96,24 +116,31 @@ }; }; - fonts.packages = with pkgs; [ - noto-fonts - noto-fonts-cjk-sans - noto-fonts-cjk-serif - noto-fonts-emoji - liberation_ttf - fira-code-symbols - mplus-outline-fonts.githubRelease - dina-font - nerd-fonts.fira-code - nerd-fonts.droid-sans-mono - ]; + fonts = { + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk-sans + noto-fonts-cjk-serif + noto-fonts-emoji + liberation_ttf + fira-code-symbols + mplus-outline-fonts.githubRelease + dina-font + nerd-fonts.fira-code + nerd-fonts.droid-sans-mono + ]; + + fontconfig = { + enable = true; + includeUserConf = true; + }; + }; nixpkgs.config.allowUnfree = true; nix.settings = { - substituters = ["https://hyprland.cachix.org"]; - trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; + substituters = [ "https://hyprland.cachix.org" ]; + trusted-public-keys = [ "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; trusted-users = [ "root" "@wheel" ]; allowed-users = [ "root" "@wheel" ]; }; @@ -123,6 +150,7 @@ dates = "weekly"; options = "--delete-older-than 10d"; }; + nix.optimise = { automatic = true; dates = [ "00:00" ]; @@ -135,44 +163,65 @@ }; programs = { - dconf.enable = true; steam = { enable = true; remotePlay.openFirewall = true; dedicatedServer.openFirewall = true; }; - nix-ld.enable = true; - mtr.enable = true; + hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + portalPackage = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland; + xwayland.enable = true; + withUWSM = true; + plugins = [ ]; + }; + gnupg.agent = { enable = true; enableSSHSupport = true; }; + + hyprlock.enable = true; + dconf.enable = true; + nix-ld.enable = true; + mtr.enable = true; }; + lib.inputMethod.fcitx5.waylandFrontend = true; + home-manager = { useGlobalPkgs = true; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { inherit inputs; inherit cfg; }; users = { "liamm" = import ./home.nix; }; + backupFileExtension = ".bak"; }; environment.systemPackages = with pkgs; [ - vim - fd - file - ripgrep - wget - glib - spotify + alacritty + bat discord discord-canary - wl-clipboard - alacritty + fd + file + glib + gnome-keyring + libdrm libnotify mesa - libdrm + neovim + ripgrep + spotify + unzip + usbutils + uxplay + vim + wget + wl-clipboard + zip ]; zramSwap = { diff --git a/hosts/desktop/file.nix b/hosts/desktop/file.nix new file mode 100644 index 0000000..e520d82 --- /dev/null +++ b/hosts/desktop/file.nix @@ -0,0 +1,67 @@ +{ cfg, config, context, pkgs, ... }: + +let + inherit (config.home) username homeDirectory; + + mkSymlinkAttrs = import ../../utils/mkSymlinkAttrs.nix { + inherit pkgs; + inherit (cfg) context runtimeRoot; + hm = config.lib; # same as: cfg.context.inputs.home-manager.lib.hm; + }; + +in +{ + # Symlink dotfiles + home.file = mkSymlinkAttrs { + # Fonts + ".local/share/fonts/KelmscottMono.otf" = { + source = ../../fonts/KelmscottMono.otf; + outOfStoreSymlink = true; + recursive = false; + }; + + # Configs + ".config/hypr" = { + source = ../../configs/hypr; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/waybar" = { + source = ../../configs/waybar; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/ghostty" = { + source = ../../configs/ghostty; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/nvim" = { + source = ../../configs/nvim; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/wofi" = { + source = ../../configs/wofi; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/swaync" = { + source = ../../configs/swaync; + outOfStoreSymlink = true; + recursive = true; + }; + ".config/fastfetch" = { + source = ../../configs/fastfetch; + outOfStoreSymlink = true; + recursive = true; + }; + + # I have no idea why this is an issue... + # ".config/emacs" = { + # source = ../../configs/emacs; + # outOfStoreSymlink = true; + # recursive = true; + # }; + }; +} diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index 7a566d1..5428043 100644 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -1,19 +1,27 @@ -{ config, pkgs, lib, callPackage, inputs, ... }: +{ + cfg, + config, + pkgs, + lib, + callPackage, + inputs, + ... +}: { home.username = "liamm"; home.homeDirectory = "/home/liamm"; - imports = [ - # general modules - ../../modules/home-manager/dunst.nix - ../../modules/home-manager/tmux.nix - ../../modules/home-manager/fastfetch.nix - ../../modules/home-manager/terminals/alacritty.nix + home.username = cfg.username; + home.homeDirectory = cfg.homeDirectory; - # desktop - ../../modules/desktop/bluetooth.nix - ../../modules/desktop/hyprland-desktop.nix + imports = [ + ./file.nix # config file out-of-store links + ./pkgs.nix # system pkgs + ./services.nix # system services + + # general modules + ../../modules/home-manager/tmux.nix ]; # You should not change this value, even if you update Home Manager. If you do @@ -21,65 +29,11 @@ # release notes. home.stateVersion = "24.11"; # Please read the comment before changing. - nixpkgs.config.allowUnfree = true; - home.packages = with pkgs; [ - audacity - android-studio - brave - brightnessctl - btop - emacs-all-the-icons-fonts - emacsPackages.pdf-tools - exfatprogs - filezilla - firefox - floorp - genymotion - ghostty - gimp - gnome-keyring - gtk4 - gvfs - grim - grimblast - htop - imagemagick - kdePackages.kdenlive - keepassxc - libsForQt5.polkit-kde-agent - localsend - mpv - nautilus - networkmanagerapplet - nvtopPackages.full - nwg-look - openvpn - pamixer - pavucontrol - powertop - praat - prismlauncher - protonvpn-cli - protonvpn-gui - qbittorrent - signal-desktop - swww - texliveFull - tree - unzip - wev - wl-clipboard - xdg-user-dirs - zip - zoom-us - ]; - - home.file = {}; - home.sessionVariables = { EDITOR = "emacsclient"; GIT_EDITOR = "nvim"; NIX_SHELL_PRESERVE_PROMPT = 1; + NIX_CONFIG_DIR = "${cfg.homeDirectory}/personal/nixos"; }; nix.settings.extra-trusted-substituters = [ @@ -87,9 +41,6 @@ ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - # THEMING ## QT SECTION @@ -118,131 +69,17 @@ # ENV SETTINGS - - fonts.fontconfig = { - enable = true; - }; - xdg.enable = true; xdg.configFile = { "emacs" = { recursive = true; source = ../../modules/non-nix_configs/emacs; }; - "ghostty" = { - recursive = true; - source = ../../modules/non-nix_configs/ghostty; - }; - "kitty" = { - recursive = true; - source = ../../modules/non-nix_configs/kitty; - }; - "nvim" = { - recursive = true; - source = ../../modules/non-nix_configs/nvim; - }; - "wofi" = { - recursive = true; - source = ../../modules/non-nix_configs/wofi; - }; + "user-dirs.dirs".source = ../../modules/non-nix_configs/user-dirs.dirs; "user-dirs.locale".source = ../../modules/non-nix_configs/user-dirs.locale; }; - # BEGIN PROGRAMS - programs = { - bash = { - enable = true; - enableCompletion = true; - enableVteIntegration = true; - initExtra ='' - if [[ -z $ORIG_SHLVL ]]; then - export ORIG_SHLVL=$SHLVL - fi; - if [[ $SHLVL -gt $ORIG_SHLVL ]]; then - export PS1='\[\e[1;m\e[1;33m\e[1;m\] ($(($SHLVL - $ORIG_SHLVL))) \W\[\e[m\e[m\] 🐧 \[\e[1;32m\]~> \[\e[m\e[m\]' - else - export PS1='\[\e[1;m\e[1;33m\e[1;m\] \W\[\e[m\e[m\] 🐧 \[\e[1;32m\]~> \[\e[m\e[m\]' - fi; - set -o vi - fastfetch - ''; - shellAliases = { - build = "./build.sh"; - emacsd = "emacs --daemon"; - emacsc = "emacsclient -c -a 'emacs'"; - gap = "git add -p"; - gcp = "git commit -p"; - kpx = "keepassxc-cli open"; - ls = "ls --color=auto"; - ll = "ls -l"; - la = "ls -lA"; - nixrebuild = "nixos-rebuild build --flake ~/personal/nixos#desktop && sudo nixos-rebuild switch --flake ~/personal/nixos#desktop"; - nixbuild = "sudo nixos-rebuild switch --flake"; - nixtest = "sudo nixos-rebuild test --flake"; - new = "source $HOME/.bashrc"; - newbar = "pkill waybar; waybar &disown"; - ping = "ping -c 5"; - vi = "\\vim"; - work = "nix develop --impure"; - ".." = "cd .."; - }; - }; - emacs = { - enable = true; - package = pkgs.emacs-gtk; - extraPackages = epkgs: [ - epkgs.pdf-tools - epkgs.org-pdftools - ]; - }; - feh.enable = true; - git = { - enable = true; - lfs.enable = true; - diff-so-fancy.enable = true; - userEmail = "maloneliam@proton.me"; - userName = "Liam Malone"; - }; - neovim = { - enable = true; - package = pkgs.neovim-unwrapped; - vimAlias = true; - vimdiffAlias = true; - }; - obs-studio = { - enable = true; - }; - wofi.enable = true; - }; - - - # BEGIN SERVICES - services = { - blueman-applet.enable = true; - network-manager-applet.enable = true; - - emacs = { - enable = true; - package = pkgs.emacs-gtk; - client = { - enable = true; - arguments = [ - "-c" - "-a emacs" - ]; - }; - startWithUserSession = "graphical"; - }; - - gnome-keyring.enable = true; - - gpg-agent = { - enable = true; - defaultCacheTtl = 1800; - enableSshSupport = true; - }; - - nextcloud-client.enable = true; - }; + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; } diff --git a/hosts/desktop/pkgs.nix b/hosts/desktop/pkgs.nix new file mode 100644 index 0000000..f096cb4 --- /dev/null +++ b/hosts/desktop/pkgs.nix @@ -0,0 +1,128 @@ +{ + pkgs, + ... +}: + +{ + # BEGIN PACKAGES + home.packages = with pkgs; [ + audacity + android-studio + bat + brave + brightnessctl + btop + emacs-all-the-icons-fonts + emacsPackages.pdf-tools + exfatprogs + fastfetch + filezilla + floorp + fzf + genymotion + gimp + gtk4 + gvfs + grimblast + htop + hyprpicker + imagemagick + kdePackages.kdenlive + keepassxc + libsForQt5.polkit-kde-agent + localsend + mpv + mupdf + nautilus + networkmanagerapplet + networkmanager_dmenu + nwg-look + openvpn + overskride + pamixer + pavucontrol + powertop + prismlauncher + protonvpn-cli + pywal + qbittorrent + signal-desktop + swaynotificationcenter + swww + texliveFull + xfce.thunar + xfce.thunar-volman + tree + waybar + wev + ]; + + # BEGIN PROGRAMS + programs = { + bash = { + enable = true; + enableCompletion = true; + enableVteIntegration = true; + initExtra ='' + if [[ -z $ORIG_SHLVL ]]; then + export ORIG_SHLVL=$SHLVL + fi; + if [[ $SHLVL -gt $ORIG_SHLVL ]]; then + export PS1='\[\e[1;m\e[1;33m\e[1;m\] ($(($SHLVL - $ORIG_SHLVL))) \W\[\e[m\e[m\] 🐧 \[\e[1;32m\]~> \[\e[m\e[m\]' + else + export PS1='\[\e[1;m\e[1;33m\e[1;m\] \W\[\e[m\e[m\] 🐧 \[\e[1;32m\]~> \[\e[m\e[m\]' + fi; + set -o vi + fastfetch + ''; + shellAliases = { + build = "./build.sh"; + emacsd = "emacs --daemon"; + emacsc = "emacsclient -c -a 'emacs'"; + gap = "git add -p"; + gcp = "git commit -p"; + kpx = "keepassxc-cli open"; + ls = "ls --color=auto"; + ll = "ls -l"; + la = "ls -lA"; + fastfetch = "fastfetch -c $HOME/.config/fastfetch/config.json"; + nixrebuild = "nixos-rebuild build --flake ~/personal/nixos#darp8 && sudo nixos-rebuild switch --flake ~/personal/nixos#darp8"; + nixbuild = "sudo nixos-rebuild switch --flake"; + nixtest = "sudo nixos-rebuild test --flake"; + new = "source $HOME/.bashrc"; + newbar = "pkill waybar; waybar &disown"; + ping = "ping -c 5"; + vi = "\\vim"; + work = "nix develop --impure"; + ".." = "cd .."; + }; + }; + emacs = { + enable = true; + package = pkgs.emacs-gtk; + extraPackages = epkgs: [ + epkgs.pdf-tools + epkgs.org-pdftools + ]; + }; + feh.enable = true; + git = { + enable = true; + lfs.enable = true; + diff-so-fancy.enable = true; + userEmail = "maloneliam@proton.me"; + userName = "Liam Malone"; + }; + neovim = { + enable = true; + package = pkgs.neovim-unwrapped; + vimAlias = true; + vimdiffAlias = true; + }; + obs-studio = { + enable = true; + }; + wofi.enable = true; + }; +} + diff --git a/hosts/desktop/services.nix b/hosts/desktop/services.nix new file mode 100644 index 0000000..844bfd2 --- /dev/null +++ b/hosts/desktop/services.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: + +{ + services = { + emacs = { + enable = true; + package = pkgs.emacs-gtk; + client = { + enable = true; + arguments = [ + "-c" + "-a emacs" + ]; + }; + startWithUserSession = "graphical"; + }; + + gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + }; + + gnome-keyring.enable = true; + mpris-proxy.enable = true; + network-manager-applet.enable = true; + nextcloud-client.enable = true; + swww.enable = true; + }; +}