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 = 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 = HYPRCURSOR_SIZE,24
env = HYPRCURSOR_THEME,Apple_Cursor

View file

@ -42,17 +42,20 @@ for _, plugin in ipairs(disabled_plugins) do
vim.g['loaded_' .. plugin] = 1
end
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
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
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfreePredicate =
pkg:
builtins.elem (nixpkgs.lib.getName pkg) [
"slack"
"claude-code"
"claude"
"nvidia-x11"
"nvidia-settings"
"apple_cursor"
];
overlays = [
neovim-nightly.overlays.default
claude-code.overlays.default
];
overlays = [
neovim-nightly.overlays.default
claude-code.overlays.default
];
sharedUnfree = [
"slack"
"claude-code"
"claude"
"apple_cursor"
];
mkPkgs =
system: extraUnfree:
import nixpkgs {
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
{
formatter.${system} = pkgs.nixfmt-tree;
formatter.x86_64-linux = (mkPkgs "x86_64-linux" [ ]).nixfmt-tree;
nixosConfigurations.xps15 = nixpkgs.lib.nixosSystem {
modules = [
nixos-hardware.nixosModules.dell-xps-15-9500-nvidia
./hosts/xps15/configuration.nix
{
nixpkgs.hostPlatform = system;
nixpkgs.overlays = [
neovim-nightly.overlays.default
claude-code.overlays.default
];
nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.overlays = overlays;
nixpkgs.config.allowUnfreePredicate =
pkg:
builtins.elem (nixpkgs.lib.getName pkg) [
"slack"
"claude-code"
"claude"
"nvidia-x11"
"nvidia-settings"
"apple_cursor"
];
builtins.elem (nixpkgs.lib.getName pkg) (
sharedUnfree
++ [
"nvidia-x11"
"nvidia-settings"
]
);
}
home-manager.nixosModules.home-manager
{
@ -75,8 +120,7 @@
home-manager.users.barrett = import ./home/home.nix;
home-manager.extraSpecialArgs = {
inherit zen-browser;
hostPlatform = system;
isNixOS = true;
hostConfig = xps15Config;
};
}
];
@ -85,14 +129,10 @@
};
};
homeConfigurations.barrett = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit zen-browser;
hostPlatform = system;
isNixOS = false;
};
modules = [ ./home/home.nix ];
homeConfigurations = {
"barrett@mac" = mkHome macConfig;
"barrett@mac-work" = mkHome macWorkConfig;
"barrett@linux-work" = mkHome linuxWorkConfig;
};
};
}

View file

@ -2,39 +2,45 @@
lib,
config,
pkgs,
isNixOS,
hostConfig,
...
}:
{
imports = [
./modules/bootstrap.nix
./modules/theme.nix
./modules/shell.nix
./modules/terminal.nix
./modules/git.nix
./modules/editor.nix
./modules/hyprland.nix
./modules/ui.nix
./modules/packages.nix
];
imports =
[
./modules/bootstrap.nix
./modules/theme.nix
./modules/shell.nix
./modules/terminal.nix
./modules/git.nix
./modules/editor.nix
./modules/packages.nix
]
++ lib.optionals hostConfig.isLinux [
./modules/hyprland.nix
./modules/ui.nix
];
config = {
theme = "midnight";
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";
xdg.enable = true;
targets.genericLinux.enable = !isNixOS;
targets.genericLinux.enable = hostConfig.isLinux && !hostConfig.isNixOS;
news.display = "silent";
home.sessionPath = [ "${config.home.homeDirectory}/.config/nix/scripts" ];
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";
Service = {
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";
Timer = {
OnCalendar = "daily";
@ -52,7 +58,7 @@
Install.WantedBy = [ "timers.target" ];
};
systemd.user.services.theme-apply = {
systemd.user.services.theme-apply = lib.mkIf hostConfig.isLinux {
Unit = {
Description = "Apply theme on login";
After = [ "graphical-session.target" ];
@ -64,7 +70,7 @@
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";
Service = {
Type = "oneshot";

View file

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

View file

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

View file

@ -2,7 +2,7 @@
pkgs,
lib,
config,
isNixOS,
hostConfig,
...
}:
@ -13,21 +13,32 @@ let
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
{
wayland.windowManager.hyprland = {
enable = true;
package = lib.mkIf (!isNixOS) null;
portalPackage = lib.mkIf (!isNixOS) null;
systemd.enable = isNixOS;
package = lib.mkIf (!hostConfig.isNixOS) null;
portalPackage = lib.mkIf (!hostConfig.isNixOS) null;
systemd.enable = hostConfig.isNixOS;
extraConfig = ''
${nvidiaEnv}
source = $XDG_CONFIG_HOME/nix/config/hypr/hyprland.conf
'';
};
home.packages =
lib.optionals isNixOS [
lib.optionals hostConfig.isNixOS [
pkgs.xdg-desktop-portal-gtk
pkgs.hyprpaper
]

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,7 @@
{
imports = [
./hardware-configuration.nix
./hardware.nix
];
boot.loader.systemd-boot = {
@ -16,8 +17,6 @@
};
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelParams = [
"nvidia-drm.modeset=1"
"ibt=off"
"loglevel=3"
"quiet"
];
@ -77,16 +76,6 @@
};
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;
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;
}