Settin : Use module instead of raw nix.

This commit is contained in:
Dmitry Voronin 2024-06-24 13:36:10 +03:00
parent c88f4c2e3f
commit 03500126f8
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
31 changed files with 180 additions and 87 deletions

View file

@ -4,7 +4,6 @@
, style , style
, util , util
, key , key
, setting
, secret , secret
, ... } @args: let , ... } @args: let
# Path where Termux stores user data. # Path where Termux stores user data.

View file

@ -148,7 +148,10 @@
); );
in { in {
# Here I import everything from those directories. # Here I import everything from those directories.
imports = (lsFiles ./module/common) ++ (lsFiles ./overlay) ++ [ ./user/Root.nix ]; imports = (lsFiles ./module/common) ++ (lsFiles ./overlay) ++ [
./part/Setting.nix
./user/Root.nix
];
}; };
# Function to create a host. It does basic setup, like adding common modules. # Function to create a host. It does basic setup, like adding common modules.
@ -194,7 +197,6 @@
flake = self; # This Flake itself. flake = self; # This Flake itself.
inputs = inputs; # Our dependencies. inputs = inputs; # Our dependencies.
secret = import ./part/Secret.nix {}; # Secrets (public keys). secret = import ./part/Secret.nix {}; # Secrets (public keys).
setting = import ./part/Setting.nix {}; # My own global settings.
style = import ./part/Style.nix { inherit config; }; # Style abstraction. style = import ./part/Style.nix { inherit config; }; # Style abstraction.
util = import ./part/Util.nix { inherit pkgs lib; }; # Util functions. util = import ./part/Util.nix { inherit pkgs lib; }; # Util functions.
wallpaper = import ./part/Wallpaper.nix { inherit pkgs; }; # Wallpaper. wallpaper = import ./part/Wallpaper.nix { inherit pkgs; }; # Wallpaper.
@ -347,6 +349,9 @@
# I put all my Android configuration there. # I put all my Android configuration there.
./android ./android
# Common settings.
./part/Setting.nix
]; ];
# SpecialArgs allows you to pass objects down to other configuration. # SpecialArgs allows you to pass objects down to other configuration.
@ -359,7 +364,6 @@
flake = self; # This Flake itself. flake = self; # This Flake itself.
inputs = inputs; # Our dependencies. inputs = inputs; # Our dependencies.
secret = import ./part/Secret.nix {}; # Secrets (public keys). secret = import ./part/Secret.nix {}; # Secrets (public keys).
setting = import ./part/Setting.nix {}; # My own global settings.
style = import ./part/Style.nix { config = import ./part/style/Gruvbox.nix {}; }; # Style abstraction. Stylix is not available for Android so I provide static Gruvbox style. style = import ./part/Style.nix { config = import ./part/style/Gruvbox.nix {}; }; # Style abstraction. Stylix is not available for Android so I provide static Gruvbox style.
util = import ./part/Util.nix { inherit pkgs lib; }; # Util functions. util = import ./part/Util.nix { inherit pkgs lib; }; # Util functions.
}; };

View file

@ -1,5 +1,5 @@
# https://github.com/ollama/ollama # https://github.com/ollama/ollama
{ pkgsStable, lib, setting, ... }: let { pkgsStable, lib, config, ... }: let
pkgs = pkgsStable; pkgs = pkgsStable;
in { in {
environment = { environment = {
@ -7,7 +7,7 @@ in {
systemPackages = with pkgs; [ ollama ]; systemPackages = with pkgs; [ ollama ];
# Specify default model. # Specify default model.
variables.OLLAMA_MODEL = setting.ollama.primaryModel; variables.OLLAMA_MODEL = config.setting.ollama.primaryModel;
}; };
# Enable Ollama server. # Enable Ollama server.
@ -31,7 +31,7 @@ in {
serviceConfig.Type = "simple"; serviceConfig.Type = "simple";
script = '' script = ''
sleep 5 sleep 5
${lib.getExe pkgs.ollama} pull ${setting.ollama.primaryModel} ${lib.getExe pkgs.ollama} pull ${config.setting.ollama.primaryModel}
''; '';
}; };
} }

View file

@ -1,4 +1,4 @@
{ pkgs, setting, ... }: { { pkgs, config, ... }: {
environment.systemPackages = with pkgs; [ keyd ]; environment.systemPackages = with pkgs; [ keyd ];
services.keyd = { services.keyd = {
@ -10,7 +10,7 @@
backspace = "delete"; # Delete key on backspace. backspace = "delete"; # Delete key on backspace.
capslock = "overload(control, esc)"; # Ctrl/esc combo. capslock = "overload(control, esc)"; # Ctrl/esc combo.
compose = "layer(layer_number)"; # Number input layer. compose = "layer(layer_number)"; # Number input layer.
esc = "${setting.sysctrl}"; # System controls. esc = "${config.setting.sysctrl}"; # System controls.
leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc. leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc.
rightcontrol = "layer(layer_control)"; # Media and other controls. rightcontrol = "layer(layer_control)"; # Media and other controls.
rightshift = "backspace"; # Backspace. rightshift = "backspace"; # Backspace.

View file

@ -1,4 +1,4 @@
{ inputs, pkgs, util, key, setting, ... } @args: let { inputs, pkgs, util, key, config, ... } @args: let
nvim = import ./nvim args; nvim = import ./nvim args;
in { in {
environment = { environment = {

View file

@ -1,7 +1,7 @@
{ setting, ... }: { { config, ... }: {
text = '' text = ''
require("ollama").setup { require("ollama").setup {
model = "${setting.ollama.primaryModel}", model = "${config.setting.ollama.primaryModel}",
url = "http://127.0.0.1:11434", url = "http://127.0.0.1:11434",
-- View the actual default prompts in ./lua/ollama/prompts.lua -- View the actual default prompts in ./lua/ollama/prompts.lua
prompts = { prompts = {

View file

@ -1,3 +1,3 @@
{ style, key, util, setting, ... } @args: { { style, key, util, config, ... } @args: {
config = util.catText (util.ls ./module) args; config = util.catText (util.ls ./module) args;
} }

View file

@ -1,4 +1,4 @@
{ pkgs, pkgsStable, pkgsMaster, setting, ... } @args: let { pkgs, pkgsStable, pkgsMaster, config, ... } @args: let
mangohud = import ./mangohud args; mangohud = import ./mangohud args;
in { in {
imports = [ imports = [
@ -69,7 +69,7 @@ in {
# Terminal settings. # Terminal settings.
TERM = "xterm-256color"; TERM = "xterm-256color";
TERMINAL = setting.terminal.bin; TERMINAL = config.setting.terminal.bin;
}; };
}; };

View file

@ -1,7 +1,7 @@
{ setting, ... }: { { config, ... }: {
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.xkb = { services.xserver.xkb = {
layout = setting.keyboard.layouts; layout = config.setting.keyboard.layouts;
options = setting.keyboard.options; options = config.setting.keyboard.options;
}; };
} }

View file

@ -1,11 +1,11 @@
{ lib, setting, ... }: { { lib, config, ... }: {
"org/gnome/desktop/input-sources" = with lib.gvariant; { "org/gnome/desktop/input-sources" = with lib.gvariant; {
current = mkUint32 0; current = mkUint32 0;
mru-sources = [ (mkTuple [ "xkb" "us" ]) (mkTuple [ "xkb" "ru" ]) ]; mru-sources = [ (mkTuple [ "xkb" "us" ]) (mkTuple [ "xkb" "ru" ]) ];
per-window = false; per-window = false;
show-all-sources = true; show-all-sources = true;
sources = [ (mkTuple [ "xkb" "us" ]) (mkTuple [ "xkb" "ru" ]) ]; sources = [ (mkTuple [ "xkb" "us" ]) (mkTuple [ "xkb" "ru" ]) ];
xkb-options = [ setting.keyboard.options ]; xkb-options = [ config.setting.keyboard.options ];
}; };
"org/gnome/desktop/peripherals/mouse" = { "org/gnome/desktop/peripherals/mouse" = {

View file

@ -1,4 +1,4 @@
{ setting, ... }: let { config, ... }: let
mod = "<Super>"; mod = "<Super>";
in { in {
"org/gnome/desktop/wm/keybindings" = { "org/gnome/desktop/wm/keybindings" = {
@ -82,31 +82,31 @@ in {
}; };
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = {
binding = "${setting.sysctrl}z"; binding = "${config.setting.sysctrl}z";
command = "systemctl suspend -i"; command = "systemctl suspend -i";
name = "System Sleep"; name = "System Sleep";
}; };
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = { "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = {
binding = "${setting.sysctrl}x"; binding = "${config.setting.sysctrl}x";
command = "systemctl poweroff -i"; command = "systemctl poweroff -i";
name = "System Poweroff"; name = "System Poweroff";
}; };
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = {
binding = "${setting.sysctrl}c"; binding = "${config.setting.sysctrl}c";
command = "systemctl reboot -i"; command = "systemctl reboot -i";
name = "System Reboot"; name = "System Reboot";
}; };
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = {
binding = "${setting.sysctrl}p"; binding = "${config.setting.sysctrl}p";
command = "powersave toggle"; command = "powersave toggle";
name = "Toggle Powersave"; name = "Toggle Powersave";
}; };
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5" = { "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5" = {
binding = "${setting.sysctrl}l"; binding = "${config.setting.sysctrl}l";
command = "powerlimit toggle"; command = "powerlimit toggle";
name = "Toggle Powerlimit"; name = "Toggle Powerlimit";
}; };

View file

@ -1,4 +1,4 @@
{ pkgs, wallpaper, style, util, setting, ... } @args: let { pkgs, wallpaper, style, util, config, ... } @args: let
# Order is required for Sway configuration. # Order is required for Sway configuration.
swayRc = util.catText [ swayRc = util.catText [
./module/Style.nix ./module/Style.nix

View file

@ -1,5 +1,5 @@
{ setting, ... }: let { config, ... }: let
step = setting.step.brightness; step = config.setting.step.brightness;
in { in {
text = '' text = ''
bindsym XF86MonBrightnessDown exec light -U ${toString step} bindsym XF86MonBrightnessDown exec light -U ${toString step}

View file

@ -1,4 +1,4 @@
{ setting, ... }: { { config, ... }: {
text = '' text = ''
### Input configuration ### Input configuration
# #
@ -33,11 +33,11 @@
} }
input type:keyboard { input type:keyboard {
xkb_layout ${setting.keyboard.layouts} xkb_layout ${config.setting.keyboard.layouts}
xkb_options ${setting.keyboard.options} xkb_options ${config.setting.keyboard.options}
} }
# Hide mouse cursor after a period of inactivity. # Hide mouse cursor after a period of inactivity.
seat seat0 hide_cursor ${toString setting.timeout.popup} seat seat0 hide_cursor ${toString config.setting.timeout.popup}
''; '';
} }

View file

@ -1,6 +1,6 @@
{ setting, ... }: let { config, ... }: let
step_volume = setting.step.volume; step_volume = config.setting.step.volume;
step_music = setting.step.media; step_music = config.setting.step.media;
in { in {
text = '' text = ''
bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%' bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%'

View file

@ -1,5 +1,5 @@
{ setting, ... }: let { config, ... }: let
mod = setting.sysctrl; mod = config.setting.sysctrl;
in { in {
text = '' text = ''
bindsym ${mod}+c exec 'systemctl reboot -i' bindsym ${mod}+c exec 'systemctl reboot -i'

View file

@ -1,6 +1,6 @@
{ setting, ... }: { { config, ... }: {
text = '' text = ''
set $term ${setting.terminal.bin} set $term ${config.setting.terminal.bin}
bindsym $mod+Escape exec $term -e bash -c "tmux new-session -A -s $USER; bash" bindsym $mod+Escape exec $term -e bash -c "tmux new-session -A -s $USER; bash"
''; '';

View file

@ -1,4 +1,4 @@
{ setting, style, pkgs, ... }: let { config, style, pkgs, ... }: let
refreshInterval = 2; refreshInterval = 2;
in { in {
file = (pkgs.formats.json {}).generate "WaybarConfig" { file = (pkgs.formats.json {}).generate "WaybarConfig" {
@ -73,7 +73,7 @@ in {
on-click-right = "powerlimit toggle"; on-click-right = "powerlimit toggle";
}; };
pulseaudio = { pulseaudio = {
scroll-step = setting.step.volume; scroll-step = config.setting.step.volume;
format = "{volume}% {icon}"; format = "{volume}% {icon}";
format-muted = "󰸈"; format-muted = "󰸈";
format-icons = { format-icons = {
@ -100,26 +100,26 @@ in {
cpu = { cpu = {
format = "{usage}% ({load})"; format = "{usage}% ({load})";
interval = refreshInterval; interval = refreshInterval;
on-click = "${setting.terminal.bin} -e bash -c btop"; on-click = "${config.setting.terminal.bin} -e bash -c btop";
on-click-right = "powersave toggle"; on-click-right = "powersave toggle";
tooltip = false; tooltip = false;
}; };
memory = { memory = {
format = "{percentage}%"; format = "{percentage}%";
interval = refreshInterval; interval = refreshInterval;
on-click = "${setting.terminal.bin} -e bash -c btop"; on-click = "${config.setting.terminal.bin} -e bash -c btop";
on-click-right = "powersave toggle"; on-click-right = "powersave toggle";
}; };
temperature = { temperature = {
format = "{temperatureC}°C"; format = "{temperatureC}°C";
interval = refreshInterval; interval = refreshInterval;
on-click = "${setting.terminal.bin} -e bash -c btop"; on-click = "${config.setting.terminal.bin} -e bash -c btop";
on-click-right = "powersave toggle"; on-click-right = "powersave toggle";
}; };
"custom/powersave" = { "custom/powersave" = {
exec = "powersave waybar"; exec = "powersave waybar";
interval = refreshInterval; interval = refreshInterval;
on-click = "${setting.terminal.bin} -e bash -c btop"; on-click = "${config.setting.terminal.bin} -e bash -c btop";
on-click-right = "powersave toggle"; on-click-right = "powersave toggle";
}; };
"custom/display" = { "custom/display" = {

View file

@ -1,29 +1,119 @@
# Global settings. # Global settings.
# Just like I can configure each package, here I configure my config! :O) # Just like I can configure each package, here I configure my config! :O)
{ ... }: { { pkgs
ollama.primaryModel = "llama3"; , config
browser.bin = "firefox-esr"; ,lib
terminal.bin = "foot"; , ... }: {
dpiAware = false; options.setting = with lib; {
sysctrl = "print"; ollama = mkOption {
default = { };
type = types.submodule {
# freeformType = lib.jsonFormat.type;
options = {
primaryModel = mkOption {
default = "llama3";
type = types.str;
};
};
};
};
keyboard = { browser = mkOption {
layouts = "us,ru"; default = { };
options = "grp:toggle"; type = types.submodule {
}; options = {
bin = mkOption {
default = "firefox-esr";
type = types.str;
};
};
};
};
refresh = { terminal = mkOption {
top = 2000; default = { };
}; type = types.submodule {
options = {
bin = mkOption {
default = "foot";
type = types.str;
};
};
};
};
step = { dpiAware = mkOption {
brightness = 5; default = false;
volume = 5; type = types.bool;
media = 10; };
};
timeout = { sysctrl = mkOption {
popup = 5000; default = "print";
keyd = 150; type = types.str;
};
keyboard = mkOption {
default = { };
type = types.submodule {
options = {
layouts = mkOption {
default = "us,ru";
type = types.str;
};
options = mkOption {
default = "grp:toggle";
type = types.str;
};
};
};
};
refresh = mkOption {
default = { };
type = types.submodule {
options = {
top = mkOption {
default = 2000;
type = types.int;
};
};
};
};
step = mkOption {
default = { };
type = types.submodule {
options = {
brightness = mkOption {
default = 5;
type = types.int;
};
volume = mkOption {
default = 5;
type = types.int;
};
media = mkOption {
default = 10;
type = types.int;
};
};
};
};
timeout = mkOption {
default = { };
type = types.submodule {
options = {
popup = mkOption {
default = 5000;
type = types.int;
};
keyd = mkOption {
default = 150;
type = types.int;
};
};
};
};
}; };
} }

View file

@ -3,7 +3,7 @@
, style , style
, pkgs , pkgs
, lib , lib
, setting , config
, key , key
, secret , secret
, ... } @args: { , ... } @args: {

View file

@ -2,7 +2,7 @@
, util , util
, style , style
, pkgs , pkgs
, setting , config
, key , key
, secret , secret
, ... } @args: { , ... } @args: {

View file

@ -3,7 +3,7 @@
, style , style
, pkgs , pkgs
, lib , lib
, setting , config
, key , key
, secret , secret
, ... } @args: { , ... } @args: {

View file

@ -4,7 +4,7 @@
, key , key
, pkgs , pkgs
, secret , secret
, setting , config
, style , style
, username , username
, util , util

View file

@ -1,5 +1,5 @@
{ style, setting, pkgs, ... }: let { style, config, pkgs, ... }: let
dpiAware = if setting.dpiAware then "yes" else "no"; dpiAware = if config.setting.dpiAware then "yes" else "no";
fontStep = 1; fontStep = 1;
in { in {
file = (pkgs.formats.iniWithGlobalSection {}).generate "FootConfig" { file = (pkgs.formats.iniWithGlobalSection {}).generate "FootConfig" {

View file

@ -1,5 +1,5 @@
{ pkgs, style, setting, ... }: let { pkgs, style, config, ... }: let
dpiAware = if setting.dpiAware then "yes" else "no"; dpiAware = if config.setting.dpiAware then "yes" else "no";
in { in {
file = (pkgs.formats.ini {}).generate "FuzzelConfig" { file = (pkgs.formats.ini {}).generate "FuzzelConfig" {
main = { main = {
@ -8,7 +8,7 @@ in {
lines = 20; lines = 20;
prompt = "\"\""; prompt = "\"\"";
show-actions = "yes"; show-actions = "yes";
terminal = setting.terminal.bin; terminal = config.setting.terminal.bin;
width = 40; width = 40;
# list-executables-in-path = "no"; # list-executables-in-path = "no";
}; };

View file

@ -1,4 +1,4 @@
{ setting, pkgs, ... }: { { config, pkgs, ... }: {
file = (pkgs.formats.ini {}).generate "KeydDrgConfig" { file = (pkgs.formats.ini {}).generate "KeydDrgConfig" {
steam-app-548430 = { steam-app-548430 = {
"alt.1" = "macro(enter 10ms L e t ' s space d o space t h i s space T e x a s space s t y l e ! enter)"; "alt.1" = "macro(enter 10ms L e t ' s space d o space t h i s space T e x a s space s t y l e ! enter)";
@ -26,7 +26,7 @@
"alt.w" = "macro(enter 10ms r enter)"; "alt.w" = "macro(enter 10ms r enter)";
"alt.x" = "macro(enter 10ms > space H e r e space < enter)"; "alt.x" = "macro(enter 10ms > space H e r e space < enter)";
"alt.z" = "macro(enter 10ms < space L e f t enter)"; "alt.z" = "macro(enter 10ms < space L e f t enter)";
leftshift = "timeout(leftcontrol, ${toString setting.timeout.keyd}, leftshift)"; leftshift = "timeout(leftcontrol, ${toString config.setting.timeout.keyd}, leftshift)";
}; };
}; };
} }

View file

@ -1,4 +1,4 @@
{ setting, pkgs, ... }: { { config, pkgs, ... }: {
file = (pkgs.formats.ini {}).generate "KeydJetbrainsConfig" { file = (pkgs.formats.ini {}).generate "KeydJetbrainsConfig" {
"jetbrains-*" = { "jetbrains-*" = {
"alt./" = "C-/"; "alt./" = "C-/";
@ -16,7 +16,7 @@
"alt.q" = "A-left"; "alt.q" = "A-left";
"alt.r" = "S-f10"; "alt.r" = "S-f10";
"alt.s" = "C-A-s"; "alt.s" = "C-A-s";
"alt.tab" = "timeout(f8, ${toString setting.timeout.keyd}, macro2(0, 0, f7))"; "alt.tab" = "timeout(f8, ${toString config.setting.timeout.keyd}, macro2(0, 0, f7))";
"alt.v" = "C-q"; "alt.v" = "C-q";
"alt.w" = "C-S-A-t"; "alt.w" = "C-S-A-t";
"alt.x" = "C-f4"; "alt.x" = "C-f4";

View file

@ -1,4 +1,4 @@
{ style, pkgs, setting, ... }: let { style, pkgs, config, ... }: let
alpha = style.opacity.hex; alpha = style.opacity.hex;
in { in {
file = (pkgs.formats.iniWithGlobalSection {}).generate "MakoConfig" { file = (pkgs.formats.iniWithGlobalSection {}).generate "MakoConfig" {
@ -6,7 +6,7 @@ in {
anchor = "top-center"; anchor = "top-center";
background-color = "#${style.color.bg.dark}${alpha}"; background-color = "#${style.color.bg.dark}${alpha}";
border-color = "#${style.color.border}${alpha}"; border-color = "#${style.color.border}${alpha}";
default-timeout = setting.timeout.popup; default-timeout = config.setting.timeout.popup;
font = "${style.font.serif.name} ${toString style.font.size.popup}"; font = "${style.font.serif.name} ${toString style.font.size.popup}";
height = 120; height = 120;
icons = 0; icons = 0;

View file

@ -1,4 +1,4 @@
{ setting, util, ... }: { { config, util, ... }: {
text = util.trimTabs '' text = util.trimTabs ''
#? Config file for btop v. 1.3.0 #? Config file for btop v. 1.3.0
@ -55,7 +55,7 @@
shown_boxes = "cpu mem net proc" shown_boxes = "cpu mem net proc"
#* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs. #* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs.
update_ms = ${toString setting.refresh.top} update_ms = ${toString config.setting.refresh.top}
#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct", #* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct",
#* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly. #* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly.

View file

@ -1,4 +1,4 @@
{ pkgs, setting, util, ... } @args: { { pkgs, config, util, ... } @args: {
init = (import ./module/Init.nix args).file; init = (import ./module/Init.nix args).file;
keymap = (import ./module/Keymap.nix args).file; keymap = (import ./module/Keymap.nix args).file;
theme = (import ./module/Theme.nix args).file; theme = (import ./module/Theme.nix args).file;

View file

@ -1,4 +1,4 @@
{ pkgs, setting, ... }: { { pkgs, config, ... }: {
file = (pkgs.formats.toml {}).generate "YaziYaziConfig" { file = (pkgs.formats.toml {}).generate "YaziYaziConfig" {
manager = { manager = {
# linemode = "mtime"; # linemode = "mtime";
@ -30,7 +30,7 @@
browser = [{ browser = [{
desc = "Browser"; desc = "Browser";
orphan = true; orphan = true;
run = openWith setting.browser.bin; run = openWith config.setting.browser.bin;
}]; }];
text = [{ text = [{
desc = "Text"; desc = "Text";