start modularizing things

This commit is contained in:
Natalie 2025-04-18 15:55:34 -07:00
parent 51df904a81
commit 1c313955d5
No known key found for this signature in database
GPG key ID: 61F4EAEB0C9C3D5F
24 changed files with 414 additions and 219 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -668,23 +668,43 @@
"type": "github"
}
},
"nh_darwin": {
"nh": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1739410909,
"narHash": "sha256-wx0oBgnmh6K8PJGyASLAErnrIe8/1hZthVrkfoX+j/E=",
"owner": "ToyVo",
"repo": "nh_darwin",
"rev": "10c8d19efd0ed9f63708d1179468fbb2f2bd7f4e",
"lastModified": 1743682999,
"narHash": "sha256-bg+aAN8K90r3m/I+xXiXG0gawpbkshwlk93wxUN7KEk=",
"owner": "viperML",
"repo": "nh",
"rev": "9e9a4590b38b62b28f07a1fae973ce7b6ca0687a",
"type": "github"
},
"original": {
"owner": "ToyVo",
"repo": "nh_darwin",
"owner": "viperML",
"repo": "nh",
"type": "github"
}
},
"nix-index-database": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1744518957,
"narHash": "sha256-RLBSWQfTL0v+7uyskC5kP6slLK1jvIuhaAh8QvB75m4=",
"owner": "nix-community",
"repo": "nix-index-database",
"rev": "4fc9ea78c962904f4ea11046f3db37c62e8a02fd",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-index-database",
"type": "github"
}
},
@ -920,7 +940,8 @@
"hyprland": "hyprland",
"hyprland-plugins": "hyprland-plugins",
"moonlight": "moonlight",
"nh_darwin": "nh_darwin",
"nh": "nh",
"nix-index-database": "nix-index-database",
"nix-options-search": "nix-options-search",
"nixos-cosmic": "nixos-cosmic",
"nixpkgs": "nixpkgs_5",

100
flake.nix
View file

@ -33,8 +33,6 @@
zig.url = "github:mitchellh/zig-overlay";
zls.url = "github:zigtools/zls?rev=a26718049a8657d4da04c331aeced1697bc7652b";
# foundryvtt.url = "github:reckenrode/nix-foundryvtt";
moonlight = {
url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly.
inputs.nixpkgs.follows = "nixpkgs";
@ -44,90 +42,78 @@
inputs.nixpkgs.follows = "nixpkgs";
};
nh_darwin = {
url = "github:ToyVo/nh_darwin";
nh = {
url = "github:viperML/nh";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-options-search = {
url = "github:madsbv/nix-options-search";
};
nix-index-database.url = "github:nix-community/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
chinese-fonts-overlay = {
url = "github:brsvh/chinese-fonts-overlay/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
outputs = inputs @ {
nixpkgs,
nixpkgs-stable,
nix-options-search,
home-manager,
darwin,
hosts,
hyprland-plugins,
zig,
zls,
nixos-cosmic,
nh_darwin,
nix-index-database,
darwin,
...
} @ inputs: let
}: let
overlays = [
inputs.zig.overlays.default
inputs.rust-overlay.overlays.default
inputs.chinese-fonts-overlay.overlays.default
inputs.nh.overlays.default
];
inherit (nixpkgs) lib;
mkIfElse = p: yes: no:
lib.mkMerge [
(lib.mkIf p yes)
(lib.mkIf (!p) no)
];
user = "nmarks";
shared_modules = [
# {nixpkgs.overlays = overlays;}
# {programs.nix-index-database.comma.enable = true;}
# nixindex
# homemanagerModules
{
_module.args = {
inherit user;
inherit mkIfElse;
};
}
];
in {
nixosConfigurations = {
nixos = lib.nixosSystem {
modules = [
{nixpkgs.overlays = overlays;}
hosts.nixosModule
{
networking.stevenBlackHosts.enable = true;
}
./hosts/desktop/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager = {
backupFileExtension = "hm-backup";
useGlobalPkgs = true;
useUserPackages = true;
users.nmarks = import ./hosts/desktop/home.nix;
};
home-manager.extraSpecialArgs = {
inherit hyprland-plugins;
inherit zls;
};
}
nixos-cosmic.nixosModules.default
];
system = "x86_64-linux";
modules =
[
./hosts/desktop/configuration.nix
nixos-cosmic.nixosModules.default
]
++ shared_modules;
specialArgs = inputs;
};
};
darwinConfigurations = {
"Natalies-MacBook-Air" = darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
{nixpkgs.overlays = overlays;}
./hosts/laptop/configuration.nix
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.nmarks = import ./hosts/laptop/home.nix;
};
home-manager.extraSpecialArgs = {
inherit zls;
};
users.users.nmarks.home = "/Users/nmarks";
}
];
specialArgs = {
inherit inputs;
};
specialArgs = inputs;
modules =
[
./hosts/laptop/configuration.nix
]
++ shared_modules;
};
};
};

BIN
hosts/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -1,6 +1,3 @@
#<BS> 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).
{
self,
inputs,
@ -8,8 +5,14 @@
pkgs,
...
}: {
nixpkgs.config.allowUnfree = true;
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
../../modules/shared/nix.nix
../../modules/nixos/nvidia.nix
../../modules/nixos/boot.ni
];
services.avahi = {
enable = true;
nssmdns4 = true;
@ -51,22 +54,6 @@
nix.settings.trusted-users = ["root" "nmarks"];
nix.settings.experimental-features = ["nix-command" "flakes"];
nix.settings = {
substituters = [
"https://cache.nixos.org/"
"https://nix-community.cachix.org"
"https://cosmic.cachix.org/"
"https://cache.iog.io"
"https://cuda-maintainers.cachix.org"
];
trusted-public-keys = [
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
programs.hyprland.enable = true;
programs.fish.enable = true;
@ -109,89 +96,6 @@
nerd-fonts.iosevka
];
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
# inputs.foundryvtt.nixosModules.foundryvtt
];
# Enable OpenGL
hardware.graphics = {
enable = true;
};
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia-container-toolkit.enable = true;
hardware.nvidia = {
forceFullCompositionPipeline = true;
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.latest;
#Fixes a glitch
nvidiaPersistenced = true;
#Required for amdgpu and nvidia gpu pairings
# modesetting.enable = true;
prime = {
# offload.enable = true;
#sync.enable = true;
amdgpuBusId = "PCI:0f:00.0";
nvidiaBusId = "PCI:01:00.0";
};
};
# Bootloader.
#boot.loader.systemd-boot.enable = true;
#boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.loader = {
# systemd-boot.enable = true;
efi = {
canTouchEfiVariables = true;
# assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends).
efiSysMountPoint = "/boot/efi";
};
grub = {
enable = true;
device = "nodev";
theme = pkgs.catppuccin-grub;
useOSProber = true;
efiSupport = true;
};
};
boot.supportedFilesystems = ["ntfs"];
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
# Set your time zone.
time.timeZone = "America/Los_Angeles";
@ -340,19 +244,6 @@
networkmanager.enable = true;
firewall = {
allowedTCPPorts = [22 80 443];
#KDE Connect
# allowedTCPPortRanges = [
# {
# from = 1714;
# to = 1764;
# }
# ];
# allowedUDPPortRanges = [
# {
# from = 1714;
# to = 1764;
# }
# ];
enable = true;
};
interfaces.enp11s0.wakeOnLan = {

BIN
hosts/laptop/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -1,27 +1,32 @@
{
config,
pkgs,
lib,
...
}: {
imports = [
../../modules/shared/nix.nix
./modules/icons.nix
];
environment.systemPackages = with pkgs; [
home-manager
neovim
pinentry_mac
];
nixpkgs.config.allowUnfree = true;
environment.customIcons = {
enable = true;
icons = [
{
path = "/Applications/Zen.app";
icon = "/Users/nmarks/.dotfiles/icons/Zen_icons/firefox.icns";
}
];
};
# Use a custom configuration.nix location.
#environment.darwinConfig = "$HOME/.dotfiles/hosts/laptop";
# Auto upgrade nix package and the daemon service.
nix = {
package = pkgs.nix;
settings = {
"extra-experimental-features" = ["nix-command" "flakes"];
};
};
# Create /etc/zshrc that loads the nix-darwin environment.
programs = {
gnupg.agent.enable = true;

View file

@ -1,36 +1,35 @@
{
inputs,
config,
pkgs,
lib,
ghostty,
moonlight,
...
}: {
# Home Manager needs a bit of information about you and the paths it should
# manage.
# 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.05"; # Please read the comment before changing.
home.packages = pkgs.callPackage ../shared/packages.nix {};
programs = import ../shared/home-programs.nix {inherit config pkgs lib;};
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
TERMINAL = "ghostty";
BROWSER = "firefox";
home = {
# Home Manager needs a bit of information about you and the paths it should
# manage.
# 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.
stateVersion = "23.05"; # Please read the comment before changing.
packages = pkgs.callPackage ../shared/packages.nix {};
sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
TERMINAL = "ghostty";
BROWSER = "firefox";
};
sessionPath = [
"$HOME/.emacs.d/bin"
];
};
home.sessionPath = [
"$HOME/.emacs.d/bin"
];
# Let Home Manager install and manage itself.
}

BIN
hosts/laptop/icons/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,61 @@
{
lib,
config,
...
}: let
cfg = config.environment.customIcons;
inherit
(lib)
mkEnableOption
mkIf
mkMerge
mkOption
types
;
in {
options.environment.customIcons = {
enable = mkEnableOption "environment.customIcons";
clearCacheOnActivation = mkEnableOption "environment.customIcons.clearCacheOnActivation";
icons = mkOption {
type = types.listOf (
types.submodule {
options = {
path = mkOption {type = types.path;};
icon = mkOption {type = types.path;};
};
}
);
};
};
config = mkMerge [
(mkIf cfg.enable {
system.activationScripts.extraActivation.text = ''
echo -e "applying custom icons..."
${
(builtins.concatStringsSep "\n\n" (
builtins.map (iconCfg: ''
osascript <<EOF >/dev/null
use framework "Cocoa"
set iconPath to "${iconCfg.icon}"
set destPath to "${iconCfg.path}"
set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:iconPath)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2)
EOF
'')
cfg.icons
))
}
${lib.optionalString cfg.clearCacheOnActivation ''
sudo rm -rf /Library/Caches/com.apple.iconservices.store
sudo find /private/var/folders/ -name com.apple.dock.iconcache -or -name com.apple.iconservices -or -name com.apple.iconservicesagent -exec rm -rf {} \; || true
killall Dock
''}'';
})
];
}

View file

@ -26,6 +26,25 @@
bold_font auto";
};
bat = {
enable = true;
extraPackages = with pkgs.bat-extras; [batdiff batman batgrep batwatch batpipe prettybat];
config = {
theme = "catpuccin";
};
themes = {
catpuccin = {
src = pkgs.fetchFromGitHub {
owner = "catppuccin";
repo = "bat";
hash = "sha256-6fWoCH90IGumAMc4buLRWL0N61op+AuMNN9CAR9/OdI=";
rev = "699f60fc8ec434574ca7451b444b880430319941";
};
file = "themes/Catppuccin Mocha.tmTheme";
};
};
};
hyfetch = {
enable = true;
settings = {
@ -63,7 +82,10 @@
shellAliases = {
reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now";
};
shellInit = "test -r '/Users/nmarks/.opam/opam-init/init.fish' && source '/Users/nmarks/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true";
shellInit = ''
test -r '/Users/nmarks/.opam/opam-init/init.fish' && source '/Users/nmarks/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true
batman --export-env | source
'';
};
home-manager.enable = true;
}

View file

@ -32,7 +32,6 @@ with pkgs; [
#nix tools
cachix
direnv
comma
nh
#terminal stuff
@ -44,7 +43,6 @@ with pkgs; [
neofetch
hyfetch
fastfetch
bat
eza
ollama
uv

33
modules/nixos/boot.nix Normal file
View file

@ -0,0 +1,33 @@
{pkgs, ...}: {
boot = {
kernelPackages = pkgs.linuxPackages_latest; # _zen, _hardened, _rt, _rt_latest, etc.
loader = {
efi = {
canTouchEfiVariables = true;
# assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends).
efiSysMountPoint = "/boot/efi";
};
grub = {
enable = true;
device = "nodev";
theme = pkgs.catppuccin-grub;
useOSProber = true;
efiSupport = true;
};
};
#this is set to false by default for some reason
tmp.cleanOnBoot = true;
# Make boot screen quiet
kernelParams = [
"quiet"
"splash"
"rd.systemd.show_status=auto"
"rd.udev.log_level=3"
"udev.log_priority=3"
];
consoleLogLevel = 0;
initrd.verbose = false;
};
}

95
modules/nixos/nvidia.nix Normal file
View file

@ -0,0 +1,95 @@
{
lib,
pkgs,
config,
...
}: let
nvidiaDriverChannel = config.boot.kernelPackages.nvidiaPackages.latest;
in {
services.xserver.videoDrivers = ["nvidia"];
nixpkgs.config = {
nvidia.acceptLicense = true;
allowUnfree = true;
};
# Kernel parameters for better Wayland and Hyprland integration
boot.kernelParams = [
"nvidia-drm.modeset=1" # Enable mode setting for Wayland
"nvidia.NVreg_PreserveVideoMemoryAllocations=1" # Improves resume after sleep
];
# Blacklist nouveau to avoid conflicts
boot.blacklistedKernelModules = ["nouveau"];
hardware = {
nvidia = {
forceFullCompositionPipeline = true; # Prevents screen tearing
# Modesetting is required.
modesetting.enable = true;
powerManagement = {
enable = true; # Power management
finegrained = true; # More precise power consumption control
};
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Environment variables for better compatibility
environment.variables = {
LIBVA_DRIVER_NAME = "nvidia"; # Hardware video acceleration
XDG_SESSION_TYPE = "wayland"; # Force Wayland
GBM_BACKEND = "nvidia-drm"; # Graphics backend for Wayland
__GLX_VENDOR_LIBRARY_NAME = "nvidia"; # Use Nvidia driver for GLX
WLR_NO_HARDWARE_CURSORS = "1"; # Fix for cursors on Wayland
NIXOS_OZONE_WL = "1"; # Wayland support for Electron apps
__GL_GSYNC_ALLOWED = "1"; # Enable G-Sync if available
__GL_VRR_ALLOWED = "1"; # Enable VRR (Variable Refresh Rate)
WLR_DRM_NO_ATOMIC = "1"; # Fix for some issues with Hyprland
NVD_BACKEND = "direct"; # Configuration for new driver
MOZ_ENABLE_WAYLAND = "1"; # Wayland support for Firefox
};
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
package = nvidiaDriverChannel;
#Fixes a glitch
nvidiaPersistenced = true;
};
nvidia-container-toolkit.enable = true;
graphics = {
enable = true;
package = nvidiaDriverChannel;
enable32Bit = true;
extraPackages = with pkgs; [
nvidia-vaapi-driver
vaapiVdpau
libvdpau-va-gl
mesa
egl-wayland
vulkan-loader
vulkan-validation-layers
libva
];
};
};
nix.settings = {
substituters = ["https://cuda-maintainers.cachix.org"];
trusted-public-keys = [
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
};
environment.systemPackages = with pkgs; [
vulkan-tools
glxinfo
libva-utils # VA-API debugging tools
];
}

14
modules/shared/extras.nix Normal file
View file

@ -0,0 +1,14 @@
{
pkgs,
config,
inputs,
hostName,
mkIfElse,
darwin,
...
}: {
networking = {
inherit hostName;
networkmanager = !darwin;
};
}

View file

@ -0,0 +1,8 @@
{inputs, ...}: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "hm-backup";
extraSpecialArgs = {inherit inputs;};
};
}

39
modules/shared/nix.nix Normal file
View file

@ -0,0 +1,39 @@
{
config,
inputs,
...
}: {
nixpkgs.config = {
allowUnfree = true;
};
nix = {
nixPath = ["nixpkgs = ${inputs.nixpkgs}"];
extraOptions = ''
warn-dirty = false
'';
settings = {
auto-optimise-store = true;
experimental-features = ["nix-command" "flakes"];
substituters = [
"https://cache.nixos.org/?priority=10"
"https://nix-community.cachix.org"
"https://cosmic.cachix.org/"
"https://cache.iog.io"
];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
gc = {
automatic = true;
persistent = true;
dates = "weekly";
options = "--delete-older-than 7d";
};
};
}

23
modules/shared/vars.nix Normal file
View file

@ -0,0 +1,23 @@
{
inputs,
pkgs,
config,
lib,
mkIfElse,
...
}: let
darwin = pkgs.stdenv.isDarwin;
homemanagerModules = mkIfElse darwin inputs.home-manager.darwinModules inputs.home-manager.nixosModules;
nixindex = mkIfElse darwin inputs.nix-index-database.darwinModules.nix-index inputs.nix-index-database.nixosModules.nix-index;
in {
config.var = {
inherit darwin homemanagerModules nixindex;
};
options = {
var = lib.mkOption {
type = lib.types.attrs;
default = {};
};
};
}