From a05748ee28099cbfa31a60b941aced445d5d407f Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 22 Sep 2023 20:57:08 +0200 Subject: [PATCH] feat: stylix --- flake.lock | 109 ++++++++++++++++++++ flake.nix | 4 + hosts/desktopnix/default.nix | 4 + modules/config/default.nix | 1 - modules/config/fonts.nix | 52 ---------- modules/graphical/default.nix | 18 ++++ modules/graphical/fonts.nix | 29 ++++-- modules/{graphical => optional}/steam.nix | 0 modules/optional/streamdeck.nix | 20 +--- modules/{graphical => optional}/wayland.nix | 0 modules/{graphical => optional}/xserver.nix | 0 users/common/graphical/Xorg/i3.nix | 1 + users/common/graphical/Xorg/rofi.nix | 2 +- users/common/graphical/Xorg/xinitrc | 1 + users/common/graphical/themes.nix | 13 ++- users/common/graphical/wayland/fuzzel.nix | 1 + users/common/graphical/wayland/sway.nix | 1 + users/common/programs/kitty.nix | 12 +-- users/patrick/default.nix | 4 +- 19 files changed, 184 insertions(+), 88 deletions(-) delete mode 100644 modules/config/fonts.nix create mode 100644 modules/graphical/default.nix rename modules/{graphical => optional}/steam.nix (100%) rename modules/{graphical => optional}/wayland.nix (100%) rename modules/{graphical => optional}/xserver.nix (100%) diff --git a/flake.lock b/flake.lock index 6478a9f..9430216 100644 --- a/flake.lock +++ b/flake.lock @@ -44,6 +44,24 @@ "type": "github" } }, + "base16": { + "inputs": { + "fromYaml": "fromYaml" + }, + "locked": { + "lastModified": 1689633990, + "narHash": "sha256-iwvQg2Vx0IIDWZaKo8Xmzxlv1YPHg+Kp/QSv8dRv0RY=", + "owner": "SenchoPens", + "repo": "base16.nix", + "rev": "dddf2e1c04845d43c89a8e9e37d574519649a404", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "base16.nix", + "type": "github" + } + }, "colmena": { "inputs": { "flake-compat": "flake-compat", @@ -230,6 +248,22 @@ "type": "github" } }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -347,6 +381,22 @@ "type": "github" } }, + "fromYaml": { + "flake": false, + "locked": { + "lastModified": 1689549921, + "narHash": "sha256-iX0pk/uB019TdBGlaJEWvBCfydT6sRq+eDcGPifVsCM=", + "owner": "SenchoPens", + "repo": "fromYaml", + "rev": "11fbbbfb32e3289d3c631e0134a23854e7865c84", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "fromYaml", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -410,6 +460,27 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "stylix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1691882297, + "narHash": "sha256-e1/LAQSGLnBywfA1TfMl0Vj3tvYka73XOZ/D2/CJowE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c3ab5ea047e6dc73df530948f7367455749d8906", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "impermanence": { "locked": { "lastModified": 1694622745, @@ -680,6 +751,22 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1691853136, + "narHash": "sha256-wTzDsRV4HN8A2Sl0SVQY0q8ILs90CD43Ha//7gNZE+E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f0451844bbdf545f696f029d1448de4906c7f753", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixseparatedebuginfod": { "inputs": { "flake-utils": "flake-utils_4", @@ -774,6 +861,7 @@ "nixpkgs-wayland": "nixpkgs-wayland", "nixseparatedebuginfod": "nixseparatedebuginfod", "pre-commit-hooks": "pre-commit-hooks", + "stylix": "stylix", "systems": "systems_4", "templates": "templates" } @@ -819,6 +907,27 @@ "type": "github" } }, + "stylix": { + "inputs": { + "base16": "base16", + "flake-compat": "flake-compat_5", + "home-manager": "home-manager_2", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1694375893, + "narHash": "sha256-oJGESNjJ/6o6tfuUavBZ7go4Oun7g9YKv7OqaQaY/80=", + "owner": "danth", + "repo": "stylix", + "rev": "c3c9f4784b4f08f6676340126858d936edbce1fa", + "type": "github" + }, + "original": { + "owner": "danth", + "repo": "stylix", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index aeeb243..4c052b3 100644 --- a/flake.nix +++ b/flake.nix @@ -71,12 +71,16 @@ url = "github:nix-community/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixseparatedebuginfod.url = "github:symphorien/nixseparatedebuginfod"; + lanzaboote = { url = "github:nix-community/lanzaboote/v0.3.0"; inputs.nixpkgs.follows = "nixpkgs"; }; + + stylix.url = "github:danth/stylix"; }; outputs = { diff --git a/hosts/desktopnix/default.nix b/hosts/desktopnix/default.nix index 69f5263..4d3df5e 100644 --- a/hosts/desktopnix/default.nix +++ b/hosts/desktopnix/default.nix @@ -7,6 +7,7 @@ ../../modules/config ../../modules/dev + ../../modules/graphical ../../modules/hardware/bluetooth.nix ../../modules/hardware/intel.nix @@ -24,4 +25,7 @@ ../../users/patrick ]; + stylix.fonts.sizes = { + terminal = 10; + }; } diff --git a/modules/config/default.nix b/modules/config/default.nix index 9620718..9727604 100644 --- a/modules/config/default.nix +++ b/modules/config/default.nix @@ -2,7 +2,6 @@ imports = [ ./boot.nix ./efi.nix - ./fonts.nix ./home-manager.nix ./inputrc.nix ./issue.nix diff --git a/modules/config/fonts.nix b/modules/config/fonts.nix deleted file mode 100644 index 0b893e8..0000000 --- a/modules/config/fonts.nix +++ /dev/null @@ -1,52 +0,0 @@ -{pkgs, ...}: { - fonts = { - enableGhostscriptFonts = false; - fontDir.enable = false; - fontconfig = { - defaultFonts = { - sansSerif = ["IBM Plex Sans"]; - serif = ["IBM Plex Sans"]; - monospace = ["FiraCode Nerd Font"]; - emoji = ["Noto Color Emoji"]; - }; - localConf = '' - - - - - monospace - - emoji - - - - sans-serif - - emoji - - - - serif - - emoji - - - - ''; - }; - packages = with pkgs; [ - (nerdfonts.override {fonts = ["FiraCode"];}) - ibm-plex - dejavu_fonts - unifont - freefont_ttf - gyre-fonts # TrueType substitutes for standard PostScript fonts - liberation_ttf - noto-fonts - noto-fonts-cjk-sans - noto-fonts-cjk-serif - noto-fonts-emoji - noto-fonts-extra - ]; - }; -} diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix new file mode 100644 index 0000000..d869865 --- /dev/null +++ b/modules/graphical/default.nix @@ -0,0 +1,18 @@ +{ + inputs, + config, + pkgs, + ... +}: { + imports = [ + inputs.stylix.nixosModules.stylix + ./fonts.nix + ]; + + stylix = { + autoEnable = false; + polarity = "dark"; + image = config.lib.stylix.pixel "base00"; + base16Scheme = "${pkgs.base16-schemes}/share/themes/da-one-black.yaml"; + }; +} diff --git a/modules/graphical/fonts.nix b/modules/graphical/fonts.nix index 0b893e8..3cfd7d9 100644 --- a/modules/graphical/fonts.nix +++ b/modules/graphical/fonts.nix @@ -3,12 +3,6 @@ enableGhostscriptFonts = false; fontDir.enable = false; fontconfig = { - defaultFonts = { - sansSerif = ["IBM Plex Sans"]; - serif = ["IBM Plex Sans"]; - monospace = ["FiraCode Nerd Font"]; - emoji = ["Noto Color Emoji"]; - }; localConf = '' @@ -49,4 +43,27 @@ noto-fonts-extra ]; }; + stylix.fonts = { + serif = { + package = pkgs.dejavu_fonts; + name = "IBM Plex Serif"; + }; + + sansSerif = { + package = pkgs.dejavu_fonts; + name = "IBM Plex Sans"; + }; + + monospace = { + # No need for patched nerd fonts, kitty can pick up on them automatically, + # and ideally every program should do that: https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font + package = pkgs.jetbrains-mono; + name = "JetBrains Mono"; + }; + + emoji = { + package = pkgs.noto-fonts-emoji; + name = "Noto Color Emoji"; + }; + }; } diff --git a/modules/graphical/steam.nix b/modules/optional/steam.nix similarity index 100% rename from modules/graphical/steam.nix rename to modules/optional/steam.nix diff --git a/modules/optional/streamdeck.nix b/modules/optional/streamdeck.nix index ee19129..c8a4070 100644 --- a/modules/optional/streamdeck.nix +++ b/modules/optional/streamdeck.nix @@ -18,11 +18,6 @@ in { options.programs.streamdeck-ui = { enable = mkEnableOption "streamdeck-ui"; package = mkPackageOption pkgs "streamdeck-ui" {}; - autoStart = mkOption { - default = true; - type = types.bool; - description = "Whether streamdeck-ui should be started automatically"; - }; settings = mkOption { default = {}; type = types.submodule {freeformType = settingsFormat.type;}; @@ -31,6 +26,7 @@ in { }; config = mkIf config.programs.streamdeck-ui.enable { home.packages = [pkgs.streamdeck-ui]; + home.sessionVariables.STREAMDECK_UI_CONFIG = "${config.xdg.configHome}/streamdeck-ui/config.json"; xdg.configFile.streamdeck-ui = { target = "streamdeck-ui/config.json"; source = settingsFormat.generate "config.json" { @@ -38,20 +34,6 @@ in { state = config.programs.streamdeck-ui.settings; }; }; - systemd.user.services = mkIf config.programs.streamdeck-ui.autoStart { - streamdeck-ui = { - Unit = { - Description = "Start streamdeck-ui"; - }; - Service = { - Environment = "STREAMDECK_UI_CONFIG=${config.xdg.configHome}/streamdeck-ui/config.json"; - ExecStart = "${config.programs.streamdeck-ui.package}/bin/streamdeck --no-ui"; - }; - Install = { - WantedBy = ["default.target"]; - }; - }; - }; }; }) ]; diff --git a/modules/graphical/wayland.nix b/modules/optional/wayland.nix similarity index 100% rename from modules/graphical/wayland.nix rename to modules/optional/wayland.nix diff --git a/modules/graphical/xserver.nix b/modules/optional/xserver.nix similarity index 100% rename from modules/graphical/xserver.nix rename to modules/optional/xserver.nix diff --git a/users/common/graphical/Xorg/i3.nix b/users/common/graphical/Xorg/i3.nix index 2af1791..7a26fc8 100644 --- a/users/common/graphical/Xorg/i3.nix +++ b/users/common/graphical/Xorg/i3.nix @@ -3,6 +3,7 @@ lib, ... }: { + stylix.targets.i3.enable = true; xsession.windowManager.i3 = { enable = true; config = diff --git a/users/common/graphical/Xorg/rofi.nix b/users/common/graphical/Xorg/rofi.nix index daea4b4..c960f53 100644 --- a/users/common/graphical/Xorg/rofi.nix +++ b/users/common/graphical/Xorg/rofi.nix @@ -1,7 +1,7 @@ { + stylix.targets.rofi.enable = true; programs.rofi = { enable = true; - theme = "DarkBlue"; extraConfig = { matching = "fuzzy"; dpi = 1; diff --git a/users/common/graphical/Xorg/xinitrc b/users/common/graphical/Xorg/xinitrc index 9e202fe..2965270 100644 --- a/users/common/graphical/Xorg/xinitrc +++ b/users/common/graphical/Xorg/xinitrc @@ -21,5 +21,6 @@ if command -v dbus-update-activation-environment >/dev/null 2>&1; then fi autorandr -c +streamdeck --no-ui systemctl --user start set-wallpaper.service exec i3 diff --git a/users/common/graphical/themes.nix b/users/common/graphical/themes.nix index 01b1920..22f106a 100644 --- a/users/common/graphical/themes.nix +++ b/users/common/graphical/themes.nix @@ -1,6 +1,7 @@ { pkgs, config, + lib, ... }: { home.pointerCursor = { @@ -11,6 +12,16 @@ size = 18; }; + stylix = { + targets = { + gtk.enable = true; + bat.enable = true; + dunst.enable = true; + zathura.enable = true; + xresources.enable = true; + }; + }; + xresources.properties = { "Xft.hinting" = true; "Xft.antialias" = true; @@ -38,7 +49,7 @@ package = pkgs.vimix-icon-theme; }; - theme = { + theme = lib.mkForce { name = "Orchis-purple-solid-black"; package = pkgs.orchis-theme; }; diff --git a/users/common/graphical/wayland/fuzzel.nix b/users/common/graphical/wayland/fuzzel.nix index d3c44f6..914b6de 100644 --- a/users/common/graphical/wayland/fuzzel.nix +++ b/users/common/graphical/wayland/fuzzel.nix @@ -1,4 +1,5 @@ {pkgs, ...}: { + stylix.targets.fuzzel.enable = true; home.packages = with pkgs; [ (writeShellScriptBin "fuzzel" '' ${fuzzel}/bin/fuzzel --background-color=000000ff diff --git a/users/common/graphical/wayland/sway.nix b/users/common/graphical/wayland/sway.nix index e785878..cf66e06 100644 --- a/users/common/graphical/wayland/sway.nix +++ b/users/common/graphical/wayland/sway.nix @@ -8,6 +8,7 @@ home.packages = [ pkgs.wdisplays ]; + stylix.targets.sway.enable = true; wayland.windowManager.sway = { enable = true; config = diff --git a/users/common/programs/kitty.nix b/users/common/programs/kitty.nix index 875e1dc..7487a5a 100644 --- a/users/common/programs/kitty.nix +++ b/users/common/programs/kitty.nix @@ -1,14 +1,14 @@ -{pkgs, ...}: { +{ + pkgs, + lib, + ... +}: { + stylix.targets.kitty.enable = true; programs.kitty = { enable = true; package = pkgs.kitty.overrideAttrs (_finalAttrs: _prevAttrs: { doCheck = false; }); - font = { - package = pkgs.nerdfonts; - name = "FiraCode Nerd Font"; - size = 10; - }; settings = { # Use xterm-256color because copying terminfo-kitty is painful. term = "xterm-256color"; diff --git a/users/patrick/default.nix b/users/patrick/default.nix index 0bcda57..66d830e 100644 --- a/users/patrick/default.nix +++ b/users/patrick/default.nix @@ -5,8 +5,8 @@ }: { # enable nixos wide graphical config imports = [ - ../../modules/graphical/xserver.nix - ../../modules/graphical/steam.nix + ../../modules/optional/xserver.nix + ../../modules/optional/steam.nix ./impermanence.nix ];