From 211e5096282e06fc72f61da950ebebed347c5b88 Mon Sep 17 00:00:00 2001 From: unexplrd Date: Thu, 3 Apr 2025 17:57:49 +0300 Subject: [PATCH] steal from MaxMur Signed-off-by: unexplrd --- modules/home/desktop/hyprland/default.nix | 17 ++++----- modules/home/desktop/niri/default.nix | 25 ++++++------- modules/home/programs/console/joshuto.nix | 8 ++--- modules/home/programs/editor/helix.nix | 12 +++---- modules/home/programs/editor/nixvim.nix | 13 +++---- modules/home/programs/editor/zed.nix | 30 ++++++++-------- modules/nixos/desktop/cosmic.nix | 5 +-- modules/nixos/system/misc/locale.nix | 36 ++++++++++--------- .../nixos/system/misc/opentabletdriver.nix | 8 +++-- modules/nixos/system/misc/qmk-vial.nix | 12 +++---- modules/nixos/system/security/basic.nix | 12 +++---- 11 files changed, 94 insertions(+), 84 deletions(-) diff --git a/modules/home/desktop/hyprland/default.nix b/modules/home/desktop/hyprland/default.nix index 6f0a6f3..e4e6517 100644 --- a/modules/home/desktop/hyprland/default.nix +++ b/modules/home/desktop/hyprland/default.nix @@ -6,24 +6,25 @@ lib, ... }: let + inherit (config.stylix) colors; + inherit (lib) mkIf mkEnableOption mkDefault mkForce getExe; cfg = config.desktop.hyprland; hostname = osConfig.networking.hostName; cursorSize = config.stylix.cursor.size; fontName = config.stylix.fonts.sansSerif.name; - inherit (config.lib.stylix) colors; keyboard = if hostname == "eldrid" then "chromeos" else "platform"; xdgPictures = config.xdg.userDirs.pictures; - ifLaptop = lib.mkIf (hostname != "dunamis"); + ifLaptop = mkIf (hostname != "dunamis"); in { options = { desktop.hyprland.enable = - lib.mkEnableOption "enable hyprland desktop"; + mkEnableOption "enable hyprland desktop"; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { stylix.targets.waybar.enable = false; stylix.targets.hyprland.enable = false; stylix.targets.hyprlock.enable = false; @@ -507,7 +508,7 @@ in { }; qt = { enable = true; - platformTheme.name = lib.mkDefault "gtk3"; + platformTheme.name = mkDefault "gtk3"; }; dconf.settings = { "org/gnome/desktop/interface" = { @@ -1017,7 +1018,7 @@ in { width = 300; height = 300; icon_theme = "${config.dconf.settings."org/gnome/desktop/interface".icon-theme}"; - corner_radius = lib.mkDefault 9; + corner_radius = mkDefault 9; #corners = "top-right,bottom-left"; offset = "16x16"; origin = "bottom-right"; @@ -1230,7 +1231,7 @@ in { Service = graphicalService.Service // { - Environment = lib.mkForce "QT_QPA_PLATFORM=wayland"; + Environment = mkForce "QT_QPA_PLATFORM=wayland"; }; }; hyprpolkitagent = mkGraphicalService { @@ -1252,7 +1253,7 @@ in { // { Type = "simple"; Slice = "session.slice"; - ExecStart = "${lib.getExe perSystem.hyprsunset.hyprsunset} -t 6500"; + ExecStart = "${getExe perSystem.hyprsunset.hyprsunset} -t 6500"; }; }; }; diff --git a/modules/home/desktop/niri/default.nix b/modules/home/desktop/niri/default.nix index 6276cdd..87b039b 100644 --- a/modules/home/desktop/niri/default.nix +++ b/modules/home/desktop/niri/default.nix @@ -5,9 +5,10 @@ lib, ... }: let - cfg = config.desktop.niri; + inherit (lib) mkIf mkEnableOption mkDefault mkForce getExe; inherit (osConfig.networking) hostId; - inherit (config.lib.stylix) colors; + inherit (config.stylix) colors; + cfg = config.desktop.niri; cursorSize = config.stylix.cursor.size; cursorName = config.stylix.cursor.name; keyboard = @@ -16,18 +17,18 @@ else "platform"; xdgPics = config.xdg.userDirs.pictures; - ifLaptop = lib.mkIf (hostId != "c7f6c4a1"); + ifLaptop = mkIf (hostId != "c7f6c4a1"); # TODO: make terminal depent on thing outside a module - terminal = lib.getExe pkgs.wezterm; - launcher = lib.getExe pkgs.fuzzel; + terminal = getExe pkgs.wezterm; + launcher = getExe pkgs.fuzzel; browser = "app.zen_browser.zen"; - lockscreen = lib.getExe pkgs.gtklock; + lockscreen = getExe pkgs.gtklock; in { options = { desktop.niri.enable = - lib.mkEnableOption "enable niri desktop"; + mkEnableOption "enable niri desktop"; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { stylix.targets = { waybar.enable = false; wpaperd.enable = true; @@ -274,7 +275,7 @@ in { match-mode = "fuzzy"; icon-theme = "${config.dconf.settings."org/gnome/desktop/interface".icon-theme}"; }; - border = lib.mkDefault { + border = mkDefault { width = 3; radius = 12; }; @@ -1039,7 +1040,7 @@ in { Service = graphicalService.Service // { - Environment = lib.mkForce "QT_QPA_PLATFORM=wayland"; + Environment = mkForce "QT_QPA_PLATFORM=wayland"; }; }; xwayland-satellite = mkGraphicalService { @@ -1047,12 +1048,12 @@ in { graphicalService.Service // { Type = "simple"; - ExecStart = lib.getExe pkgs.xwayland-satellite + " :123"; + ExecStart = getExe pkgs.xwayland-satellite + " :123"; }; }; wpaperd = mkGraphicalService { Service = - lib.mkDefault graphicalService.Service; + mkDefault graphicalService.Service; }; gnome-polkit-agent = mkGraphicalService { Service = diff --git a/modules/home/programs/console/joshuto.nix b/modules/home/programs/console/joshuto.nix index 08904c5..5736224 100644 --- a/modules/home/programs/console/joshuto.nix +++ b/modules/home/programs/console/joshuto.nix @@ -3,8 +3,8 @@ config, lib, ... -}: -with lib; let +}: let + inherit (lib) mkIf mkEnableOption; cfg = config.console.joshuto; in { options = { @@ -204,7 +204,7 @@ in { # ''; # }; # in - lib.mkIf cfg.enable { + mkIf cfg.enable { home.packages = [pkgs.file]; programs.joshuto = { enable = true; @@ -223,7 +223,7 @@ in { column_ratio = [1 5 2]; }; preview = { - # preview_script = lib.getExe pkgs.pistol; + # preview_script = getExe pkgs.pistol; use_xdg_thumbs = true; xdg_thumb_size = "xxlarge"; }; diff --git a/modules/home/programs/editor/helix.nix b/modules/home/programs/editor/helix.nix index 259e044..c4fc8ae 100644 --- a/modules/home/programs/editor/helix.nix +++ b/modules/home/programs/editor/helix.nix @@ -3,8 +3,8 @@ config, lib, ... -}: -with lib; let +}: let + inherit (lib) mkIf mkEnableOption getExe; cfg = config.editor.helix; in { options = { @@ -61,7 +61,7 @@ in { }; }; languages = { - language-server = with lib; { + language-server = { clangd.command = "${pkgs.clang-tools}/bin/clangd"; markdown-oxide.command = getExe pkgs.markdown-oxide; # nil.command = getExe pkgs.nil; @@ -74,7 +74,7 @@ in { { name = "nix"; auto-format = true; - formatter.command = lib.getExe pkgs.alejandra; + formatter.command = getExe pkgs.alejandra; language-servers = ["nixd"]; } # { @@ -86,7 +86,7 @@ in { { name = "typst"; auto-format = true; - formatter.command = lib.getExe pkgs.typstyle; + formatter.command = getExe pkgs.typstyle; language-servers = ["tinymist"]; } { @@ -109,7 +109,7 @@ in { # name = "rust"; # auto-format = true; # language-servers = ["rust-analyzer"]; - # formatter.command = lib.getExe pkgs.rustfmt; + # formatter.command = getExe pkgs.rustfmt; # } ]; }; diff --git a/modules/home/programs/editor/nixvim.nix b/modules/home/programs/editor/nixvim.nix index 4e7798b..7d4200c 100644 --- a/modules/home/programs/editor/nixvim.nix +++ b/modules/home/programs/editor/nixvim.nix @@ -1,15 +1,16 @@ { - pkgs, - # pkgs-51b85c, - lib, config, + lib, + pkgs, ... -}: { +}: let + inherit (lib) mkIf mkEnableOption; +in { options = { editor.neovim.enable = - lib.mkEnableOption "enable neovim text editor"; + mkEnableOption "enable neovim text editor"; }; - config = lib.mkIf config.editors.neovim.enable { + config = mkIf config.editors.neovim.enable { # stylix.targets.nixvim.enable = true; home.packages = with pkgs; [neovide]; programs.nixvim = { diff --git a/modules/home/programs/editor/zed.nix b/modules/home/programs/editor/zed.nix index 568e353..9023b86 100644 --- a/modules/home/programs/editor/zed.nix +++ b/modules/home/programs/editor/zed.nix @@ -3,8 +3,8 @@ pkgs, lib, ... -}: -with lib; let +}: let + inherit (lib) mkIf mkEnableOption mkForce getExe; cfg = config.editor.zed; in { options = { @@ -22,8 +22,8 @@ in { ]; userSettings = { vim_mode = true; - ui_font_size = lib.mkForce 16; - buffer_font_size = lib.mkForce 16; + ui_font_size = mkForce 16; + buffer_font_size = mkForce 16; features = {inline_completion_provider = "none";}; auto_update = false; languages = { @@ -33,13 +33,13 @@ in { "nixd" ]; formatter = { - external.command = lib.getExe pkgs.alejandra; + external.command = getExe pkgs.alejandra; }; }; "Rust" = { formatter = { external = { - command = lib.getExe pkgs.rustfmt; + command = getExe pkgs.rustfmt; arguments = ["--edition" "2021"]; }; }; @@ -49,7 +49,7 @@ in { format_on_save = "on"; formatter = { external = { - command = lib.getExe pkgs.typstyle; + command = getExe pkgs.typstyle; arguments = ["-i" "{buffer_path}"]; }; }; @@ -76,39 +76,39 @@ in { rust-analyzer = { binary = { arguments = []; - path = lib.getExe pkgs.rust-analyzer; + path = getExe pkgs.rust-analyzer; }; }; ruff = { binary = { arguments = []; - path = lib.getExe pkgs.ruff; + path = getExe pkgs.ruff; }; }; nixd = { binary = { arguments = []; - path = lib.getExe pkgs.nixd; + path = getExe pkgs.nixd; }; - initialization_options.formatting.command = [(lib.getExe pkgs.alejandra)]; + initialization_options.formatting.command = [(getExe pkgs.alejandra)]; }; nil = { binary = { arguments = []; - path = lib.getExe pkgs.nil; + path = getExe pkgs.nil; }; - initialization_options.formatting.command = [(lib.getExe pkgs.alejandra)]; + initialization_options.formatting.command = [(getExe pkgs.alejandra)]; }; texlab = { binary = { arguments = []; - path = lib.getExe pkgs.texlab; + path = getExe pkgs.texlab; }; }; tinymist = { binary = { arguments = []; - path = lib.getExe pkgs.tinymist; + path = getExe pkgs.tinymist; }; }; }; diff --git a/modules/nixos/desktop/cosmic.nix b/modules/nixos/desktop/cosmic.nix index 2f7e09e..483a61c 100644 --- a/modules/nixos/desktop/cosmic.nix +++ b/modules/nixos/desktop/cosmic.nix @@ -5,6 +5,7 @@ lib, ... }: let + inherit (lib) mkIf mkEnableOption; cfg = config.desktop.cosmic; in { imports = with inputs; [ @@ -12,9 +13,9 @@ in { ]; options = { desktop.cosmic.enable = - lib.mkEnableOption "enable cosmic desktop"; + mkEnableOption "enable cosmic desktop"; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { sound.pipewire.enable = true; nix.settings = { substituters = ["https://cosmic.cachix.org/"]; diff --git a/modules/nixos/system/misc/locale.nix b/modules/nixos/system/misc/locale.nix index 89209a9..06bbb72 100644 --- a/modules/nixos/system/misc/locale.nix +++ b/modules/nixos/system/misc/locale.nix @@ -2,27 +2,31 @@ config, lib, ... -}: { +}: let + inherit (lib) mkIf mkEnableOption; +in { options = { locale.ukrainian.enable = - lib.mkEnableOption "enables ukrainian locale"; + mkEnableOption "enables ukrainian locale"; }; - config = lib.mkIf config.locale.ukrainian.enable { - i18n = { - defaultLocale = "uk_UA.UTF-8"; + config = mkIf config.locale.ukrainian.enable { + i18n = let + locale = "uk_UA.UTF-8"; + in { + defaultLocale = locale; extraLocaleSettings = { - LC_CTYPE = "uk_UA.UTF-8"; - LC_NUMERIC = "uk_UA.UTF-8"; - LC_TIME = "uk_UA.UTF-8"; + LC_ADDRESS = locale; LC_COLLATE = "en_US.UTF-8"; - LC_MONETARY = "uk_UA.UTF-8"; - LC_MESSAGES = "uk_UA.UTF-8"; - LC_PAPER = "uk_UA.UTF-8"; - LC_NAME = "uk_UA.UTF-8"; - LC_ADDRESS = "uk_UA.UTF-8"; - LC_TELEPHONE = "uk_UA.UTF-8"; - LC_MEASUREMENT = "uk_UA.UTF-8"; - LC_IDENTIFICATION = "uk_UA.UTF-8"; + LC_CTYPE = locale; + LC_IDENTIFICATION = locale; + LC_MEASUREMENT = locale; + LC_MESSAGES = locale; + LC_MONETARY = locale; + LC_NAME = locale; + LC_NUMERIC = locale; + LC_PAPER = locale; + LC_TELEPHONE = locale; + LC_TIME = locale; }; }; }; diff --git a/modules/nixos/system/misc/opentabletdriver.nix b/modules/nixos/system/misc/opentabletdriver.nix index 8951ff9..5a0fa03 100644 --- a/modules/nixos/system/misc/opentabletdriver.nix +++ b/modules/nixos/system/misc/opentabletdriver.nix @@ -2,12 +2,14 @@ config, lib, ... -}: { +}: let + inherit (lib) mkIf mkEnableOption; +in { options = { opentabletdriver.enable = - lib.mkEnableOption "enables opentabletdriver"; + mkEnableOption "enables opentabletdriver"; }; - config = lib.mkIf config.opentabletdriver.enable { + config = mkIf config.opentabletdriver.enable { hardware.opentabletdriver = { enable = true; daemon.enable = true; diff --git a/modules/nixos/system/misc/qmk-vial.nix b/modules/nixos/system/misc/qmk-vial.nix index 0fd5732..3459611 100644 --- a/modules/nixos/system/misc/qmk-vial.nix +++ b/modules/nixos/system/misc/qmk-vial.nix @@ -1,16 +1,16 @@ { - pkgs, - lib, config, + lib, ... -}: { +}: let + inherit (lib) mkIf mkEnableOption; +in { options = { qmk-vial.enable = - lib.mkEnableOption "adds a udev rule for vial keyboards"; + mkEnableOption "adds a udev rule for vial keyboards"; }; - config = lib.mkIf config.qmk-vial.enable { + config = mkIf config.qmk-vial.enable { services.udev.extraRules = '' - #vial rule KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" ''; }; diff --git a/modules/nixos/system/security/basic.nix b/modules/nixos/system/security/basic.nix index eddd501..3c508a2 100644 --- a/modules/nixos/system/security/basic.nix +++ b/modules/nixos/system/security/basic.nix @@ -3,15 +3,15 @@ lib, pkgs, ... -}: -with lib; let +}: let + inherit (lib) mkIf mkEnableOption mkDefault; cfg = config.security.basic; in { options = { security.basic.enable = - lib.mkEnableOption "enable basic security"; + mkEnableOption "enable basic security"; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { security = { sudo.enable = false; # doas.enable = true; @@ -36,7 +36,7 @@ in { } }); ''; - apparmor.enable = lib.mkDefault true; + apparmor.enable = mkDefault true; }; environment.systemPackages = with pkgs; [ @@ -85,6 +85,6 @@ in { "ufs" ]; - nix.settings.allowed-users = lib.mkDefault ["@users"]; + nix.settings.allowed-users = mkDefault ["@users"]; }; }