diff --git a/flake.nix b/flake.nix index fb637b8..28c30ff 100644 --- a/flake.nix +++ b/flake.nix @@ -44,8 +44,15 @@ ./src/system/machines/desktop home-manager.nixosModules.home-manager (import ./src/system/machines/desktop/modules/home-manager) - #disko.nixosModules.disko - # (import ./src/system/machines/desktop/modules/disko) + ]; + }; + + workstation = nixpkgs.lib.nixosSystem { + inherit system pkgs; + modules = [ + ./src/system/machines/workstation + home-manager.nixosModules.home-manager + (import ./src/system/machines/workstation/modules/home-manager) ]; }; @@ -81,11 +88,6 @@ }; }; - homeConfigurations."work" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ ./src/system/machines/workstation ]; - }; - devShells.${system}.default = mkShell { name = "devShell"; packages = [ diff --git a/src/system/machines/workstation/default.nix b/src/system/machines/workstation/default.nix index f68b744..6e64b71 100644 --- a/src/system/machines/workstation/default.nix +++ b/src/system/machines/workstation/default.nix @@ -1 +1,9 @@ -{ imports = [ ./home.nix ]; } +{ ... }: + +{ + imports = [ + ../../../user/config + ./hardware.nix + ./system.nix + ]; +} diff --git a/src/system/machines/workstation/hardware.nix b/src/system/machines/workstation/hardware.nix new file mode 100644 index 0000000..5362c9f --- /dev/null +++ b/src/system/machines/workstation/hardware.nix @@ -0,0 +1,73 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot = { + initrd = { + availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + kernelModules = [ "dm-snapshot" ]; + }; + extraModulePackages = [ ]; + kernelPackages = pkgs.linuxPackages_zen; + kernelParams = [ "intel_iommu=on" ]; + kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ]; + }; + + environment.systemPackages = with pkgs; [ + linuxHeaders + +# vulkan-headers +# vulkan-loader +# vulkan-tools +# vulkan-extension-layer +# glxinfo +# mesa + + #cudaPackages.cudatoolkit + #cudaPackages.cudnn + ]; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/6e964c61-ea77-48cc-b495-6a8516b8e756"; + fsType = "xfs"; + }; + + "/home" = { + device = "/dev/disk/by-uuid/db504fb8-14f8-4292-b745-32d6255c4893"; + fsType = "xfs"; + }; + + "/boot" = { + device = "/dev/disk/by-uuid/61E7-6E56"; + fsType = "vfat"; + }; + }; + + hardware = { + cpu = { + intel = { + updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; + }; + nvidia = { + open = true; + modesetting.enable = true; + }; + graphics = { + enable = true; + }; + }; + + virtualisation.libvirtd = { + enable = true; + qemu = { + runAsRoot = true; + ovmf.enable = true; + }; + }; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; +} diff --git a/src/system/machines/workstation/home.nix b/src/system/machines/workstation/home.nix deleted file mode 100644 index 01b3534..0000000 --- a/src/system/machines/workstation/home.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ ./user ]; - - programs.home-manager.enable = true; - - home = { - stateVersion = "23.11"; - username = "${config.user.name}"; - homeDirectory = "/home/${config.user.name}"; - - file.".config/home-manager" = { - source = ../../../..; - recursive = true; - }; - }; - - nix = { - package = pkgs.nixVersions.stable; - extraOptions = "experimental-features = nix-command flakes"; - settings = { - auto-optimise-store = true; - trusted-users = [ "${config.user.name}" ]; - }; - }; - - user = { - bash.enable = true; - git.enable = true; - - security= { - gpg.enable = true; - }; - - gui = { - alacritty.enable = true; - browsers.enable = true; - neovim.enable = true; - }; - - utils = { - enable = true; - dev.enable = true; - email.enable = true; - irc.enable = true; - vim.enable = true; - }; - }; - - programs.bash = { - initExtra = - import ./scripts/guiControl - ; - }; -} diff --git a/src/system/machines/workstation/modules/disko/default.nix b/src/system/machines/workstation/modules/disko/default.nix new file mode 100644 index 0000000..5bf5734 --- /dev/null +++ b/src/system/machines/workstation/modules/disko/default.nix @@ -0,0 +1,72 @@ +let + dev = "/dev/disk/by-id/ata-CT2000MX500SSD1_2137E5D2D47D"; + +in +{ + disko.devices = { + disk = { + one = { + type = "disk"; + device = dev; + content = { + type = "table"; + format = "gpt"; + partitions = { + boot = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + primary = { + size = "100%"; + content = { + type = "lvm_pv"; + vg = "nix"; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + nix = { + type = "lvm_vg"; + lvs = { + aaa = { + size = "1M"; + }; + zzz = { + size = "1M"; + }; + root = { + size = "252G"; + content = { + name = "root"; + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + home = { + size = "100%FREE"; + content = { + name = "home"; + type = "filesystem"; + format = "ext4"; + mountpoint = "/home"; + }; + }; + }; + }; + }; + }; +} diff --git a/src/system/machines/workstation/modules/home-manager/default.nix b/src/system/machines/workstation/modules/home-manager/default.nix new file mode 100644 index 0000000..86de83f --- /dev/null +++ b/src/system/machines/workstation/modules/home-manager/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./home.nix + ]; +} diff --git a/src/system/machines/workstation/modules/home-manager/home.nix b/src/system/machines/workstation/modules/home-manager/home.nix new file mode 100644 index 0000000..8a737a1 --- /dev/null +++ b/src/system/machines/workstation/modules/home-manager/home.nix @@ -0,0 +1,54 @@ +{ config, ... }: + +{ + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${config.user.name} = { + imports = [ ../../../../../user ]; + + programs.home-manager.enable = true; + + home.stateVersion = "23.11"; + + home.username = "${config.user.name}"; + home.homeDirectory = "/home/${config.user.name}"; + + modules = { + user = { + bash.enable = true; + git.enable = true; + + security = { + enable = true; + gpg.enable = true; + }; + + tmux.enable = true; + + utils = { + enable = true; + dev = { + enable = true; + }; + irc.enable = true; + neovim.enable = true; + vim.enable = false; + }; + + gui = { + wm.sway.enable = true; + + browser = { + firefox.enable = true; + }; + + alacritty.enable = true; + corn.enable = true; + fun.enable = true; + utils.enable = true; + writing.enable = true; + }; + }; + }; + }; +} diff --git a/src/system/machines/workstation/scripts/guiControl.nix b/src/system/machines/workstation/scripts/guiControl.nix deleted file mode 100644 index 02f33bb..0000000 --- a/src/system/machines/workstation/scripts/guiControl.nix +++ /dev/null @@ -1,17 +0,0 @@ -'' -function ui() { - case $1 in - on) - sudo systemctl set-default graphical.target - sudo systemctl start graphical.target - ;; - off) - sudo systemctl set-default multi-user.target - sudo systemctl isolate multi-user.target - ;; - *) - echo "Usage: $0 {on|off}" - ;; - esac -} -'' diff --git a/src/system/machines/workstation/system.nix b/src/system/machines/workstation/system.nix new file mode 100644 index 0000000..9811041 --- /dev/null +++ b/src/system/machines/workstation/system.nix @@ -0,0 +1,118 @@ +{ pkgs, lib, config, ... }: + +{ system.stateVersion = "23.11"; + + users.users = { + ${config.user.name} = { + isNormalUser = true; + extraGroups = config.user.groups + ++ [ "video" "audio" "kvm" "libvirtd" "dialout" ]; + openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.android}" ]; + }; + }; + + nix = { + channel.enable = false; + package = pkgs.nixVersions.stable; + extraOptions = '' + experimental-features = nix-command flakes + keep-going = true + ''; + settings = { + auto-optimise-store = true; + trusted-users = [ "${config.user.name}" ]; + substitute = true; + max-jobs = "auto"; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + boot.loader = { + systemd-boot = { + enable = true; + configurationLimit = 5; + memtest86.enable = true; + }; + + efi = { + canTouchEfiVariables = true; + }; + timeout = null; + }; + + environment.systemPackages = with pkgs; [ + vim + git + usbutils + ]; + + fonts.packages = with pkgs; [ + terminus_font + terminus-nerdfont + ]; + + security = { + sudo = { + wheelNeedsPassword = false; + execWheelOnly = true; + }; + polkit.enable = true; + }; + + time = { + timeZone = "America/New_York"; + hardwareClockInLocalTime = true; + }; + + i18n.defaultLocale = "en_US.UTF-8"; + + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; + }; + + networking = { + hostName = "workstation"; + useDHCP = lib.mkDefault true; + networkmanager.enable = true; + firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 ]; + }; + }; + + services = { + timesyncd = lib.mkDefault { + enable = true; + servers = [ + "0.pool.ntp.org" + "1.pool.ntp.org" + "2.pool.ntp.org" + "3.pool.ntp.org" + ]; + }; + pipewire = { + enable = true; + audio.enable = true; + + wireplumber.enable = true; + + pulse.enable = true; + jack.enable = true; + alsa.enable = true; + alsa.support32Bit = true; + }; + openssh = { + enable = true; + startWhenNeeded = false; + settings = { + X11Forwarding = false; + PasswordAuthentication = true; + }; + }; + }; +} diff --git a/src/system/machines/workstation/user b/src/system/machines/workstation/user deleted file mode 120000 index 0b7ce2d..0000000 --- a/src/system/machines/workstation/user +++ /dev/null @@ -1 +0,0 @@ -../../../user/ \ No newline at end of file diff --git a/src/user/modules/gui/wm/hyprland/default.nix b/src/user/modules/gui/wm/hyprland/default.nix index 5ae5cc0..e4e23cf 100644 --- a/src/user/modules/gui/wm/hyprland/default.nix +++ b/src/user/modules/gui/wm/hyprland/default.nix @@ -22,8 +22,9 @@ in "$menu" = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; monitor = [ - "HDMI-A-1, 1920x1080, 0x0, 1" - "DP-1, 1920x1080, 1920x0, 1" + "DP-2, 3440x1440, 0x0, 1" + #"HDMI-A-1, 1920x1080, 0x0, 1" + #"DP-1, 1920x1080, 1920x0, 1" ]; exec-once = [ diff --git a/src/user/modules/gui/wm/sway/default.nix b/src/user/modules/gui/wm/sway/default.nix index 1046119..bbbadac 100644 --- a/src/user/modules/gui/wm/sway/default.nix +++ b/src/user/modules/gui/wm/sway/default.nix @@ -23,21 +23,23 @@ in ''; config = { + defaultWorkspace = "workspace number 1"; + fonts = { names = [ "Terminus" ]; }; output = { - HDMI-A-1 = { - resolution = "1920x1080"; + #HDMI-A-1 = { + # resolution = "1920x1080"; + # position = "0,0"; + # bg = "${wallpaper} fill"; + #}; + DP-2 = { + resolution = "3440x1440@59.973Hz"; position = "0,0"; bg = "${wallpaper} fill"; }; - DP-1 = { - resolution = "1920x1080"; - position = "1920,0"; - bg = "${wallpaper} fill"; - }; }; modifier = "Mod1"; menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'"; @@ -60,7 +62,7 @@ in statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done''; fonts = { names = [ "Terminus" ]; - size = 10.0; + size = 12.0; }; colors = { background = "#0A0E14"; @@ -92,7 +94,7 @@ in keybindings = lib.mkOptionDefault { "${modifier}+q" = "kill"; "Print" = "exec grim ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; - "Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; + "${modifier}+Shift+Print" = "exec grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png"; "${modifier}+Print" = ''exec sh -c 'grim -g "$(swaymsg -t get_tree | jq -j '"'"'.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'"'"')" ~/Pictures/screenshot-$(date +'%Y%m%d-%H%M%S').png' ''; "${modifier}+Shift+f" = "exec alacritty -e sh -c 'EDITOR=nvim ranger'"; "${modifier}+Shift+d" = "exec rofi -modi emoji -show emoji"; @@ -100,7 +102,7 @@ in }; extraConfig = '' - exec_always ${pkgs.autotiling}/bin/autotiling + exec_always ${pkgs.autotiling}/bin/autotiling --limit 2 ''; };