treewide: move defaults to dedicated folder

This commit is contained in:
Elec3137 2026-03-23 20:41:34 -07:00
commit 00c06f982b
6 changed files with 0 additions and 0 deletions

56
defaults/default.nix Normal file
View file

@ -0,0 +1,56 @@
{
lib,
config,
...
}:
let
name = "graphical";
cfg = config.nixowos.${name};
in
{
imports = [
./plasma.nix
./nvidia.nix
./games
./jp.nix
./mpv.nix
./virt.nix
];
options.nixowos.${name} = {
enable = lib.mkEnableOption name;
};
config = lib.mkIf cfg.enable {
nixowos.${name} = lib.mkDefault {
plasma.enable = config.services.desktopManager.plasma6.enable;
mpv.enable = true;
};
programs.firefox = lib.mkDefault {
policies = {
ExtensionSettings = {
"uBlock0@raymondhill.net" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
};
};
Preferences = {
"browser.newtabpage.activity-stream.feeds.wallpaperfeed".Value = false;
"browser.newtabpage.activity-stream.feeds.weatherfeed".Value = false;
# from https://discourse.nixos.org/t/declare-firefox-extensions-and-settings/36265
"browser.newtabpage.activity-stream.feeds.section.topstories".Value = false;
"browser.newtabpage.activity-stream.feeds.snippets".Value = false;
"browser.newtabpage.activity-stream.section.highlights.includePocket".Value = false;
"browser.newtabpage.activity-stream.section.highlights.includeBookmarks".Value = false;
"browser.newtabpage.activity-stream.section.highlights.includeDownloads".Value = false;
"browser.newtabpage.activity-stream.section.highlights.includeVisited".Value = false;
"browser.newtabpage.activity-stream.showSponsored".Value = false;
"browser.newtabpage.activity-stream.system.showSponsored".Value = false;
"browser.newtabpage.activity-stream.showSponsoredTopSites".Value = false;
};
};
};
};
}

47
defaults/git.nix Normal file
View file

@ -0,0 +1,47 @@
{
pkgs,
lib,
config,
...
}:
let
name = "git";
cfg = config.nixowos.cli.${name};
in
{
options.nixowos.cli.${name} = {
enable = lib.mkEnableOption name;
delta.enable = lib.mkEnableOption "delta within git" // {
default = true;
};
};
config = lib.mkIf cfg.enable {
programs.git = {
enable = true;
config = lib.mkMerge [
{
init.defaultBranch = "main";
core.compression = 9; # max
credential.helper = "cache";
push.autoSetupRemote = true;
pull.ff = "only";
merge.conflictStyle = "zdiff3";
commit.verbose = true; # show diffs in commit editor
}
(lib.mkIf cfg.delta.enable {
core.pager = "${pkgs.delta}/bin/delta";
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
delta.navigate = true; # use n and N to move between diff sections
delta.diff-highlight = true; # simpler mode, highlights inter-line changes
})
];
};
};
}

67
defaults/jp.nix Normal file
View file

@ -0,0 +1,67 @@
{
pkgs,
lib,
config,
...
}:
let
name = "jp";
cfg = config.nixowos.graphical.${name};
in
{
options.nixowos.graphical.${name} = {
enable = lib.mkEnableOption "cjk fonts and fcitx5-mozc for ${name} input";
};
config = lib.mkIf cfg.enable {
# enable default fonts (helps with emojis, etc)
fonts.enableDefaultPackages = lib.mkDefault true;
# for higher quality asian fonts
# without this, chromium might not render asian text at all
fonts.packages = [ pkgs.noto-fonts-cjk-sans ];
# for typing in japanese
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5 = {
waylandFrontend = true;
addons = with pkgs; [
fcitx5-mozc # japanese module
fcitx5-gtk
];
settings.globalOptions = {
# also require "alt" for triggering IME
# this is to avoid conflicts with other apps/games
"Hotkey/TriggerKeys"."0" = "Control+Alt+space";
};
# basic configuration for switching between normal mode and mozc
settings.inputMethod = {
"Groups/0" = {
Name = "Default";
"Default Layout" = "us";
DefaultIM = "mozc";
};
"Groups/0/Items/0" = {
Name = "keyboard-us";
Layout = "us";
};
"Groups/0/Items/1" = {
Name = "mozc";
Layout = "us";
};
GroupOrder."0" = "Default";
};
settings.addons.classicui.globalSection.Theme =
lib.mkIf config.services.desktopManager.plasma6.enable "plasma";
};
};
};
}

52
defaults/plasma.nix Normal file
View file

@ -0,0 +1,52 @@
{
pkgs,
lib,
config,
...
}:
let
name = "plasma";
cfg = config.nixowos.graphical.${name};
in
{
options.nixowos.graphical.${name} = {
enable = lib.mkEnableOption name;
startOnFirstTTY = lib.mkEnableOption "starting plasma from tty1" // {
description = ''
Whether to start ${name} automatically from tty1.
note: this replaces sddm, which also means kwallet will not be unlocked automatically.
kwallet is responsible for storing secrets, using your password for encryption.
It's used by browsers, NetworkManager, and many more.
'';
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
kdePackages.plasma-keyboard
kdePackages.qtvirtualkeyboard
wl-clipboard
];
environment.interactiveShellInit =
lib.mkIf cfg.startOnFirstTTY
/* sh */ "test $(tty) = /dev/tty1 && startplasma-wayland";
services.displayManager.sddm.enable = lib.mkIf cfg.startOnFirstTTY false;
# remove plasma6 packages included by default
# from optionalPackages defined in nixpkgs/nixos/modules/services/desktop-managers/plasma6.nix
environment.plasma6.excludePackages = with pkgs.kdePackages; [
plasma-workspace-wallpapers
kwin-x11
elisa
krdp
];
# use kdeconnect (opens ports)
programs.kdeconnect.enable = true;
};
}

38
defaults/shell.nix Normal file
View file

@ -0,0 +1,38 @@
{
pkgs,
lib,
config,
...
}:
let
name = "shell";
cfg = config.nixowos.cli.${name};
# use a more verbose output style for nix than default
# only lix supports log-format = multiline-with-logs
logFormat = if config.nixowos.system.lix.enable then "multiline-with-logs" else "bar-with-logs";
in
{
options.nixowos.cli.${name} = {
enable = lib.mkEnableOption name;
};
config = lib.mkIf cfg.enable {
# use Fish, the nicest shell :)
programs.fish.enable = true;
users.defaultUserShell = pkgs.fish;
# avoid generating caches (enabled by fish) due to slowdowns during nixos-rebuild
# this may degrade autocompletion
documentation.man.generateCaches = false;
environment.shellAliases = {
# make nix-shell preserve the user's $SHELL
nix-shell = /* sh */ ''nix-shell --command "export SHELL=$SHELL; $SHELL"'';
nixos-rebuild = /* sh */ "nixos-rebuild --ask-sudo-password --log-format ${logFormat}";
nix = /* sh */ "nix --log-format ${logFormat}";
};
};
}

58
defaults/tmux.nix Normal file
View file

@ -0,0 +1,58 @@
{
lib,
config,
...
}:
let
name = "tmux";
cfg = config.nixowos.cli.${name};
in
{
options.nixowos.cli.${name} = {
enable = lib.mkEnableOption name;
};
config = lib.mkIf cfg.enable {
programs.tmux = lib.mkDefault {
enable = true;
# this is a sin committed for ergonomics
# since "1" and "0" are quite far apart on most keyboards
baseIndex = 1;
keyMode = "vi";
# https://unix.stackexchange.com/questions/608142/whats-the-effect-of-escape-time-in-tmux
escapeTime = 50;
clock24 = true;
extraConfig = /* sh */ ''
set -g mouse on
# open new shells in the same working directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
###### STYLING
set -g status-style 'fg=pink'
setw -g window-status-style 'fg=pink bg=black'
setw -g window-status-format ' #I #[fg=white]#W #[fg=pink]#F '
setw -g window-status-current-style 'fg=black bg=pink'
setw -g window-status-current-format ' #I #W #F '
set -g message-style 'fg=black bg=pink'
set -g mode-style 'fg=black bg=pink'
set -g pane-border-style 'fg=grey'
set -g pane-active-border-style 'fg=pink'
'';
};
};
}