[fix] home: revamp options

Query the system configuration for defaults for the options.
This commit is contained in:
Jalil David Salamé Messina 2024-06-01 16:24:05 +02:00
parent 1da87b1153
commit a639e4e214
Signed by: jalil
GPG key ID: F016B9E770737A0B
3 changed files with 45 additions and 27 deletions

View file

@ -14,11 +14,7 @@ in {
imports =
[
# Apply overlays
{
nixpkgs = {
inherit overlays;
};
}
{nixpkgs = {inherit overlays;};}
nvim-config
./options.nix
./gui
@ -26,12 +22,11 @@ in {
]
++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{
stylix.image = cfg.sway.background;
}
{stylix.image = cfg.sway.background;}
];
config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.styling.enable) {stylix.enable = true;})
(lib.mkIf cfg.enable {
programs = {
# Better cat (bat)

View file

@ -41,7 +41,7 @@ in {
++ lib.optional flatpakEnabled flatpak;
fonts.fontconfig = {
enable = true;
defaultFonts = {
defaultFonts = lib.mkIf config.jhome.styling.enable {
emoji = ["Noto Color Emoji"];
monospace = ["JetBrains Mono" "Symbols Nerd Font"];
serif = ["Noto Serif" "Symbols Nerd Font"];
@ -54,7 +54,7 @@ in {
# Dynamic Menu
fuzzel = {
enable = true;
settings.main = {
settings.main = lib.mkIf config.jhome.styling.enable {
icon-theme = "Papirus-Dark";
inherit (cfg) terminal;
layer = "overlay";
@ -69,8 +69,8 @@ in {
waybar = {
enable = true;
systemd.enable = true;
settings = import ./waybar-settings.nix {inherit config lib;};
style = ''
settings = lib.mkIf config.jhome.styling.enable (import ./waybar-settings.nix {inherit config lib;});
style = lib.optionalString config.jhome.styling.enable ''
.modules-left #workspaces button {
border-bottom: 3px solid @base01;
}
@ -82,7 +82,7 @@ in {
# Terminal
wezterm = {
enable = cfg.terminal == "wezterm";
extraConfig = ''
extraConfig = lib.optionalString config.jhome.styling.enable ''
config = {}
config.hide_tab_bar_if_only_one_tab = true
config.window_padding = { left = 1, right = 1, top = 1, bottom = 1 }
@ -90,7 +90,7 @@ in {
'';
};
alacritty.enable = cfg.terminal == "alacritty";
zellij.enable = cfg.terminal == "alacritty"; # alacritty has no terminal multiplexerr built in
zellij.enable = cfg.terminal == "alacritty"; # alacritty has no terminal multiplexer built-in
# PDF reader
zathura.enable = true;
# Auto start sway
@ -128,26 +128,26 @@ in {
# Window Manager
wayland.windowManager.sway = {
enable = true;
inherit (cfg.sway) enable;
package = swayPkg; # no sway package if it comes from the OS
config = import ./sway-config.nix {inherit config pkgs;};
};
# Set cursor style
stylix = {inherit cursor;};
home.pointerCursor = {
stylix = lib.mkIf config.jhome.styling.enable {inherit cursor;};
home.pointerCursor = lib.mkIf config.jhome.styling.enable (lib.mkDefault {
gtk.enable = true;
inherit (cursor) name package;
};
});
# Set Gtk theme
gtk = {
gtk = lib.mkIf config.jhome.styling.enable {
enable = true;
inherit iconTheme;
gtk3.extraConfig.gtk-application-prefer-dark-theme = 1;
gtk4.extraConfig.gtk-application-prefer-dark-theme = 1;
};
# Set Qt theme
qt = {
qt = lib.mkIf config.jhome.styling.enable {
enable = true;
platformTheme.name = "gtk";
};

View file

@ -2,8 +2,20 @@
lib,
pkgs,
...
}: let
} @ attrs: let
osConfig = attrs.osConfig or null;
inherit (lib) types;
fromOs = let
get = path: set:
if path == []
then set
else get (builtins.tail path) (builtins.getAttr (builtins.head path) set);
in
path: default:
if osConfig == null
then default
else get path osConfig;
fromConfig = path: default: fromOs (["jconfig"] ++ path) default;
mkExtraPackagesOption = name: defaultPkgsPath: let
text =
@ -73,13 +85,14 @@
};
sway.options = {
enable = lib.mkEnableOption "sway" // {default = fromConfig ["gui" "sway"] true;};
background = lib.mkOption {
description = "The wallpaper to use.";
type = types.path;
default = builtins.fetchurl {
default = fromConfig ["styling" "wallpaper"] (builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
};
});
};
autostart = lib.mkOption {
description = ''
@ -117,7 +130,7 @@
};
gui.options = {
enable = lib.mkEnableOption "GUI applications";
enable = lib.mkEnableOption "GUI applications" // {default = fromConfig ["gui" "enable"] false;};
tempInfo = lib.mkOption {
description = "Temperature info to display in the statusbar.";
default = null;
@ -148,7 +161,7 @@ in {
hostName = lib.mkOption {
description = "The hostname of this system.";
type = types.str;
default = "nixos";
default = fromOs ["networking" "hostName"] "nixos";
example = "my pc";
};
dev = lib.mkOption {
@ -156,7 +169,7 @@ in {
default = {};
type = types.submodule {
options = {
enable = lib.mkEnableOption "development settings";
enable = lib.mkEnableOption "development settings" // {default = fromConfig ["dev" "enable"] false;};
neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
extraPackages = mkExtraPackagesOption "dev" [
["jq"] # json parser
@ -172,7 +185,8 @@ in {
type = types.submodule {
options.enable = lib.mkEnableOption "rust development settings";
options.extraPackages = mkExtraPackagesOption "Rust" [
["cargo-kcov"] # code coverage
["cargo-insta"] # snapshot testing
["cargo-llvm-cov"] # code coverage
["cargo-msrv"] # minimum supported version
["cargo-nextest"] # better testing harness
["cargo-sort"] # sort deps and imports
@ -193,6 +207,15 @@ in {
default = {};
type = types.submodule gui;
};
styling = lib.mkOption {
description = "My custom styling (uses stylix)";
default = {};
type = types.submodule {
options = {
enable = lib.mkEnableOption "styling" // {default = fromConfig ["styling" "enable"] true;};
};
};
};
};
};
};