From 5fca9d16c08f7b3d3cb53aa763dad0a9ce312509 Mon Sep 17 00:00:00 2001 From: sadan <117494111+sadan4@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:19:34 -0400 Subject: [PATCH] more refactoring --- boxes/desktop/configuration.nix | 55 ++++++------------------------ common/programs/git.nix | 0 common/systemModules/boot.nix | 14 ++++++++ common/systemModules/crypt.nix | 22 ++++++++++++ common/systemModules/gaming.nix | 15 ++++++++ common/systemModules/nixHelper.nix | 12 +++++++ common/systemModules/printing.nix | 13 +++++++ common/systemModules/razer.nix | 8 +++++ common/systemModules/tailscale.nix | 7 ++++ common/users/homeModules/java.nix | 8 +++++ common/users/meyer/default.nix | 2 ++ common/users/meyer/git.nix | 35 +++++++++++++++++++ common/users/meyer/home.nix | 50 +++++++++------------------ 13 files changed, 163 insertions(+), 78 deletions(-) delete mode 100644 common/programs/git.nix create mode 100644 common/systemModules/boot.nix create mode 100644 common/systemModules/crypt.nix create mode 100644 common/systemModules/gaming.nix create mode 100644 common/systemModules/nixHelper.nix create mode 100644 common/systemModules/printing.nix create mode 100644 common/systemModules/razer.nix create mode 100644 common/systemModules/tailscale.nix create mode 100644 common/users/homeModules/java.nix create mode 100644 common/users/meyer/git.nix diff --git a/boxes/desktop/configuration.nix b/boxes/desktop/configuration.nix index c7fd6e9..a48d660 100644 --- a/boxes/desktop/configuration.nix +++ b/boxes/desktop/configuration.nix @@ -2,66 +2,42 @@ # 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, inputs, ... }: +{ pkgs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ../../common/systemModules/boot.nix ../../common/systemModules/audio.nix ../../common/systemModules/kde.nix + ../../common/systemModules/tailscale.nix + ../../common/systemModules/gaming.nix + ../../common/systemModules/crypt.nix + ../../common/systemModules/printing.nix + # USERS ../../common/users/meyer ]; - # Use the systemd-boot EFI boot loader. - boot.loader.grub.device = "nodev"; - boot.kernelPackages = pkgs.linuxPackages_latest; - boot.loader.grub.efiSupport = true; - boot.loader.grub.useOSProber = true; - boot.loader.grub.efiInstallAsRemovable = true; # boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; - # add user to "openrazer" group - hardware.openrazer.enable = true; - hardware.openrazer.users = [ "meyer" ]; hardware.i2c.enable = true; - hardware.xpadneo.enable = true; hardware.amdgpu.opencl.enable = true; + services.xserver.videoDrivers = [ "amdgpu" ]; hardware.bluetooth.enable = true; - services.tailscale.enable = true; networking.hostName = "nix-desktop-evo4b5"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # Set your time zone. time.timeZone = "America/New_York"; - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # useXkbConfig = true; # use xkb.options in tty. - - # }; + nixpkgs.config.allowUnfree = true; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; services = { teamviewer.enable = true; - avahi.enable = true; usbmuxd.enable = true; }; - services.xserver.videoDrivers = [ "amdgpu" ]; - services.printing.enable = true; - services.printing.drivers = with pkgs; [ - hplip - ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; programs.zsh.enable = true; - programs.steam.enable = true; - programs.steam.extraCompatPackages = with pkgs; [ - proton-ge-bin - ]; - nixpkgs.config.allowUnfree = true; @@ -77,10 +53,6 @@ wget ripgrep tldr - gnupg - openssh - pinentry-curses - pinentry libnotify file ]; @@ -116,13 +88,6 @@ mimalloc libstdcxx5 ]; - programs.ssh.startAgent = true; - programs.ssh.askPassword = pkgs.lib.mkForce "${pkgs.ksshaskpass.out}/bin/ksshaskpass"; - - programs.gnupg.agent = { - enable = true; - pinentryPackage = pkgs.pinentry-gnome3; - }; # 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. diff --git a/common/programs/git.nix b/common/programs/git.nix deleted file mode 100644 index e69de29..0000000 diff --git a/common/systemModules/boot.nix b/common/systemModules/boot.nix new file mode 100644 index 0000000..a435894 --- /dev/null +++ b/common/systemModules/boot.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: { + boot = { + loader = { + grub = { + enable = true; + device = "nodev"; + efiSupport = true; + useOSProber = true; + efiInstallAsRemovable = true; + }; + }; + kernelPackages = pkgs.linuxPackages_latest; + }; +} diff --git a/common/systemModules/crypt.nix b/common/systemModules/crypt.nix new file mode 100644 index 0000000..f50ca4a --- /dev/null +++ b/common/systemModules/crypt.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: { + environment = { + systemPackages = with pkgs; [ + gnupg + openssh + pinentry-curses + pinentry + ]; + }; + programs = { + ssh = { + startAgent = true; + askPassword = "${pkgs.ksshaskpass}/bin/ksshaskpass"; + }; + gnupg = { + agent = { + enable = true; + pinentryPackage = pkgs.pinentry-gnome3; + }; + }; + }; +} diff --git a/common/systemModules/gaming.nix b/common/systemModules/gaming.nix new file mode 100644 index 0000000..8235d6d --- /dev/null +++ b/common/systemModules/gaming.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + hardware = { + xpadneo = { + enable = true; + }; + }; + programs = { + steam = { + enable = true; + extraCompatPackages = with pkgs; [ + proton-ge-bin + ]; + }; + }; +} diff --git a/common/systemModules/nixHelper.nix b/common/systemModules/nixHelper.nix new file mode 100644 index 0000000..cd32cbe --- /dev/null +++ b/common/systemModules/nixHelper.nix @@ -0,0 +1,12 @@ +{ NAME }: { ... }: { + programs = { + nh = { + enable = true; + clean = { + enable = true; + extraArgs = "--keep-since 4d --keep 3"; + }; + flake = "/home/${NAME}/nixos" + }; + }; +} diff --git a/common/systemModules/printing.nix b/common/systemModules/printing.nix new file mode 100644 index 0000000..aedd2c0 --- /dev/null +++ b/common/systemModules/printing.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: { + services = { + avahi = { + enable = true; + }; + printing = { + enable = true; + drivers = with pkgs; [ + hplip + ]; + }; + }; +} diff --git a/common/systemModules/razer.nix b/common/systemModules/razer.nix new file mode 100644 index 0000000..71890e2 --- /dev/null +++ b/common/systemModules/razer.nix @@ -0,0 +1,8 @@ +{ NAME }: { ... }: { + hardware = { + openrazer = { + enable = true; + users = [ NAME ]; + }; + }; +} diff --git a/common/systemModules/tailscale.nix b/common/systemModules/tailscale.nix new file mode 100644 index 0000000..7cfe3e6 --- /dev/null +++ b/common/systemModules/tailscale.nix @@ -0,0 +1,7 @@ +{ ... }: { + services = { + tailscale = { + enable = true; + }; + }; +} diff --git a/common/users/homeModules/java.nix b/common/users/homeModules/java.nix new file mode 100644 index 0000000..03664b6 --- /dev/null +++ b/common/users/homeModules/java.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + programs = { + java = { + enable = true; + package = pkgs.temurin-bin-17; + }; + }; +} diff --git a/common/users/meyer/default.nix b/common/users/meyer/default.nix index d5daff4..c71d2ac 100644 --- a/common/users/meyer/default.nix +++ b/common/users/meyer/default.nix @@ -7,6 +7,8 @@ in (import ../../systemModules/networkManager.nix { inherit NAME; }) (import ../../systemModules/sops.nix { inherit NAME; }) (import ../../systemModules/vm.nix { inherit NAME; }) + (import ../../systemModules/razer.nix { inherit NAME; }) + (import ../../systemModules/nixHelper.nix { inherit NAME; }) (import ../../programs/wireshark.nix { inherit NAME; }) ]; users = { diff --git a/common/users/meyer/git.nix b/common/users/meyer/git.nix new file mode 100644 index 0000000..3cd28c4 --- /dev/null +++ b/common/users/meyer/git.nix @@ -0,0 +1,35 @@ +{ ... }: { + programs = { + git = { + enable = true; + userName = "sadan"; + userEmail = "117494111+sadan4@users.noreply.github.com"; + extraConfig = { + gpg = { + format = "ssh"; + }; + user = { + signingkey = "~/.ssh/id_ed25519"; + }; + commit = { + gpgsign = true; + }; + core = { + autocrlf = "input"; + }; + pull = { + rebase = true; + }; + push = { + autoSetupRemote = true; + }; + init = { + defaultBranch = "main"; + }; + rerere = { + enabled = true; + }; + }; + }; + }; +} diff --git a/common/users/meyer/home.nix b/common/users/meyer/home.nix index dc2a6cf..7967982 100644 --- a/common/users/meyer/home.nix +++ b/common/users/meyer/home.nix @@ -1,39 +1,24 @@ -{ config, pkgs, inputs, ... }: +{ config, pkgs, ... }: let - files = import ../../files.nix { inherit config; }; + file = import ../../files.nix { inherit config; }; shell = import ../../shell.nix { inherit config pkgs; }; pkgTypes = import ../../pkgs.nix { inherit pkgs config; }; packages = pkgTypes.dev ++ pkgTypes.gui ++ pkgTypes.general ++ pkgTypes.scripts ++ pkgTypes.gaming; in { nixpkgs.config.allowInsecurePredicate = (pkg: true); + nixpkgs.config.allowUnfreePredicate = (pkg: true); imports = [ ../homeModules/flameshot.nix ../homeModules/arrpc.nix ../homeModules/zsh.nix ../homeModules/desktopEntries.nix + ../homeModules/java.nix ./sops.nix + ./git.nix ]; - programs.java.enable = true; - programs.java.package = pkgs.temurin-bin-17; - programs.git.enable = true; - programs.git.userName = "sadan"; - programs.git.userEmail = "117494111+sadan4@users.noreply.github.com"; - programs.git.extraConfig = { - gpg.format = "ssh"; - user = { - signingkey = "~/.ssh/id_ed25519"; - }; - commit.gpgsign = true; - core.autocrlf = "input"; - pull.rebase = true; - push.autoSetupRemote = true; - init.defaultBranch = "main"; - rerere.enabled = true; - }; - nixpkgs.config.allowUnfreePredicate = (pkg: true); # Home Manager needs a bit of information about you and the paths it should # nixpkg.config.allowUnfree = true; # manage. @@ -41,22 +26,16 @@ in home.homeDirectory = "/home/meyer"; - # This value determines the Home Manager release that your configuration is - # compatible with. This helps avoid breakage when a new Home Manager release - # introduces backwards incompatible changes. - # - # You should not change this value, even if you update Home Manager. If you do - # want to update the value, then make sure to first check the Home Manager - # release notes. - home.stateVersion = "23.11"; # Please read the comment before changing. # The home.packages option allows you to install Nix packages into your # environment. home = { - inherit packages; + inherit packages file; }; + home.shellAliases = shell.dev.aliases; + home.sessionPath = shell.dev.path; + home.sessionVariables = shell.dev.env; # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. - home.file = files; # Home Manager can also manage your environment variables through # 'home.sessionVariables'. If you don't want to manage your shell through Home @@ -73,10 +52,15 @@ in # # /etc/profiles/per-user/meyer/etc/profile.d/hm-session-vars.sh # - home.shellAliases = shell.dev.aliases; - home.sessionPath = shell.dev.path; - home.sessionVariables = shell.dev.env; + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.11"; # Please read the comment before changing. # Let Home Manager install and manage itself. programs.home-manager.enable = true; }