From 490c894796ea5613ae6e0d98c7714a75ff4726e1 Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Sat, 13 May 2023 19:09:08 -0700 Subject: [PATCH] updates to nixos --- home/bin/executable_rbw-get | 4 +- home/dot_zshrc | 5 + provision/nixos/flake.lock | 30 +-- .../nixos/hosts/kestrel/configuration.nix | 227 ++++-------------- provision/nixos/hosts/kestrel/hardware.nix | 33 ++- .../hosts/kestrel/home-configuration.nix | 29 ++- provision/nixos/modules/default.nix | 2 +- provision/nixos/modules/gaming/default.nix | 5 + provision/nixos/modules/gaming/steam.nix | 26 ++ provision/nixos/modules/stow.nix | 27 --- 10 files changed, 129 insertions(+), 259 deletions(-) create mode 100644 provision/nixos/modules/gaming/default.nix create mode 100644 provision/nixos/modules/gaming/steam.nix delete mode 100644 provision/nixos/modules/stow.nix diff --git a/home/bin/executable_rbw-get b/home/bin/executable_rbw-get index a9f9c396..fb5eaefb 100644 --- a/home/bin/executable_rbw-get +++ b/home/bin/executable_rbw-get @@ -1,5 +1,5 @@ -#!/bin/bash - +#!/usr/bin/env bash +# # rbw-get # Ex: rbw-get google url diff --git a/home/dot_zshrc b/home/dot_zshrc index e46bbab6..4fec68ef 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -108,6 +108,11 @@ export EDITOR=nvim # users are encouraged to define aliases within the ZSH_CUSTOM folder. # For a full list of active aliases, run `alias`. # +# + +alias nixos-update='cd ~/.local/share/chezmoi/provision/nixos && \ + sudo nixos-rebuild switch --flake .#$(hostname) && \ + cd -' alias ssway='export WLR_NO_HARDWARE_CURSORS=1 && sway --unsupported-gpu' alias s='startx' diff --git a/provision/nixos/flake.lock b/provision/nixos/flake.lock index 8eb74708..4d0bbc30 100644 --- a/provision/nixos/flake.lock +++ b/provision/nixos/flake.lock @@ -4,15 +4,14 @@ "inputs": { "nixpkgs": [ "nixpkgs" - ], - "utils": "utils" + ] }, "locked": { - "lastModified": 1668332334, - "narHash": "sha256-YT1qcE/MCqBO1Bi/Yr6GcFpNKsvmzrBKh8juyXDbxQc=", + "lastModified": 1683989410, + "narHash": "sha256-puF/QsIkp4ch0sf6M5mNzbdZtYcq2MJHcKre9wJ3ZYo=", "owner": "nix-community", "repo": "home-manager", - "rev": "bc90de24d898655542589237cc0a6ada7564cb6c", + "rev": "6702b22b9805bc1879715d4111e3764cd4237aed", "type": "github" }, "original": { @@ -23,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668417584, - "narHash": "sha256-yeuEyxKPwsm5fIHN49L/syn9g5coxnPp3GsVquhrv5A=", + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "013fcdd106823416918004bb684c3c186d3c460f", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", "type": "github" }, "original": { @@ -42,21 +41,6 @@ "home-manager": "home-manager", "nixpkgs": "nixpkgs" } - }, - "utils": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } } }, "root": "root", diff --git a/provision/nixos/hosts/kestrel/configuration.nix b/provision/nixos/hosts/kestrel/configuration.nix index b7c6aa01..8b3431b1 100644 --- a/provision/nixos/hosts/kestrel/configuration.nix +++ b/provision/nixos/hosts/kestrel/configuration.nix @@ -1,11 +1,6 @@ -# 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, user, lib, ... }: { nix = { - # Flakes! package = pkgs.nixFlakes; extraOptions = "experimental-features = nix-command flakes"; @@ -17,168 +12,39 @@ }; }; + # Add non-free packages + nixpkgs.config.allowUnfree = true; + # Use zen kernel boot.kernelPackages = pkgs.linuxPackages_zen; + # Hardware options hardware.bluetooth.enable = true; hardware.sensor.iio.enable = true; - services.blueman.enable = true; + hardware.opengl.enable = true; + hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "kestrel"; # 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. + # Set networking options + networking.hostName = "kestrel"; + networking.networkmanager.enable = true; # Set your time zone. time.timeZone = "America/Los_Angeles"; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. i18n.defaultLocale = "en_US.UTF-8"; - programs.seahorse.enable = lib.mkForce false; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - }; - programs.ssh.askPassword = ""; - - services.xserver = { enable = true; layout = "us"; - #displayManager.lightdm.greeters.mini = { - # enable = true; - # user = "${user}"; - # extraConfig = '' - # # LightDM Mini Greeter Configuration - # # - # # To test your configuration out, run: lightdm --test-mode - # - # [greeter] - # # The user to login as. - # user = tstarr - # # Whether to show the password input's label. - # show-password-label = true - # # The text of the password input's label. - # password-label-text = Password: - # # The text shown when an invalid password is entered. May be blank. - # invalid-password-text = Invalid Password - # # Show a blinking cursor in the password input. - # show-input-cursor = true - # # The text alignment for the password input. Possible values are: - # # "left", "center", or "right" - # password-alignment = right - # # The number of characters that should fit into the password input. - # # A value of -1 will use GTK's default width. - # # Note: The entered width is a suggestion, GTK may render a narrower input. - # password-input-width = -1 - # # Show the background image on all monitors or just the primary monitor. - # show-image-on-all-monitors = false - # # Show system info above the password input. - # # `@` is shown on the left side, & current time on the right. - # show-sys-info = false - # - # - # [greeter-hotkeys] - # # The modifier key used to trigger hotkeys. Possible values are: - # # "alt", "control" or "meta" - # # meta is also known as the "Windows"/"Super" key - # mod-key = meta - # # Power management shortcuts (single-key, case-sensitive) - # shutdown-key = s - # restart-key = r - # hibernate-key = h - # suspend-key = u - # # Cycle through available sessions - # session-key = e - # - # - # [greeter-theme] - # # A color from X11's `rgb.txt` file, a quoted hex string(`"#rrggbb"`) or a - # # RGB color(`rgb(r,g,b)`) are all acceptable formats. - # - # # The font to use for all text - # font = "Sans" - # # The font size to use for all text - # font-size = 1em - # # The font weight to use for all text - # font-weight = bold - # # The font style to use for all text - # font-style = normal - # # The default text color - # text-color = "#080800" - # # The color of the error text - # error-color = "#F8F8F0" - # # An absolute path to an optional background image. - # # Note: The file should be somewhere that LightDM has permissions to read - # # (e.g., /etc/lightdm/). - # background-image = "" - # # Background image size: - # # auto: unscaled - # # cover: scale image to fill screen space - # # contain: scale image to fit inside screen space - # # (more options: https://www.w3.org/TR/css-backgrounds-3/#background-size) - # background-image-size = auto - # # The screen's background color. - # background-color = "#1B1D1E" - # # The password window's background color - # window-color = "#F92672" - # # The color of the password window's border - # border-color = "#080800" - # # The width of the password window's border. - # # A trailing `px` is required. - # border-width = 2px - # # The pixels of empty space around the password input. - # # Do not include a trailing `px`. - # layout-space = 15 - # # The character used to mask your password. Possible values are: - # # "-1", "0", or a single unicode character(including emojis) - # # A value of -1 uses the default bullet & 0 displays no characters when you - # # type your password. - # password-character = -1 - # # The color of the text in the password input. - # password-color = "#F8F8F0" - # # The background color of the password input. - # password-background-color = "#1B1D1E" - # # The color of the password input's border. - # # Falls back to `border-color` if missing. - # password-border-color = "#080800" - # # The width of the password input's border. - # # Falls back to `border-width` if missing. - # password-border-width = 2px - # # The border radius of the password input. - # password-border-radius = 0.341125em - # # Override font for system info - # # Falls back to `font` if missing. - # sys-info-font = "Mono" - # # Set font size of system info - # # Falls back to `font-size` if missing. - # sys-info-font-size = 0.8em - # # Override color for system info text - # # Falls back to `text-color` if missing. - # #sys-info-color = "#080800" - # # Margins around the system info section - # # The default `-5px -5px -5px` works well with the password label enabled. - # # If you have the label disabled, you might want to try `-5px -5px 0px` - # sys-info-margin = -5px -5px -5px - # ''; - # }; desktopManager.xterm.enable = false; # Use nvidia drivers - videoDrivers = [ "nvidia" ]; - screenSection = '' - Option "metamodes" "DP-4: 2560x1440_144 +2560+0, HDMI-0: 2560x1440_144 +0+0" - ''; + videoDrivers = [ "amdgpu" ]; displayManager.gdm.enable = true; desktopManager.gnome.enable = true; @@ -192,45 +58,16 @@ }; }; - - hardware.opengl.enable = true; - - # Enable CUPS to print documents. - services.printing.enable = true; - services.printing.drivers = [ pkgs.hplip ]; - services.avahi.enable = true; - services.avahi.nssmdns = true; - # Enable sound. sound.enable = true; hardware.pulseaudio.enable = true; hardware.pulseaudio.support32Bit = true; - # Add non-free packages - nixpkgs.config.allowUnfree = true; - - + # Add fonts fonts.fonts = with pkgs; [ nerdfonts ]; - services = { - # USB automount - gvfs.enable = true; - - # File sync - syncthing = { - enable = true; - user = "tstarr"; - dataDir = "/home/tstarr/sync"; - configDir = "/home/tstarr/.config/syncthing"; - }; - }; - - programs.steam = { - enable = true; - }; - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.${user} = { isNormalUser = true; @@ -256,25 +93,41 @@ autokey gnome-extension-manager gnome.gnome-tweaks + pinentry-curses + zsh + ripgrep ]; + # Enable user services + services = { + gvfs.enable = true; # USB automount + blueman.enable = true; + printing.enable = true; + printing.drivers = [ pkgs.hplip ]; + avahi.enable = true; + avahi.nssmdns = true; + syncthing = { + enable = true; + user = "tstarr"; + dataDir = "/home/tstarr/sync"; + configDir = "/home/tstarr/.config/syncthing"; + }; + }; + + # Enable the OpenSSH daemon. services.openssh.enable = true; - - system.stateVersion = "22.05"; # Did you read the comment? - - programs.bash.shellAliases = { - # Nix rebuild and switch - nr = "cd ~/.setup && sudo nixos-rebuild switch --flake .# && cd -"; - sd = "cd ~/.setup/local/stow && stow . -t /home/${user} --no-folding && cd -"; + services.pcscd.enable = true; + programs.gnupg.agent = { + enable = true; + pinentryFlavor = "curses"; + enableSSHSupport = true; }; - virtualisation.docker.enable = true; imports = [ ../../modules ]; modules = { - stow.enable = true; services = { samba.enable = true; vfio.enable = true; @@ -283,8 +136,10 @@ python.enable = true; engineering.enable = true; }; - editors = { - emacs.enable = true; + gaming = { + steam.enable = true; }; }; + + system.stateVersion = "22.11"; # Did you read the comment? } diff --git a/provision/nixos/hosts/kestrel/hardware.nix b/provision/nixos/hosts/kestrel/hardware.nix index d4c01470..a371f3c8 100644 --- a/provision/nixos/hosts/kestrel/hardware.nix +++ b/provision/nixos/hosts/kestrel/hardware.nix @@ -14,29 +14,43 @@ boot.extraModulePackages = [ ]; fileSystems."/" = - { device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb"; + { device = "/dev/sda2"; fsType = "btrfs"; - options = [ "subvol=root" "compress=zstd" ]; + options = [ "subvol=root" ]; }; fileSystems."/home" = - { device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb"; + { device = "/dev/sda2"; fsType = "btrfs"; - options = [ "subvol=home" "compress=zstd" ]; + options = [ "subvol=home" ]; }; fileSystems."/nix" = - { device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb"; + { device = "/dev/sda2"; fsType = "btrfs"; - options = [ "subvol=nix" "noatime" "compress=zstd" ]; + options = [ "subvol=nix" ]; + }; + + fileSystems."/persist" = + { device = "/dev/sda2"; + fsType = "btrfs"; + options = [ "subvol=persist" ]; + }; + + fileSystems."/var/log" = + { device = "/dev/sda2"; + fsType = "btrfs"; + options = [ "subvol=log" ]; }; fileSystems."/boot" = - { device = "/dev/disk/by-uuid/9AEE-2BD0"; + { device = "/dev/disk/by-uuid/0A89-7181"; fsType = "vfat"; }; - swapDevices = [ ]; + swapDevices = + [ { device = "/dev/disk/by-uuid/b62ff9a9-37ed-494a-9805-9f148aff4b9c"; } + ]; # 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 @@ -45,7 +59,6 @@ networking.useDHCP = lib.mkDefault true; # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - # high-resolution display - hardware.video.hidpi.enable = lib.mkDefault true; } diff --git a/provision/nixos/hosts/kestrel/home-configuration.nix b/provision/nixos/hosts/kestrel/home-configuration.nix index ad91ac1b..e445ee73 100644 --- a/provision/nixos/hosts/kestrel/home-configuration.nix +++ b/provision/nixos/hosts/kestrel/home-configuration.nix @@ -1,21 +1,27 @@ { config, pkgs, user, ... }: - { - home.username = "${user}"; home.homeDirectory = "/home/${user}"; - - home.stateVersion = "22.05"; - programs.home-manager.enable = true; - programs.vscode = { - enable = true; - package = pkgs.vscode.fhsWithPackages (ps: with ps; [ ]); + # Enable user services + services = { + gvfs.enable = true; # USB automount + blueman.enable = true; + printing.enable = true; + printing.drivers = [ pkgs.hplip ]; + #avahi.enable = true; + #avahi.nssmdns = true; + syncthing = { + enable = true; + user = "tstarr"; + dataDir = "/home/tstarr/sync"; + configDir = "/home/tstarr/.config/syncthing"; + }; }; home.packages = with pkgs; [ - brave + firefox rofi alacritty gamemode @@ -29,6 +35,9 @@ gruvbox-dark-gtk gruvbox-dark-icons-gtk libreoffice-fresh + chezmoi + rbw + vscodium.fhs ]; gtk = { @@ -38,5 +47,5 @@ }; }; - + home.stateVersion = "22.11"; } diff --git a/provision/nixos/modules/default.nix b/provision/nixos/modules/default.nix index 676d7607..c58029f5 100644 --- a/provision/nixos/modules/default.nix +++ b/provision/nixos/modules/default.nix @@ -1,5 +1,5 @@ { ... }: { - imports = [ ./devel ./services ./editors ./stow.nix ]; + imports = [ ./gaming ./devel ./services ./editors ]; } diff --git a/provision/nixos/modules/gaming/default.nix b/provision/nixos/modules/gaming/default.nix new file mode 100644 index 00000000..bbc73b38 --- /dev/null +++ b/provision/nixos/modules/gaming/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./steam.nix ]; +} diff --git a/provision/nixos/modules/gaming/steam.nix b/provision/nixos/modules/gaming/steam.nix new file mode 100644 index 00000000..b70a346c --- /dev/null +++ b/provision/nixos/modules/gaming/steam.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.steam; +in { + options.programs.steam.enable = mkEnableOption "steam"; + + config = mkIf cfg.enable { + hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: + https://github.com/NixOS/nixpkgs/issues/47932 + enable = true; + driSupport32Bit = true; + }; + + # optionally enable 32bit pulseaudio support if pulseaudio is enabled + hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable; + + hardware.steam-hardware.enable = true; + + environment.systemPackages = [ pkgs.steam ]; + }; + + meta.maintainers = with maintainers; [ mkg20001 ]; +} diff --git a/provision/nixos/modules/stow.nix b/provision/nixos/modules/stow.nix deleted file mode 100644 index b7ac2fd8..00000000 --- a/provision/nixos/modules/stow.nix +++ /dev/null @@ -1,27 +0,0 @@ -# stow config files for great sanity! - -{ config, lib, pkgs, user, ... }: - -let cfg = config.modules.stow; -in { - options.modules.stow.enable = lib.mkEnableOption "stow"; - config = lib.mkIf cfg.enable { - - # Install packages - environment.systemPackages = with pkgs; [ stow ]; - - # Run script that checks the .stow-on-rebuild file - # if it is 1 then it will re-stow else it won't - # this is to aviod the slow stow on every rebuild - system.userActivationScripts = { - stowDots = '' - if [ -f "/home/${user}/.stow-on-rebuild" ]; then - if [ $(cat "/home/${user}/.stow-on-rebuild") -eq 1 ]; then - cd "/home/${user}/.setup/local/stow" - ${pkgs.stow}/bin/stow . -t "/home/${user}" --no-folding - fi - fi - ''; - }; - }; -}