nix:use variables

This commit is contained in:
js0ny 2025-11-02 20:24:17 +00:00
parent cf221c7c4b
commit dfcbd50294
14 changed files with 121 additions and 10 deletions

View file

@ -0,0 +1,31 @@
{
lib,
config,
...
}: {
options.currentUser = {
defaultShell = lib.mkOption {
type = lib.types.enum ["zsh" "bash" "fish"];
default = "zsh";
description = "The default shell to use.";
};
defaultTerminal = lib.mkOption {
type = lib.types.str;
default = "ghostty";
description = "The default terminal emulator.";
};
defaultTerminalRunner = lib.mkOption {
type = lib.types.str;
default = config.currentUser.defaultTerminal;
description = "The default terminal emulator to run CLI softwares directly";
};
iconTheme = lib.mkOption {
type = lib.types.str;
default = "Breeze";
description = "Default icon theme";
};
};
}

View file

@ -7,7 +7,16 @@
rofimoji
rofi-power-menu
swaylock-effects
swayidle
xwayland-satellite
wmname
hyprpolkitagent
];
fonts.packages = [pkgs.font-awesome];
xdg.portal = {
extraPortals = with pkgs; [
kdePackages.xdg-desktop-portal-kde
];
config.common.default = ["kde" "wlr"];
};
}

View file

@ -48,4 +48,8 @@
wl-clipboard
libnotify
];
xdg.portal = {
wlr.enable = true;
};
}

View file

@ -9,6 +9,7 @@
pkgs.nerd-fonts.jetbrains-mono
pkgs.nur.repos.definfo.sarasa-term-sc-nerd
pkgs.vollkorn
pkgs.font-awesome
];
in {
environment.systemPackages = fontPkgs;

View file

@ -0,0 +1,10 @@
{
currentUser = {
defaultShell = "zsh";
defaultTerminal = "ghostty";
defaultTerminalRunner = "alacritty";
iconTheme = "Papirus";
};
currentHost = {
};
}

View file

@ -1,7 +1,15 @@
# ~/.config/nixcfgs/users/js0ny/default.nix
{pkgs, ...}: let
{
pkgs,
config,
...
}: let
username = "js0ny";
in {
imports = [
../../modules/home/options.nix
./config.nix
];
home.username = username;
home.homeDirectory =
if pkgs.stdenv.isDarwin
@ -12,5 +20,7 @@ in {
home-manager
];
home.sessionVariables.TERMINAL = config.currentUser.defaultTerminal;
home.stateVersion = "25.05";
}

View file

@ -55,6 +55,8 @@
vivaldi
rustdesk
kdePackages.krdc
kdePackages.breeze
zotero
# Email
protonmail-bridge

View file

@ -1,4 +1,8 @@
{pkgs, ...}: {
{
pkgs,
config,
...
}: {
home.sessionVariables = {
QT_STYLE_OVERRIDE = "adwaita";
};
@ -42,7 +46,7 @@
"org/gnome/desktop/interface" = {
clock-show-seconds = true;
clock-show-weekday = true;
icon-theme = "Papirus";
icon-theme = "${config.currentUser.iconTheme}";
accent-color = "pink";
show-battery-percentage = true;
cursor-theme = "Adwaita";
@ -107,12 +111,12 @@
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom-1" = {
name = "Open Terminal via Win-R";
command = "ghostty";
command = "${config.currentUser.defaultTerminal}";
binding = "<Super>r";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom-2" = {
name = "Open Terminal via Ctrl-Alt-T";
command = "ghostty";
command = "${config.currentUser.defaultTerminal}";
binding = "<Ctrl><Alt>t";
};
"org/gnome/settings-daemon/plugins/media-keys" = {

View file

@ -1,4 +1,8 @@
{pkgs, ...}: {
{
pkgs,
config,
...
}: {
home.packages = [pkgs.miniserve];
home.file.".local/share/kio/servicemenus/miniserve.desktop" = {
text = ''
@ -14,7 +18,7 @@
Name=Map Directory to Port 8080
Name[CN]=(8080)
Icon=network-server
Exec=alacritty -t "miniserve" -e miniserve "%f" --port 8080
Exec=${config.currentUser.defaultTerminalRunner} -t "miniserve" -e miniserve "%f" --port 8080
'';
};
}

View file

@ -0,0 +1,25 @@
{
config,
pkgs,
...
}: {
home.file."${config.xdg.configHome}/niri/config.kdl" = {
text = ''
spawn-at-startup "waybar" // Status Bar
spawn-at-startup "dunst" // Notifications
spawn-at-startup "fcitx5" // Input Method
spawn-at-startup "${pkgs.hyprpolkitagent}/libexec/hyprpolkitagent"
spawn-at-startup
input {
xkb {}
numlock
touchpad {
tap
naturalscroll
}
mouse {}
}
'';
enable = false; # TODO:
};
}

View file

@ -1,4 +1,8 @@
{pkgs, ...}: {
{
pkgs,
config,
...
}: {
home.packages = with pkgs; [
# kdePackages.yakuake
krunner-vscodeprojects
@ -20,7 +24,7 @@
position = "center";
};
workspace = {
iconTheme = "Papirus";
iconTheme = "${config.currentUser.iconTheme}";
colorScheme = "BreezeDark";
};
kwin = {

View file

@ -11,6 +11,7 @@ in {
programs.zsh = {
enable = true;
autocd = true;
# oh-my-zsh.enable = true;
autosuggestion.enable = true;
historySubstringSearch.enable = true;
enableCompletion = true;
@ -42,6 +43,10 @@ in {
#
# bindkey -M viins '^?' backward-delete-char
# bindkey -M viins '^H' backward-kill-word
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' 'r:|=*'
# fzf-tab 模糊匹配
zstyle ':fzf-tab:*' use-fzf-default-bindings yes
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
'';
};

View file

@ -36,6 +36,7 @@
# Desktop Linux
./programs/plasma.nix
./programs/niri.nix
# General Program config
../../modules/home/programs/eza.nix