refactor: modulization

This commit is contained in:
DACHXY 2025-04-09 13:24:02 +08:00
parent a29782681a
commit f6acb92ad0
63 changed files with 680 additions and 1959 deletions

View file

@ -5,7 +5,6 @@ in
{
home.file = {
".config/wallpapers".source = "${configDir}/wallpapers";
".config/kitty".source = "${configDir}/kitty";
".config/neofetch".source = "${configDir}/neofetch";
".config/wlogout".source = "${configDir}/wlogout";
".config/waybar" = {
@ -28,16 +27,11 @@ in
recursive = true;
source = "${configDir}/fcitx5";
};
".config/electron-flags.conf".source = "${configDir}/electron/electron-flags.conf";
".config/ghostty" = {
recursive = true;
source = "${configDir}/ghostty";
};
".face".source = "${configDir}/.face";
".config/yazi" = {
recursive = true;
source = "${configDir}/yazi";
};
};
xdg.mimeApps = {

View file

@ -1,31 +0,0 @@
{ inputs, ... }:
{
imports = [
./git.nix
./gtk.nix
./shell.nix
./config.nix
./packages.nix
./programs.nix
./environment.nix
./virtualization.nix
./hyprland.nix
./swaync.nix
./nvim.nix
./bin.nix
./desktops.nix
./direnv.nix
inputs.hyprland.homeManagerModules.default
];
nixpkgs = {
config = {
allowUnfree = true;
allowUnfreePredicate = _: true;
permittedInsecurePackages = [
"electron-25.9.0" # Obsidian
];
};
};
}

View file

@ -6,8 +6,4 @@
nix-direnv.enable = true;
};
};
home.sessionVariables = {
DIRENV_LOG_FORMAT = ""; # Stop direnv log
};
}

View file

@ -1,5 +1,4 @@
{
pkgs,
inputs,
system,
...
@ -22,34 +21,12 @@ let
# Disable Ctrl+Q
"browser.quitShortcut.disabled" = true;
};
in
{
programs = {
vscode = {
enable = true;
package = pkgs.vscode;
};
yazi = {
enable = true;
package = inputs.yazi.packages.${system}.default;
enableFishIntegration = false;
};
obs-studio = {
enable = true;
plugins = with pkgs.obs-studio-plugins; [
wlrobs
obs-backgroundremoval
obs-pipewire-audio-capture
];
};
firefox = {
enable = true;
# package = (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) { });
package = inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin;
package = inputs.firefox.packages.${system}.firefox-nightly-bin;
languagePacks = [
"en-US"
"zh-TW"

View file

@ -1,13 +1,9 @@
{ git-config, ... }:
let
userName = git-config.username;
email = git-config.email;
in
{ settings, ... }:
{
programs.git = {
enable = true;
userName = userName;
userEmail = email;
userName = settings.personal.git.username;
userEmail = settings.personal.git.email;
extraConfig = {
safe.directory = [ "/etc/nixos" ];
init.defaultBranch = "main";

View file

@ -1,12 +1,12 @@
{
pkgs,
xcursor-size,
settings,
...
}:
let
cursorName = "catppuccin-macchiato-lavender-cursors";
themeName = "catppuccin-macchiato-lavender-compact";
cursorSize = pkgs.lib.strings.toInt xcursor-size;
cursorSize = settings.hyprland.xcursor-size;
in
{
gtk = {
@ -49,6 +49,9 @@ in
libsForQt5.qtstyleplugin-kvantum
libsForQt5.lightly
libsForQt5.qt5ct
adwaita-icon-theme
gsettings-desktop-schemas
glib
(catppuccin-kvantum.override {
accent = "lavender";
variant = "macchiato";

View file

@ -16,7 +16,7 @@ let
dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${terminal}''\'" &
dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" &
dconf write /org/gnome/desktop/interface/cursor-size ${xcursor-size} &
dconf write /org/gnome/desktop/interface/cursor-size ${builtins.toString xcursor-size} &
${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1 &
${swayncScript}/bin/swaync-start &

View file

@ -3,10 +3,8 @@
lib,
inputs,
system,
hyprcursor-size,
xcursor-size,
nvidia-offload-enabled ? false,
monitors ? [ ],
osConfig,
settings,
...
}:
let
@ -18,8 +16,8 @@ let
inputs
system
terminal
xcursor-size
;
xcursor-size = settings.hyprland.xcursor-size;
};
mainMod = "SUPER";
window = import ./hypr/window.nix;
@ -67,7 +65,10 @@ in
debug = {
disable_logs = false;
};
bind = import ./hypr/bind.nix { inherit mainMod nvidia-offload-enabled; };
bind = import ./hypr/bind.nix {
inherit mainMod;
nvidia-offload-enabled = osConfig.hardware.nvidia.prime.offload.enableOffloadCmd;
};
bindm = import ./hypr/bindm.nix { inherit mainMod; };
binde = import ./hypr/binde.nix { inherit mainMod; };
monitor = import ./hypr/monitor.nix;
@ -75,14 +76,14 @@ in
exec-once = ''${startScript}'';
env = [
''HYPRCURSOR_THEME, ${cursorName}''
''HYPRCURSOR_SIZE, ${hyprcursor-size}''
''HYPRCURSOR_SIZE, ${builtins.toString settings.hyprland.cursor-size}''
''XCURSOR_THEME, ${cursorName}''
''XCURSOR_SIZE, ${xcursor-size}''
''XCURSOR_SIZE, ${builtins.toString settings.hyprland.xcursor-size}''
''XDG_CURRENT_DESKTOP, Hyprland''
''XDG_SESSION_DESKTOP, Hyprland''
''GDK_PIXBUF_MODULE_FILE, ${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'' # Make rofi load svg
];
workspace = import ./hypr/workspace.nix { inherit monitors; };
workspace = import ./hypr/workspace.nix { monitors = settings.hyprland.monitors; };
}
// window
// windowrule

View file

@ -1,15 +1,13 @@
{
lib,
pkgs,
unstable,
device-name,
username,
settings,
inputs,
...
}:
let
lazyVim = (
unstable.vimPlugins.LazyVim.overrideAttrs (previous: {
pkgs.vimPlugins.LazyVim.overrideAttrs (previous: {
version = "2025-02-15";
src = pkgs.fetchFromGitHub {
owner = "LazyVim";
@ -23,6 +21,28 @@ in
{
home.packages = with pkgs; [
gh
ripgrep
fd
lua-language-server
nodejs_22
nixfmt-rfc-style
markdownlint-cli2
shfmt
nixd
marksman
nginx-language-server
bash-language-server
tailwindcss-language-server
vscode-langservers-extracted
gopls
pyright
yaml-language-server
marksman
lazygit
# formatter
prettierd
black
];
programs.neovim = {
@ -298,10 +318,10 @@ in
},
options = {
nixos = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${device-name}.options',
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${settings.personal.hostname}.options',
},
home_manager = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."${username}@${device-name}".options',
expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."${settings.personal.username}@${settings.personal.hostname}".options',
}
}
}

View file

@ -1,51 +1,27 @@
{
pkgs,
lib,
nvidia-offload-enabled,
inputs,
system,
osConfig,
...
}:
let
discordIcon = lib.readFile ../../pkgs/assets/discord.svg;
discordSplash = lib.readFile ../../pkgs/assets/peepoLeave.gif.base64;
vesktopOverride = pkgs.vesktop.overrideAttrs (oldAttrs: {
desktopItems = lib.optional pkgs.stdenv.hostPlatform.isLinux (
(lib.head oldAttrs.desktopItems).override {
name = "discord";
desktopName = "Discord";
exec = if nvidia-offload-enabled == true then "nvidia-offload vesktop %U" else "vesktop %U";
}
);
patches = oldAttrs.patches ++ [
../../pkgs/patches/splash.patch
];
# Change Splash
preConfigure = ''
echo "${discordSplash}" | base64 -d > static/peepo.gif
'';
# Change Icon
postInstall = ''
rm -rf $out/share/icons/hicolor/*
mkdir -p $out/share/icons/hicolor/scalable/apps
echo '${discordIcon}' > $out/share/icons/hicolor/scalable/apps/vesktop.svg
'';
});
in
{
home.packages =
(with pkgs; [
with pkgs;
[
# Terminal
inputs.ghostty.packages.${system}.default
# Discord
vesktop
# Dev stuff
gcc
go
(python3.withPackages (python-pkgs: [
python-pkgs.pip
python-pkgs.requests
python-pkgs.weasyprint
]))
rustup
ripdrag
# Work stuff
libreoffice-qt
@ -55,31 +31,38 @@ in
# Bluetooth
blueberry
# Gaming
steam-run
protonup
# Downloads
qbittorrent
# Utils
viewnior
catppuccin-cursors.macchiatoLavender
catppuccin-gtk
cava
papirus-folders
inkscape
# PDF Preview
poppler
trash-cli
])
++ [
vesktopOverride # discord
];
home.sessionVariables = {
# File Manager
nemo
# Thumbnail
ffmpegthumbnailer
]
++ (
if osConfig.programs.steam.enable then
[
steam-run
protonup
]
else
[
]
);
home.sessionVariables = lib.mkIf osConfig.programs.steam.enable {
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
};
}

View file

@ -1,8 +1,21 @@
{ pkgs, ... }:
{ pkgs, settings, ... }:
let
shellAlias = import ./shellAlias.nix;
shellAlias = import ./shellAlias.nix { hostname = settings.personal.hostname; };
in
{
home.packages = with pkgs; [
# Shell
fishPlugins.done
fishPlugins.fzf-fish
fishPlugins.forgit
fishPlugins.hydro
fishPlugins.grc
grc # Colorize
zoxide # Dir jumper
starship # Shell theme
carapace # Autocomplete
];
programs = {
fish = {
enable = true;

View file

@ -1,3 +1,4 @@
{ hostname }:
{
ls = "exa --icons";
lp = "exa"; # Pure output
@ -7,7 +8,7 @@
t = "tmux";
# Nixos
rebuild = "sudo nixos-rebuild switch --flake /etc/nixos";
rebuild = "sudo nixos-rebuild switch --flake /etc/nixos#${hostname}";
fullClean = "sudo nix store gc && sudo /run/current-system/bin/switch-to-configuration boot";
# Hyprland
@ -22,4 +23,7 @@
# TTY
hideTTY = ''sudo sh -c "echo 0 > /sys/class/graphics/fb0/blank"'';
showTTY = ''sudo sh -c "echo 1 > /sys/class/graphics/fb0/blank"'';
# Recover from hyprlock corruption
letMeIn = ''hyprctl --instance 0 "keyword misc:allow_session_lock_restore 1" && hyprctl --instance 0 dispatch "exec hyprlock"'';
}

View file

@ -1,4 +1,5 @@
{ ... }: {
{ ... }:
{
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];

9
home/user/vscode.nix Normal file
View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
programs = {
vscode = {
enable = true;
package = pkgs.vscode;
};
};
}

27
home/user/yazi.nix Normal file
View file

@ -0,0 +1,27 @@
{
inputs,
system,
pkgs,
...
}:
{
programs = {
yazi = {
enable = true;
package = inputs.yazi.packages.${system}.default;
enableFishIntegration = false;
};
};
home.packages = with pkgs; [
# Drag from yazi
ripdrag
];
home.file = {
".config/yazi" = {
recursive = true;
source = ../config/yazi;
};
};
}