From a2f3b33514cfec6f697e6a7e76f22a5c71bda75c Mon Sep 17 00:00:00 2001 From: stitchy Date: Wed, 27 Mar 2024 03:47:54 +0000 Subject: [PATCH] complete refactor of packages and options --- configuration.nix | 73 ---------- flake.nix | 16 +-- hosts/default.nix | 48 ++++++- hosts/gemini/default.nix | 3 +- hosts/lappy/default.nix | 13 +- hosts/malachite/default.nix | 7 +- packages/art.nix | 15 -- packages/default.nix | 175 ++++++++++++++++-------- users/default.nix | 10 ++ users/nyadmin/default.nix | 1 + users/stitchynyan/default.nix | 14 +- users/stitchynyan/home.nix | 250 +++++++++++++++++----------------- 12 files changed, 328 insertions(+), 297 deletions(-) delete mode 100644 configuration.nix delete mode 100644 packages/art.nix create mode 100644 users/default.nix diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 6d4b754..0000000 --- a/configuration.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - imports = - [ - ./packages/default.nix - ]; - - # Use the systemd-boot EFI boot loader. - boot.kernelPackages = pkgs.linuxPackages_zen; - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - - security.sudo.wheelNeedsPassword=false; - security.rtkit.enable = true; - - programs.zsh.enable = true; - # Virtualization because I need mah vr back - virtualisation.libvirtd.enable = true; - programs.virt-manager.enable = true; - - - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - defaultEditor = true; - configure = { - customRC = builtins.readFile ./config/nvim/init.vim; - packages.myVimPackage = with pkgs.vimPlugins; { - start = [ - nvim-lspconfig - nvim-cmp - cmp-nvim-lsp - luasnip - cmp_luasnip - tokyonight-nvim - vim-lsp-cxx-highlight - typst-vim - ]; - }; - }; - }; - - boot.kernel.sysctl."kernel.sched_rt_runtime_us" = -1; - - users.mutableUsers = false; - users.users = { - root.initialHashedPassword = "!"; - }; - - networking.firewall = { - enable = true; - # if packets are still dropped, they will show up in dmesg - logReversePathDrops = true; - # wireguard trips rpfilter up - extraCommands = '' - ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 47111 -j RETURN - ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 47111 -j RETURN - ''; - extraStopCommands = '' - ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 47111 -j RETURN || true - ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 47111 -j RETURN || true - ''; - # Open ports in the firewall. - allowedTCPPorts = [ 22000 ]; - allowedUDPPorts = [ 22000 ]; - }; -} diff --git a/flake.nix b/flake.nix index d9e2e12..d0b592b 100644 --- a/flake.nix +++ b/flake.nix @@ -5,8 +5,6 @@ outputs = inputs@{ nixpkgs, home-manager, - hyprland, - eww, osu-nixos, ... } : { @@ -17,7 +15,7 @@ specialArgs = { inherit inputs; }; modules = [ - ./configuration.nix + ./packages/default.nix ./hosts/malachite/default.nix ./users/stitchynyan/default.nix @@ -35,7 +33,7 @@ specialArgs = { inherit inputs; }; modules = [ - ./configuration.nix + ./packages/default.nix ./hosts/lappy/default.nix ./users/stitchynyan/default.nix @@ -53,7 +51,7 @@ specialArgs = { inherit inputs; }; modules = [ - ./configuration.nix + ./packages/default.nix ./hosts/gemini/default.nix ./users/nyadmin/default.nix @@ -70,17 +68,17 @@ }; inputs = { + mobile-nixos = { + url = "github:nixos/mobile-nixos"; + flake = false; + }; nixpkgs = { url = "github:NixOS/nixpkgs/nixos-unstable"; }; - home-manager = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - - hyprland.url = "github:hyprwm/Hyprland"; - eww.url = "github:elkowar/eww"; osu-nixos.url = "github:Asqiir/osu-nixos"; }; } diff --git a/hosts/default.nix b/hosts/default.nix index 5258558..62d4c4c 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,9 +1,55 @@ -{config, pkg, home-manager, ...}: +{ config, lib, pkgs, ... }: +let + # This is a placeholder +in { + options = {}; + imports = [ ../packages/default.nix ]; + config = { + hardware = { + bluetooth.enable = lib.mkDefault false; + steam-hardware.enable = lib.mkDefault false; + }; + boot = { + kernelPackages = lib.mkDefault pkgs.linuxPackages_zen; + loader = { + efi.canTouchEfiVariables = lib.mkDefault true; + systemd-boot.enable = lib.mkDefault true; + }; + }; + security.sudo.wheelNeedsPassword = false; + security.rtkit.enable = true; + services.xserver.displayManager.lightdm.enable = false; + # Wireguard stuff, to-do make better + networking.firewall = { + enable = true; + # if packets are still dropped, they will show up in dmesg + logReversePathDrops = true; + # wireguard trips rpfilter up + extraCommands = '' + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 47111 -j RETURN + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 47111 -j RETURN + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN + ''; + extraStopCommands = '' + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 47111 -j RETURN || true + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 47111 -j RETURN || true + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true + ''; + # Open ports in the firewall. + allowedTCPPorts = [ 22000 ]; + allowedUDPPorts = [ 22000 ]; + }; + + environment.etc.hosts.mode = "0644"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + }; } diff --git a/hosts/gemini/default.nix b/hosts/gemini/default.nix index 4f72861..437f1c5 100644 --- a/hosts/gemini/default.nix +++ b/hosts/gemini/default.nix @@ -6,8 +6,9 @@ { imports = - [ # Include the results of the hardware scan. + [ ./hardware-configuration.nix + ../default.nix ]; networking.hostName = "gemini"; diff --git a/hosts/lappy/default.nix b/hosts/lappy/default.nix index 09513e0..9f9b585 100644 --- a/hosts/lappy/default.nix +++ b/hosts/lappy/default.nix @@ -1,13 +1,17 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { - imports = [ ./hardware-configuration.nix + ../default.nix ]; + stitchyconf = { + artPkgs.enable = true; + }; + system.nixos.tags = [ "Nya_Beginnings" ]; services.logind.powerKey = "ignore"; @@ -41,6 +45,8 @@ "i915.enable_guc=7" ]; + virtualisation.libvirtd.enable = true; + hardware.bluetooth.enable = true; hardware.opengl = { enable = true; driSupport = true; @@ -76,8 +82,7 @@ STOP_CHARGE_THRESH_BAT0 = 90; # 80 and above it stops charging }; -}; - + }; # Read the Docs before Changing system.stateVersion = "23.05"; diff --git a/hosts/malachite/default.nix b/hosts/malachite/default.nix index ecf6ae2..43a3887 100644 --- a/hosts/malachite/default.nix +++ b/hosts/malachite/default.nix @@ -64,12 +64,16 @@ in { imports = [ ./hardware-configuration.nix + ../default.nix ]; virtualisation.libvirtd.hooks.qemu = { passthrough = "${passthrough}"; }; - + virtualisation.libvirtd.enable = true; + hardware = { + steam-hardware.enable = true; + }; networking.hostName = "malachite"; @@ -77,5 +81,4 @@ in { # Read the Docs before Changing system.stateVersion = "23.05"; # Did you read the comment? - } diff --git a/packages/art.nix b/packages/art.nix deleted file mode 100644 index 5429ec9..0000000 --- a/packages/art.nix +++ /dev/null @@ -1,15 +0,0 @@ - -{ pkgs, ... }: { - -environment.systemPackages = with pkgs; [ - blender - krita - #armorpaint - gimp - inkscape - #prusa slicker -]; - - - -} diff --git a/packages/default.nix b/packages/default.nix index 70b8969..ffe07f9 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -1,66 +1,125 @@ +{ config, lib, pkgs, inputs, ... }: -{ pkgs, inputs, ... }: { - - imports = [ - ./art.nix - #./tools.nix - ]; - - environment.systemPackages = with pkgs; [ +let + artPkgs = lib.attrVals [ + #"armorpaint" + "blender" + "gimp" + "inkscape" + "krita" + #"prusa-slicer" + ] pkgs; + handheldPkgs = lib.attrVals [ + "chatty" + "gnome-text-editor" + "megapixels" + ] pkgs; + pcPkgs = lib.attrVals [ #osu-lazer - inputs.osu-nixos - pinentry - wget - python3 - cyrus-sasl-xoauth2 - libnotify - networkmanager-openvpn - eza - fd - git - zoxide - gnupg - brightnessctl - neofetch - wl-clipboard - glib - dracula-theme - btop - vimPlugins.nvim-lspconfig - vimPlugins.nvim-cmp - vimPlugins.cmp-nvim-lsp - vimPlugins.luasnip - vimPlugins.cmp_luasnip - vimPlugins.tokyonight-nvim + "dracula-theme" + "wl-clipboard" + "brightnessctl" + "powertop" + "easyeffects" + "mutt-wizard" + "gamescope" + "cyrus-sasl-xoauth2" + "libnotify" + "networkmanager-openvpn" # temporary home manager things - inotify-tools - eww - jq - socat - libimobiledevice - ifuse - ]; + "inotify-tools" + "eww" + "jq" + "texliveFull" + "pandoc" + "img2pdf" + "socat" + "libimobiledevice" + "ifuse" + ] pkgs ++ [ inputs.osu-nixos pkgs.wineWowPackages.stableFull ]; + serverPkgs = lib.attrVals [ + #"package" + ] pkgs; +in +{ + options = { + stitchyconf = { + form = lib.mkOption { + default = "pc"; + description = "Add moar packages I don't need"; + type = lib.types.enum [ "pc" "handheld" "server" ]; + }; + artPkgs.enable = lib.mkEnableOption "Standard Linux Creative Suite"; + }; + }; - nixpkgs.overlays = [ - (final: prev: { - # Because Luck Smith hasn't released in 2 years - mutt-wizard = prev.mutt-wizard.overrideAttrs (old: { - src = prev.fetchFromGitHub { - owner = "LukeSmithxyz"; - repo = "mutt-wizard"; - rev = "a8863a750a360bad6759f5f2c4df5d2001b31e18"; - hash = "sha256-8zPkzQ1Tt9t8G+uCKybBm4yMqfF2y4L7nmuaWWz9t6s="; + config = { + environment.systemPackages = (lib.attrVals [ + "btop" + "eza" + "fd" + "git" + "glib" + "gnumake" + "gnupg" + "pinentry" + "neofetch" + "wget" + "zoxide" + ] pkgs) + ++ (lib.optionals config.stitchyconf.artPkgs.enable artPkgs) + ++ (lib.optionals (config.stitchyconf.form == "pc") pcPkgs) + ++ (lib.optionals (config.stitchyconf.form == "handheld") handheldPkgs) + ++ (lib.optionals (config.stitchyconf.form == "server") serverPkgs); + + # To-do figure out how to section these off + programs = { + neovim = { + enable = true; + viAlias = true; + vimAlias = true; + defaultEditor = true; + configure = { + customRC = builtins.readFile ../config/nvim/init.vim; + packages.myVimPackage = with pkgs.vimPlugins; { + start = [ + nvim-lspconfig + nvim-cmp + cmp-nvim-lsp + luasnip + cmp_luasnip + tokyonight-nvim + vim-lsp-cxx-highlight + typst-vim + ]; + }; }; - }); - }) - ]; + }; + nix-ld.enable = true; + virt-manager.enable = true; + zsh.enable = true; + }; - fonts.packages= with pkgs; [ - noto-fonts - noto-fonts-emoji - liberation_ttf - nerdfonts - ipafont - ]; + nixpkgs.overlays = [ + (final: prev: { + # Because Luck Smith hasn't released in 2 years + mutt-wizard = prev.mutt-wizard.overrideAttrs (old: { + src = prev.fetchFromGitHub { + owner = "LukeSmithxyz"; + repo = "mutt-wizard"; + rev = "a8863a750a360bad6759f5f2c4df5d2001b31e18"; + hash = "sha256-8zPkzQ1Tt9t8G+uCKybBm4yMqfF2y4L7nmuaWWz9t6s="; + }; + }); + }) + ]; + fonts.packages = lib.attrVals [ + "noto-fonts" + "noto-fonts-emoji" + "liberation_ttf" + "nerdfonts" + "ipafont" + ] pkgs; + }; } diff --git a/users/default.nix b/users/default.nix new file mode 100644 index 0000000..ecc5e31 --- /dev/null +++ b/users/default.nix @@ -0,0 +1,10 @@ +{ config, ...}: + +{ + config = { + users = { + mutableUsers = false; + users.root.initialHashedPassword = "!"; + }; + }; +} diff --git a/users/nyadmin/default.nix b/users/nyadmin/default.nix index 0f613f8..b9d96ca 100644 --- a/users/nyadmin/default.nix +++ b/users/nyadmin/default.nix @@ -1,6 +1,7 @@ { config, pkgs, lib, ... }: { + imports = [ ../default.nix ]; users.users.nyadmin = { isNormalUser = true; shell = pkgs.zsh; diff --git a/users/stitchynyan/default.nix b/users/stitchynyan/default.nix index 629f597..b5a819c 100644 --- a/users/stitchynyan/default.nix +++ b/users/stitchynyan/default.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { - + imports = [ ../default.nix ]; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem ( lib.getName pkg) [ "osu-lazer" @@ -12,15 +12,15 @@ "nvidia-settings" "cudatoolkit" ]; - programs.steam = { - enable = true; - remotePlay.openFirewall = true; - }; - hardware.steam-hardware.enable = true; programs = { + firefox.enable = true; hyprland.enable = true; openvpn3.enable = true; + steam = { + enable = true; + remotePlay.openFirewall = true; + }; }; services = { @@ -43,8 +43,6 @@ security.pam.services.swaylock = {}; - hardware.bluetooth.enable = true; - users.users.stitchynyan = { isNormalUser = true; shell = pkgs.zsh; diff --git a/users/stitchynyan/home.nix b/users/stitchynyan/home.nix index 38a0d02..9424baa 100644 --- a/users/stitchynyan/home.nix +++ b/users/stitchynyan/home.nix @@ -1,5 +1,3 @@ - - { config, nixosConfig, pkgs, @@ -7,139 +5,139 @@ inputs, home-manager, ... }: +let + handheldPkgs = lib.attrVals [ + "fluffychat" + ] pkgs; + pcPkgs = lib.attrVals [ + "activitywatch" + "dunst" + "foot" + "grim" + "imv" + "isync" + "kitty" + "hunspell" + "hyprpaper" + "libreoffice" + "librewolf" + "lynx" + "mpv" + "msmtp" + "mupdf" + "neomutt" + "networkmanagerapplet" + "nheko" + "notmuch" + "okular" + "pavucontrol" + "pass" + "playerctl" + "prismlauncher" + "qt5ct" + "qt6ct" + "slurp" + "swaylock-effects" + "wofi" + ] pkgs ++ [ pkgs.hunspellDicts.en_US ]; +in { - - imports = [ - #inputs.nix-index-db.hmModules.nix-index - ]; - - home.packages = with pkgs; [ - steam - networkmanagerapplet - activitywatch - ngspice - hugo - kicad - okular - mupdf - libreoffice - hunspell - hunspellDicts.en_US - cider - foot - prismlauncher - firefox - librewolf - neomutt - dunst - pass - isync - msmtp - notmuch - kitty - lynx - playerctl - nheko - hyprpaper - xdg-desktop-portal-hyprland - pavucontrol - slurp - grim - wofi - imv - swaylock-effects - qt5ct - qt6ct - mpv - #steamvr? - procps - usbutils - (python311.withPackages (lib.attrVals ["sympy" "matplotlib"])) - (octaveFull.withPackages (lib.attrVals ["symbolic"])) - ]; - - dconf.settings = { - "org/virt-manager/virt-manager/connections" = { - autoconnect = ["qemu:///system"]; - uris = ["qemu:///system"]; - }; + options = { }; + config = { + home.packages = with pkgs; [ + cider + ngspice + hugo + kicad + #steamvr? + procps + usbutils + (python311.withPackages (lib.attrVals ["sympy" "matplotlib"])) + (octaveFull.withPackages (lib.attrVals ["symbolic"])) + ] + ++ (lib.optionals (nixosConfig.stitchyconf.form == "handheld") handheldPkgs) + ++ (lib.optionals (nixosConfig.stitchyconf.form == "pc") pcPkgs); - home.sessionVariables = { - FOO = "BAR"; - - }; - - #programs.hyprland.enable = true; - # hyprland.homeManagerModules.default - #wayland.windowManager.hyprland.enable = true; - - home.file = { - ".zshrc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/zshrc"; - }; - - xdg.configFile = { - "dunst" = { - source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/dunst"; - recursive = true; - }; - "eww" = { - source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/eww"; - recursive = true; - }; - "hypr" = { - source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/hypr"; - recursive = true; - }; - "swaylock" = { - source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/swaylock"; - recursive = true; - }; - }; - - systemd.user.services = { - mailsync = { - Unit = { - Description = "Syncs email"; - After = [ "network-online.target" ]; + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = ["qemu:///system"]; + uris = ["qemu:///system"]; }; - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.mutt-wizard}/bin/mailsync"; - Environment = [ - "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" - "DISPLAY=:0" - "MBSYNCRC=/home/stitchynyan/.config/mbsync/config" - "PATH=$PATH:${lib.makeBinPath [ pkgs.busybox pkgs.cyrus-sasl-xoauth2 pkgs.gnupg pkgs.isync pkgs.notify pkgs.notmuch pkgs.pass pkgs.perl pkgs.python3 ]}" - "SASL_PATH=/run/current-system/sw/lib/sasl2" - "WAYLAND_DISPLAY=wayland-1" - ]; - }; - Install.WantedBy = [ "default.target" ]; }; - }; - systemd.user.timers = { - mailsync = { - Unit.Description = "Syncs email"; - Timer = { - OnBootSec = "1min"; - OnUnitActiveSec = "10min"; - }; - Install.WantedBy = [ "timers.target" ]; + # To-Do Later + home.sessionVariables = { + FOO = "BAR"; + }; - }; + home.file = { + ".zshrc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/zshrc"; + }; - home.pointerCursor = { - name = "phinger-cursors"; - package = pkgs.phinger-cursors; - gtk.enable = true; - size = 64; + xdg.configFile = { + "dunst" = { + source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/dunst"; + recursive = true; + }; + "eww" = { + source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/eww"; + recursive = true; + }; + "hypr" = { + source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/hypr"; + recursive = true; + }; + "swaylock" = { + source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/config/swaylock"; + recursive = true; + }; + }; + + systemd.user.services = { + mailsync = { + Unit = { + Description = "Syncs email"; + After = [ "network-online.target" ]; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.mutt-wizard}/bin/mailsync"; + Environment = [ + "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" + "DISPLAY=:0" + "MBSYNCRC=/home/stitchynyan/.config/mbsync/config" + "PATH=$PATH:${lib.makeBinPath (lib.attrVals [ "busybox" "cyrus-sasl-xoauth2" "gnupg" "isync" "notify" "notmuch" "pass" "perl" "python3" ] pkgs)}" + "SASL_PATH=/run/current-system/sw/lib/sasl2" + "WAYLAND_DISPLAY=wayland-1" + ]; + }; + Install.WantedBy = [ "default.target" ]; + }; + }; + + systemd.user.timers = { + mailsync = { + Unit.Description = "Syncs email"; + Timer = { + OnBootSec = "1min"; + OnUnitActiveSec = "10min"; + }; + Install.WantedBy = [ "timers.target" ]; + }; + }; + + home.pointerCursor = { + name = "phinger-cursors"; + package = pkgs.phinger-cursors; + gtk.enable = true; + size = 64; + }; + + # Read the Docs before change + home.stateVersion = "23.05"; + home.homeDirectory = "/home/stitchynyan"; }; - - # Read the Docs before change - home.stateVersion = "23.05"; - home.homeDirectory = "/home/stitchynyan"; }