feat: refactor

This commit is contained in:
Barrett Ruth 2026-02-13 21:34:53 -05:00
parent 332a7dbfbe
commit 30286dbedb
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
13 changed files with 231 additions and 151 deletions

View file

@ -12,14 +12,6 @@ env = QT_QPA_PLATFORM,wayland
env = GDK_BACKEND,wayland,x11 env = GDK_BACKEND,wayland,x11
env = SDL_VIDEODRIVER,wayland env = SDL_VIDEODRIVER,wayland
env = LIBVA_DRIVER_NAME,nvidia
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = NVD_BACKEND,direct
env = GBM_BACKEND,nvidia-drm
env = GSK_RENDERER,ngl
env = __NV_PRIME_RENDER_OFFLOAD,1
env = __VK_LAYER_NV_optimus,NVIDIA_only
env = XCURSOR_SIZE,24 env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24 env = HYPRCURSOR_SIZE,24
env = HYPRCURSOR_THEME,Apple_Cursor env = HYPRCURSOR_THEME,Apple_Cursor

View file

@ -42,17 +42,20 @@ for _, plugin in ipairs(disabled_plugins) do
vim.g['loaded_' .. plugin] = 1 vim.g['loaded_' .. plugin] = 1
end end
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({ local lazyrepo = "https://github.com/folke/lazy.nvim.git"
'git', local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
'clone', if vim.v.shell_error ~= 0 then
'https://github.com/folke/lazy.nvim.git', vim.api.nvim_echo({
lazypath, { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
}) { out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require('lazy').setup('plugins', {
change_detection = { enabled = false }, require('lazy').setup('plugins')
})

122
flake.nix
View file

@ -24,48 +24,93 @@
... ...
}: }:
let let
system = "x86_64-linux"; overlays = [
pkgs = import nixpkgs { neovim-nightly.overlays.default
inherit system; claude-code.overlays.default
config.allowUnfreePredicate = ];
pkg:
builtins.elem (nixpkgs.lib.getName pkg) [ sharedUnfree = [
"slack" "slack"
"claude-code" "claude-code"
"claude" "claude"
"nvidia-x11" "apple_cursor"
"nvidia-settings" ];
"apple_cursor"
]; mkPkgs =
overlays = [ system: extraUnfree:
neovim-nightly.overlays.default import nixpkgs {
claude-code.overlays.default inherit system;
]; config.allowUnfreePredicate =
pkg:
builtins.elem (nixpkgs.lib.getName pkg) (sharedUnfree ++ extraUnfree);
inherit overlays;
};
xps15Config = {
isNixOS = true;
isLinux = true;
isDarwin = false;
gpu = "nvidia";
backlightDevice = "intel_backlight";
platform = "x86_64-linux";
}; };
macConfig = {
isNixOS = false;
isLinux = false;
isDarwin = true;
gpu = "apple";
backlightDevice = null;
platform = "aarch64-darwin";
};
macWorkConfig = {
isNixOS = false;
isLinux = false;
isDarwin = true;
gpu = "apple";
backlightDevice = null;
platform = "aarch64-darwin";
};
linuxWorkConfig = {
isNixOS = false;
isLinux = true;
isDarwin = false;
gpu = null;
backlightDevice = null;
platform = "x86_64-linux";
};
mkHome =
hostConfig:
home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs hostConfig.platform [ ];
extraSpecialArgs = {
inherit zen-browser hostConfig;
};
modules = [ ./home/home.nix ];
};
in in
{ {
formatter.${system} = pkgs.nixfmt-tree; formatter.x86_64-linux = (mkPkgs "x86_64-linux" [ ]).nixfmt-tree;
nixosConfigurations.xps15 = nixpkgs.lib.nixosSystem { nixosConfigurations.xps15 = nixpkgs.lib.nixosSystem {
modules = [ modules = [
nixos-hardware.nixosModules.dell-xps-15-9500-nvidia nixos-hardware.nixosModules.dell-xps-15-9500-nvidia
./hosts/xps15/configuration.nix ./hosts/xps15/configuration.nix
{ {
nixpkgs.hostPlatform = system; nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.overlays = [ nixpkgs.overlays = overlays;
neovim-nightly.overlays.default
claude-code.overlays.default
];
nixpkgs.config.allowUnfreePredicate = nixpkgs.config.allowUnfreePredicate =
pkg: pkg:
builtins.elem (nixpkgs.lib.getName pkg) [ builtins.elem (nixpkgs.lib.getName pkg) (
"slack" sharedUnfree
"claude-code" ++ [
"claude" "nvidia-x11"
"nvidia-x11" "nvidia-settings"
"nvidia-settings" ]
"apple_cursor" );
];
} }
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
@ -75,8 +120,7 @@
home-manager.users.barrett = import ./home/home.nix; home-manager.users.barrett = import ./home/home.nix;
home-manager.extraSpecialArgs = { home-manager.extraSpecialArgs = {
inherit zen-browser; inherit zen-browser;
hostPlatform = system; hostConfig = xps15Config;
isNixOS = true;
}; };
} }
]; ];
@ -85,14 +129,10 @@
}; };
}; };
homeConfigurations.barrett = home-manager.lib.homeManagerConfiguration { homeConfigurations = {
inherit pkgs; "barrett@mac" = mkHome macConfig;
extraSpecialArgs = { "barrett@mac-work" = mkHome macWorkConfig;
inherit zen-browser; "barrett@linux-work" = mkHome linuxWorkConfig;
hostPlatform = system;
isNixOS = false;
};
modules = [ ./home/home.nix ];
}; };
}; };
} }

View file

@ -2,39 +2,45 @@
lib, lib,
config, config,
pkgs, pkgs,
isNixOS, hostConfig,
... ...
}: }:
{ {
imports = [ imports =
./modules/bootstrap.nix [
./modules/theme.nix ./modules/bootstrap.nix
./modules/shell.nix ./modules/theme.nix
./modules/terminal.nix ./modules/shell.nix
./modules/git.nix ./modules/terminal.nix
./modules/editor.nix ./modules/git.nix
./modules/hyprland.nix ./modules/editor.nix
./modules/ui.nix ./modules/packages.nix
./modules/packages.nix ]
]; ++ lib.optionals hostConfig.isLinux [
./modules/hyprland.nix
./modules/ui.nix
];
config = { config = {
theme = "midnight"; theme = "midnight";
home.username = "barrett"; home.username = "barrett";
home.homeDirectory = "/home/${config.home.username}"; home.homeDirectory =
if hostConfig.isDarwin
then "/Users/${config.home.username}"
else "/home/${config.home.username}";
home.stateVersion = "24.11"; home.stateVersion = "24.11";
xdg.enable = true; xdg.enable = true;
targets.genericLinux.enable = !isNixOS; targets.genericLinux.enable = hostConfig.isLinux && !hostConfig.isNixOS;
news.display = "silent"; news.display = "silent";
home.sessionPath = [ "${config.home.homeDirectory}/.config/nix/scripts" ]; home.sessionPath = [ "${config.home.homeDirectory}/.config/nix/scripts" ];
programs.home-manager.enable = true; programs.home-manager.enable = true;
systemd.user.services.nix-flake-update = { systemd.user.services.nix-flake-update = lib.mkIf hostConfig.isLinux {
Unit.Description = "Update nix flake inputs"; Unit.Description = "Update nix flake inputs";
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
@ -43,7 +49,7 @@
}; };
}; };
systemd.user.timers.nix-flake-update = { systemd.user.timers.nix-flake-update = lib.mkIf hostConfig.isLinux {
Unit.Description = "Auto-update nix flake inputs"; Unit.Description = "Auto-update nix flake inputs";
Timer = { Timer = {
OnCalendar = "daily"; OnCalendar = "daily";
@ -52,7 +58,7 @@
Install.WantedBy = [ "timers.target" ]; Install.WantedBy = [ "timers.target" ];
}; };
systemd.user.services.theme-apply = { systemd.user.services.theme-apply = lib.mkIf hostConfig.isLinux {
Unit = { Unit = {
Description = "Apply theme on login"; Description = "Apply theme on login";
After = [ "graphical-session.target" ]; After = [ "graphical-session.target" ];
@ -64,7 +70,7 @@
Install.WantedBy = [ "graphical-session.target" ]; Install.WantedBy = [ "graphical-session.target" ];
}; };
systemd.user.services.cliphist-wipe = { systemd.user.services.cliphist-wipe = lib.mkIf hostConfig.isLinux {
Unit.Description = "Clear clipboard history on session end"; Unit.Description = "Clear clipboard history on session end";
Service = { Service = {
Type = "oneshot"; Type = "oneshot";

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
config, config,
hostConfig,
... ...
}: }:
@ -8,13 +9,16 @@ let
homeDir = config.home.homeDirectory; homeDir = config.home.homeDirectory;
repoDir = "${homeDir}/.config/nix"; repoDir = "${homeDir}/.config/nix";
directories = [ directories =
"dev" [
"dl" "dev"
"img" "dl"
"img/screen" "img"
"img/wp" ]
]; ++ lib.optionals hostConfig.isLinux [
"img/screen"
"img/wp"
];
in in
{ {
home.activation.createDirectories = lib.hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.createDirectories = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
@ -29,15 +33,17 @@ in
done done
''; '';
home.activation.linkWallpapers = lib.hm.dag.entryAfter [ "createDirectories" ] '' home.activation.linkWallpapers = lib.mkIf hostConfig.isLinux (
src="${repoDir}/config/screen" lib.hm.dag.entryAfter [ "createDirectories" ] ''
dest="$HOME/img/screen" src="${repoDir}/config/screen"
if [ -d "$src" ]; then dest="$HOME/img/screen"
for f in "$src"/*; do if [ -d "$src" ]; then
[ -f "$f" ] || continue for f in "$src"/*; do
name=$(basename "$f") [ -f "$f" ] || continue
[ -L "$dest/$name" ] || $DRY_RUN_CMD ln -sf "$f" "$dest/$name" name=$(basename "$f")
done [ -L "$dest/$name" ] || $DRY_RUN_CMD ln -sf "$f" "$dest/$name"
fi done
''; fi
''
);
} }

View file

@ -2,6 +2,7 @@
lib, lib,
config, config,
pkgs, pkgs,
hostConfig,
... ...
}: }:
@ -139,7 +140,7 @@
programs.gpg.enable = true; programs.gpg.enable = true;
services.gpg-agent = { services.gpg-agent = lib.mkIf hostConfig.isLinux {
enable = true; enable = true;
defaultCacheTtl = 3600; defaultCacheTtl = 3600;
maxCacheTtl = 7200; maxCacheTtl = 7200;

View file

@ -2,7 +2,7 @@
pkgs, pkgs,
lib, lib,
config, config,
isNixOS, hostConfig,
... ...
}: }:
@ -13,21 +13,32 @@ let
col.inactive_border = rgb(${builtins.substring 1 6 palette.bg}) col.inactive_border = rgb(${builtins.substring 1 6 palette.bg})
} }
''; '';
nvidiaEnv = lib.optionalString (hostConfig.gpu == "nvidia") ''
env = LIBVA_DRIVER_NAME,nvidia
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = NVD_BACKEND,direct
env = GBM_BACKEND,nvidia-drm
env = GSK_RENDERER,ngl
env = __NV_PRIME_RENDER_OFFLOAD,1
env = __VK_LAYER_NV_optimus,NVIDIA_only
'';
in in
{ {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
package = lib.mkIf (!isNixOS) null; package = lib.mkIf (!hostConfig.isNixOS) null;
portalPackage = lib.mkIf (!isNixOS) null; portalPackage = lib.mkIf (!hostConfig.isNixOS) null;
systemd.enable = isNixOS; systemd.enable = hostConfig.isNixOS;
extraConfig = '' extraConfig = ''
${nvidiaEnv}
source = $XDG_CONFIG_HOME/nix/config/hypr/hyprland.conf source = $XDG_CONFIG_HOME/nix/config/hypr/hyprland.conf
''; '';
}; };
home.packages = home.packages =
lib.optionals isNixOS [ lib.optionals hostConfig.isNixOS [
pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-gtk
pkgs.hyprpaper pkgs.hyprpaper
] ]

View file

@ -3,7 +3,7 @@
lib, lib,
config, config,
zen-browser, zen-browser,
hostPlatform, hostConfig,
... ...
}: }:
@ -39,17 +39,21 @@ in
with pkgs; with pkgs;
[ [
slack slack
bitwarden-desktop
gemini-cli gemini-cli
typst typst
libreoffice-fresh
glab glab
] ]
++ lib.optionals zen [ zen-browser.packages.${hostPlatform}.default ] ++ lib.optionals hostConfig.isLinux [
++ lib.optionals sioyek [ sioyek-wrapped ] bitwarden-desktop
++ lib.optionals vesktop [ pkgs.vesktop ] libreoffice-fresh
]
++ lib.optionals zen [ zen-browser.packages.${hostConfig.platform}.default ]
++ lib.optionals sioyek [
(if hostConfig.isLinux then sioyek-wrapped else pkgs.sioyek)
]
++ lib.optionals (vesktop && hostConfig.isLinux) [ pkgs.vesktop ]
++ lib.optionals claude [ pkgs.claude-code ] ++ lib.optionals claude [ pkgs.claude-code ]
++ lib.optionals signal [ pkgs.signal-desktop ]; ++ lib.optionals (signal && hostConfig.isLinux) [ pkgs.signal-desktop ];
xdg.configFile."claude/settings.json" = lib.mkIf claude { xdg.configFile."claude/settings.json" = lib.mkIf claude {
text = builtins.toJSON { text = builtins.toJSON {
@ -92,7 +96,7 @@ in
source = config.lib.file.mkOutOfStoreSymlink "${repoDir}/config/sioyek/themes/daylight.config"; source = config.lib.file.mkOutOfStoreSymlink "${repoDir}/config/sioyek/themes/daylight.config";
}; };
home.activation.linkZenProfile = lib.mkIf zen ( home.activation.linkZenProfile = lib.mkIf (zen && hostConfig.isLinux) (
lib.hm.dag.entryAfter [ "writeBoundary" ] '' lib.hm.dag.entryAfter [ "writeBoundary" ] ''
zen_config="$HOME/.zen" zen_config="$HOME/.zen"
repo_zen="${repoDir}/config/zen" repo_zen="${repoDir}/config/zen"
@ -135,12 +139,14 @@ in
'' ''
); );
xdg.configFile."electron-flags.conf".text = '' xdg.configFile."electron-flags.conf" = lib.mkIf hostConfig.isLinux {
--enable-features=WaylandWindowDecorations text = ''
--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations
''; --ozone-platform-hint=auto
'';
};
xdg.mimeApps = { xdg.mimeApps = lib.mkIf hostConfig.isLinux {
enable = true; enable = true;
defaultApplications = lib.mkMerge [ defaultApplications = lib.mkMerge [
(lib.mkIf zen { (lib.mkIf zen {
@ -155,9 +161,9 @@ in
"application/pdf" = "sioyek.desktop"; "application/pdf" = "sioyek.desktop";
"application/epub+zip" = "sioyek.desktop"; "application/epub+zip" = "sioyek.desktop";
}) })
# (lib.mkIf vesktop { (lib.mkIf vesktop {
# "x-scheme-handler/discord" = "vesktop.desktop"; "x-scheme-handler/discord" = "vesktop.desktop";
# }) })
]; ];
}; };
} }

View file

@ -2,7 +2,7 @@
pkgs, pkgs,
lib, lib,
config, config,
isNixOS, hostConfig,
... ...
}: }:
@ -28,7 +28,6 @@ in
[ [
awscli2 awscli2
pure-prompt pure-prompt
xclip
tree tree
jq jq
curl curl
@ -43,6 +42,7 @@ in
librsvg librsvg
imagemagick imagemagick
] ]
++ lib.optionals hostConfig.isLinux [ xclip ]
++ lib.optionals rust [ rustup ]; ++ lib.optionals rust [ rustup ];
home.sessionVariables = lib.mkMerge [ home.sessionVariables = lib.mkMerge [
@ -191,7 +191,7 @@ in
dotDir = "${config.xdg.configHome}/zsh"; dotDir = "${config.xdg.configHome}/zsh";
completionInit = ""; completionInit = "";
profileExtra = '' profileExtra = lib.mkIf hostConfig.isLinux ''
[ "$(tty)" = "/dev/tty1" ] && [ -z "$WAYLAND_DISPLAY" ] && start-hyprland [ "$(tty)" = "/dev/tty1" ] && [ -z "$WAYLAND_DISPLAY" ] && start-hyprland
''; '';

View file

@ -2,6 +2,7 @@
lib, lib,
config, config,
pkgs, pkgs,
hostConfig,
... ...
}: }:
@ -69,7 +70,7 @@ in
palettes = palettes; palettes = palettes;
colors = palettes.${config.theme}; colors = palettes.${config.theme};
home.pointerCursor = { home.pointerCursor = lib.mkIf hostConfig.isLinux {
name = "macOS"; name = "macOS";
package = pkgs.apple-cursor; package = pkgs.apple-cursor;
size = 24; size = 24;
@ -77,7 +78,7 @@ in
x11.enable = false; x11.enable = false;
}; };
gtk = { gtk = lib.mkIf hostConfig.isLinux {
enable = true; enable = true;
font = { font = {
name = "SF Pro Display"; name = "SF Pro Display";
@ -85,8 +86,10 @@ in
}; };
}; };
home.file.".local/share/fonts".source = home.file.".local/share/fonts" = lib.mkIf hostConfig.isLinux {
config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.config/nix/fonts"; source =
config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.config/nix/fonts";
};
home.activation.checkFonts = lib.hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.checkFonts = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d "${config.home.homeDirectory}/.config/nix/fonts" ] || \ if [ ! -d "${config.home.homeDirectory}/.config/nix/fonts" ] || \
@ -102,9 +105,11 @@ in
home.activation.linkTheme = lib.hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.linkTheme = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
cfg="${config.xdg.configHome}" cfg="${config.xdg.configHome}"
theme="${config.theme}" theme="${config.theme}"
$DRY_RUN_CMD ln -sf "$cfg/hypr/themes/$theme.conf" "$cfg/hypr/themes/theme.conf" ${lib.optionalString hostConfig.isLinux ''
$DRY_RUN_CMD ln -sf "$cfg/waybar/themes/$theme.css" "$cfg/waybar/themes/theme.css" $DRY_RUN_CMD ln -sf "$cfg/hypr/themes/$theme.conf" "$cfg/hypr/themes/theme.conf"
$DRY_RUN_CMD ln -sf "$cfg/rofi/themes/$theme.rasi" "$cfg/rofi/themes/theme.rasi" $DRY_RUN_CMD ln -sf "$cfg/waybar/themes/$theme.css" "$cfg/waybar/themes/theme.css"
$DRY_RUN_CMD ln -sf "$cfg/rofi/themes/$theme.rasi" "$cfg/rofi/themes/theme.rasi"
''}
$DRY_RUN_CMD ln -sf "$cfg/sioyek/themes/$theme.config" "$cfg/sioyek/themes/theme.config" $DRY_RUN_CMD ln -sf "$cfg/sioyek/themes/$theme.config" "$cfg/sioyek/themes/theme.config"
$DRY_RUN_CMD ln -sf "$cfg/fzf/themes/$theme" "$cfg/fzf/themes/theme" $DRY_RUN_CMD ln -sf "$cfg/fzf/themes/$theme" "$cfg/fzf/themes/theme"
''; '';

View file

@ -2,12 +2,12 @@
pkgs, pkgs,
lib, lib,
config, config,
hostConfig,
... ...
}: }:
let let
c = config.colors; c = config.colors;
backlightDevice = "intel_backlight";
mkWaybarTheme = palette: '' mkWaybarTheme = palette: ''
* { color: ${palette.fg}; } * { color: ${palette.fg}; }
@ -62,13 +62,14 @@ in
"hyprland/window" "hyprland/window"
]; ];
modules-center = [ ]; modules-center = [ ];
modules-right = [ modules-right =
"backlight" lib.optional (hostConfig.backlightDevice != null) "backlight"
"pulseaudio" ++ [
"network" "pulseaudio"
"battery" "network"
"clock" "battery"
]; "clock"
];
"hyprland/workspaces" = { "hyprland/workspaces" = {
disable-scroll = true; disable-scroll = true;
@ -114,8 +115,8 @@ in
tooltip-format-disconnected = "Network: disconnected"; tooltip-format-disconnected = "Network: disconnected";
}; };
backlight = { backlight = lib.mkIf (hostConfig.backlightDevice != null) {
device = backlightDevice; device = hostConfig.backlightDevice;
format = "brightness:{percent}% "; format = "brightness:{percent}% ";
signal = 1; signal = 1;
tooltip = false; tooltip = false;

View file

@ -8,6 +8,7 @@
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./hardware.nix
]; ];
boot.loader.systemd-boot = { boot.loader.systemd-boot = {
@ -16,8 +17,6 @@
}; };
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
boot.kernelParams = [ boot.kernelParams = [
"nvidia-drm.modeset=1"
"ibt=off"
"loglevel=3" "loglevel=3"
"quiet" "quiet"
]; ];
@ -77,16 +76,6 @@
}; };
programs.hyprland.enable = true; programs.hyprland.enable = true;
hardware.nvidia = {
open = true;
modesetting.enable = true;
prime = {
offload.enable = true;
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
hardware.graphics.enable = true;
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
services.keyd = { services.keyd = {

20
hosts/xps15/hardware.nix Normal file
View file

@ -0,0 +1,20 @@
{ ... }:
{
boot.kernelParams = [
"nvidia-drm.modeset=1"
"ibt=off"
];
hardware.nvidia = {
open = true;
modesetting.enable = true;
prime = {
offload.enable = true;
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
hardware.graphics.enable = true;
}