danth / stylix Goto Github PK
View Code? Open in Web Editor NEWSystem-wide colorscheming and typography for NixOS
Home Page: https://stylix.danth.me/
License: MIT License
System-wide colorscheming and typography for NixOS
Home Page: https://stylix.danth.me/
License: MIT License
More details on NixOS/nixpkgs#220690
I am unsure on the fix.
For some reason, stylix does not correctly color GRUB.
Rather than using my color scheme, GRUB looks like this:
I was able to take a screenshot of GRUB because I installed NixOS to a VM.
So far, I have not had any issues theming other programs.
As far as I can tell, this might be related to #61 if the underlying issue's something like an invalid theme causing GRUB to fall back to defaults.
I'm using stylix in a nix config, and whenever I try to evaluate my system configuration, it errors out.
The error is:
error: attribute 'lib' missing
at /nix/store/lbgfhradyynfljgmv9bywhg9h3p25qyf-modules/chromium/nixos.nix:5:5:
4| options.stylix.targets.chromium.enable =
5| config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true;
| ^
6|
I don't know what is causing this problem, but if you can help, that would be much appreciated. Please let me know if there are any other details you need.
Hello. Here's my nix setup:
https://github.com/Industrial/nixos-dotfiles/blob/main/flake.nix#L82
When I enable Stylix, loading my shell (fish) takes around 5 seconds. When I disable it, it's instant. Is there something I can do about this?
Within my NixOS configuration I use a wrapper script for Swaylock to set the colors.
This should be merged into Stylix.
Theming Swaylock :)
As a home-manager user, I would like to just add programs.stylix = {enable=true;...}
to my configuration.
Hi.
Since #65, I am unable to evaluate my NixOS configuration, as I am still on home-manager 22.11.
I tried disabling the mako target with both
home-manager.sharedModules = [{
stylix.targets.mako.enable = false;
}];
and
home-manager.users.mrcjk = {
stylix.targets.mako.enable = false;
};
as described here, but to no avail.
I always end up with
building the system configuration...
error: The option `home-manager.users.mrcjk.services.mako' does not exist. Definition values:
- In `/nix/store/l84b6hgjc6i9nsgg6mbxdgdf3ddc2pxv-modules/mako/hm.nix':
{
_type = "if";
condition = false;
content = {
backgroundColor = "#212121";
..
What is the best way to view the generated colors? Ideally I could see which base00, base01.. and their corresponding color. If there currently is not away, would it be possible to generate an HTML page that did this? Or a bash script that printed the colors?
There is tinted theming support for tmux provided by https://github.com/tinted-theming/base16-tmux
We should probably add support in Stylix as well
Stylix cannot generate a colorscheme when Colorgram returns less than the requested number of colors.
Pass all but the dominant color into itertools.cycle
, colors will be repeated to fill up the scheme.
I've been trying to update my flake setup to use the latest version of stylix, but I keep hitting an infinite recursion:
error: infinite recursion encountered
at /nix/store/f6jk9gi6i92ngcbkcz8z2d7gvkksciw1-source/lib/modules.nix:728:9:
727| in warnDeprecation opt //
728| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
729| inherit (res.defsFinal') highestPrio;
(use '--show-trace' to show detailed location information)
Using --show-trace
doesn't help much in finding the reason unfortunately.
This is the latest revision of stylix that works for me: d7536947a7fc3f9b60ba3c8f19c2530ca00110a9
. I'm using digga
to structure my configuration (you can find it here) I define the theme in this file which I then import in the definition of the user
error: undefined variable 'base16-schemes'
at /nix/store/xq5r4q0ag758wln5jq36wdv64xq973ak-source/configuration.nix:19:23:
18| image = /home/emaleth/Pictures/Wallpapers/wallhaven-q62ryd.png;
19| base16Scheme = "${base16-schemes}/gruvbox-dark-hard.yaml";
| ^
20| polarity = "dark";
(use '--show-trace' to show detailed location information)
Fails to build when stylix.image
is set to a .svg
or .webp
asset. This is especially frustrating because it seems to fail even when the base16Scheme
is set manually.
Error log
last 10 log lines:
> Jpeg Invalid marker used
> PNG Invalid PNG file, signature broken
> Bitmap Invalid Bitmap magic identifier
> GIF Invalid Gif signature : <svg w
> HDR Invalid radiance file signature
> Tiff Invalid endian tag value
> TGA not enough bytes
>
> CallStack (from HasCallStack):
> error, called at Stylix/Main.hs:22:26 in main:Main
rofi supports themes.
It doesn't work yet, as it's a different package and has slightly different options, see https://github.com/nix-community/nix-doom-emacs/blob/2b34bf438c9e748c34162e0a7c038c5b67688c11/modules/home-manager.nix
The README mentions that "Stylix is a NixOS module". Does it mean that having home-manager on another distribution isn't good enough?
Also, the README doesn't say anything about installation beyond "using Flakes" and some Nix file content. It could be nice to explain what to do with this file.
Is there another way to use stylix than using the experimental Flakes feature?
I was trying to add support for kmscon, but got stuck because it needs colors in RGB format, instead of Hex.
I think Stylix should provide a way to get the colors in RGB format, as opposed to Hex.
Inspiration from nix-colors
: https://github.com/Misterio77/nix-colors/blob/main/lib/core/conversions.nix#L108
Ive got a modules set up already based on the same coloring as the sway module, however im not sure weather up streaming would be a good idea considering that nixos and home-manager modules haven't been up streamed yet.
My understanding is that stylix currently uses stylix.image
for palette generation and wallpapers, and is mandatory. If one wishes to use stylix.autoEnable
, they might be surprised to see that stylix is also setting wallpaper options. For users who wish to use a rotating set of wallpapers, this can be an annoyance as they would have to manually disable such modules. To accomodate users with sets of wallpapers, stylix should continue to use stylix.image
but accepting a list, or expose a new option (stylix.wallpapers
? stylix.images
? Seems to complicate things for little benefit) which is a list of images. In order to accomplish the first solution (which I prefer), I would sugget taking the first or last element of the list when only one image is required.
If you try to evaluate a config with both stylix
and documentation.nixos.includeAllModules = true
it fails with the following error:
error:
… while evaluating a branch condition
at /nix/store/ycwxxfi2yv4nd8y66bxdc8pww9mhjwgj-source/lib/attrsets.nix:596:13:
595| name: value:
596| if isAttrs value && cond value
| ^
597| then recurse (path ++ [name]) value
… in the right operand of the AND (&&) operator
at /nix/store/ycwxxfi2yv4nd8y66bxdc8pww9mhjwgj-source/lib/attrsets.nix:596:30:
595| name: value:
596| if isAttrs value && cond value
| ^
597| then recurse (path ++ [name]) value
(stack trace truncated; use '--show-trace' to show the full trace)
error: attribute 'lib' missing
at /nix/store/j5w5w667z1lgkh37vi3sydm9hnbah9rx-modules/chromium/nixos.nix:5:5:
4| options.stylix.targets.chromium.enable =
5| config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true;
| ^
6|
You can reproduce by building this flake:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
stylix.url = "github:danth/stylix";
home-manager.url = "github:nix-community/home-manager";
};
outputs = { nixpkgs, home-manager, stylix, ... }: {
nixosConfigurations.repro = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
({ pkgs, ... }: {
# Unimportant things to make the config eval
boot.loader.grub.device = "/dev/sda1";
fileSystems."/".device = "tmpfs";
system.stateVersion = "23.05";
# Relevant bits
documentation = {
enable = true;
nixos.includeAllModules = true;
};
stylix.image = pkgs.fetchurl {
url = "https://media.githubusercontent.com/media/lovesegfault/nix-config/bda48ceaf8112a8b3a50da782bf2e65a2b5c4708/users/bemeurer/assets/walls/plants-00.jpg";
hash = "sha256-n8EQgzKEOIG6Qq7og7CNqMMFliWM5vfi2zNILdpmUfI=";
};
})
];
};
};
}
$ nix build .#nixosConfigurations.repro.config.system.build.toplevel
Right now stylix won't recognise helix if it's installed system wide, it has to be enabled in home manager. But then it's not possible to use the native config file. Would it be possible to fix it?
I can't make stylix work on home-manager + Fedora.
{pkgs, ...}@args:
let
base16 = import ../../base16;
palette-generator = pkgs.callPackage ../../stylix/palette-generator { };
in
{
stylix.image = pkgs.fetchurl {
url = "https://www.pixelstalk.net/wp-content/uploads/2016/05/Epic-Anime-Awesome-Wallpapers.jpg";
sha256 = "enQo3wqhgf0FEPHj2coOCvo7DuZv+x5rL/WIo4qPI50=";
};
imports = [
(import ../../stylix/stylix/hm {
inherit palette-generator;
base16 = base16 args;
})
];
}
Here is the error I get when trying to build it:
error: undefined variable 'herbsflutwm'
at /nix/store/56fjxq6xzrf2sznbhaqcw9m34wc6rd9l-modules/feh/hm.nix:8:42:
7| (with config.xsession.windowManager; bspwm.enable
8| || herbsflutwm.enable
| ^
9| || i3.enable
(use '--show-trace' to show detailed location information)
I'm on the very latest commit of both stylix and home-manager.
It would be nice to have emacs themed by stylix. This Issue is more or less a documentation for my manual theming, until I (or someone else) find some time to create a PR.
For reference, I'm using this code to supply a base16-theme
(although I'm using the emacs-init
module from rycee's NUR):
base16-theme = {
enable = true;
config = ''
(defvar base16-stylix-theme-colors
'(:base00 "${config.lib.stylix.colors.withHashtag.base00}"
:base01 "${config.lib.stylix.colors.withHashtag.base01}"
:base02 "${config.lib.stylix.colors.withHashtag.base02}"
:base03 "${config.lib.stylix.colors.withHashtag.base03}"
:base04 "${config.lib.stylix.colors.withHashtag.base04}"
:base05 "${config.lib.stylix.colors.withHashtag.base05}"
:base06 "${config.lib.stylix.colors.withHashtag.base06}"
:base07 "${config.lib.stylix.colors.withHashtag.base07}"
:base08 "${config.lib.stylix.colors.withHashtag.base08}"
:base09 "${config.lib.stylix.colors.withHashtag.base09}"
:base0A "${config.lib.stylix.colors.withHashtag.base0A}"
:base0B "${config.lib.stylix.colors.withHashtag.base0B}"
:base0C "${config.lib.stylix.colors.withHashtag.base0C}"
:base0D "${config.lib.stylix.colors.withHashtag.base0D}"
:base0E "${config.lib.stylix.colors.withHashtag.base0E}"
:base0F "${config.lib.stylix.colors.withHashtag.base0F}")
"All colors for Base16 stylix are defined here.")
;; Define the theme
(deftheme base16-stylix)
;; Add all the faces to the theme
(base16-theme-define 'base16-stylix base16-stylix-theme-colors)
;; Mark the theme as provided
(provide-theme 'base16-stylix)
(load-theme 'base16-stylix t)
'';
};
I still need to think about how I can:
emacs-init
(probably using extraConfig
from the HM module for emacs).pkgs.emacsPackages.base16-theme
i think it would be a good idea to have a module template including things like variables assigned to opacity and the hex colors, what does everyone else think?
Sometimes I have background images that are bright, will be nice to be able to have the ability to dimm the image.
stylix = {
polarity = "dark";
image "..."
image-dimming = "0.3";
}
do we want to implement this? and if so do we want to follow the same nomenclature as the font sizes?
When trying to use stylix in my system configuration (by simply importing stylix.nixosModules.stylix
and setting stylix.image
and also having home-manager already imported), I always receive the following error when trying to rebuild my system:
error: attribute 'lib' missing
at /nix/store/9jaxhhsd44pl35x4ai7silsyncs73vj7-source/modules/vim.nix:38:5:
37| options.stylix.targets.vim.enable =
38| config.lib.stylix.mkEnableTarget "Vim and/or Neovim" true;
| ^
39|
The commit that introduced this seems to be a1c4e81, as this seems to be the commit that introduced the usage of config.lib(.stylix)
in the codebase and every commit right before this works perfectly fine.
My best guess as to why this might occur is that the corresponding option (options.lib(.stylix)
) is never declared in any module and as far as I know, only config definitions that have a corresponding option declaration are considered valid by the module system, but it might be something else entirely.
If you use nix-darwin
, it breaks stylix
, even just the home-manager module.
Evaluation fails with:
error: attribute 'stylix' missing
at /nix/store/axhqicv10hg6zvp6sp2wh506q8mnblj9-source/stylix/fromos.nix:4:26:
3| path: default:
4| if (args ? "osConfig" && args.osConfig.stylix.homeManagerIntegration.followSystem)
| ^
5| then lib.attrByPath path default args.osConfig.stylix
(use '--show-trace' to show detailed location information)
Seems like this could be mitigated by there being a module for Darwin like there is one for NixOS.
Kvantum might be relevant.
Add an option to use base00 as the background for GRUB instead of an image.
When Plymouth is disabled, a plain background for the GRUB menu would be more consistent as it matches the background of the console.
This could be toggled based on whether Plymouth is enabled.
I decided to change my config into two separate repositories and ran into this issue
output
error: The option `home-manager' does not exist. Definition values:
- In `/nix/store/22z4n4mxs2vz3l3lg41dz3mgnq1d4wxs-source/flake.nix':
{
_type = "if";
condition = false;
content = {
sharedModules = [
...
flake
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
stylix.url = "github:danth/stylix";
};
description = "A very basic flake";
outputs = { self, nixpkgs, stylix, ...}:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
shared-modules = [
stylix.nixosModules.stylix
{
stylix.image = ./resources/wallpapers/raison-detre.jpg;
stylix.polarity = "dark";
stylix.fonts = {
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
monospace = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans Mono";
};
sizes = {
desktop = 12;
applications = 15;
terminal = 15;
popups = 12;
};
};
stylix.targets = {
grub.useImage = true;
};
}
./config/general/boot.nix
./config/general/configuration.nix
./config/general/hardware.nix
./config/general/packages.nix
./config/general/users.nix
./config/general/virtualisation.nix
];
in {
nixosConfigurations.flex = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = shared-modules ++ [ ./config/flex/hardware.nix ];
};
nixosConfigurations.desktop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = shared-modules ++ [ ./config/desktop/hardware.nix ];
};
};
}
I would like to override the font size in /modules/sway/hm.nix
what's the best practice to do so? Is it a nix override?
with pywal and it's -R flag you can apply colors to I guess any terminal. There is other wal programs that works with wal colors such as wal-telegram. There is my approach of doing that:
home.file = {
".cache/colors.json".source = config.lib.stylix.colors {
template = builtins.readFile ./pywal.json.mustache;
extension = ".json";
};
};
home.activation = #ALSO ACTIVATES AT REBOOT
{
generate_pywal_colors = lib.hm.dag.entryAfter ["writeBoundary"] ''
$DRY_RUN_CMD ${pkgs.pywal}/bin/wal -f ~/.cache/colors.json
$DRY_RUN_CMD ${pkgs.pywal}/bin/wal -R
'';
telegram-colors = lib.hm.dag.entryAfter ["writeBoundary"] ''
# $DRY_RUN_CMD rm -rf ~/.cache/.wal-telegram-git
$DRY_RUN_CMD ${pkgs.git}/bin/git clone --depth 1 https://github.com/guillaumeboehm/wal-telegram ~/.cache/.wal-telegram-git || PATH=/run/wrappers/bin:/.local/bin:/root/.nix-profile/bin:/etc/profiles/per-user/root/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin /usr/bin/env bash -i -c '~/.cache/.wal-telegram-git/wal-telegram --wal -g -r -b ~/Pictures/wallpaper.jpg' && PATH=/run/wrappers/bin:/.local/bin:/root/.nix-profile/bin:/etc/profiles/per-user/root/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin /usr/bin/env bash -i -c '~/.cache/.wal-telegram-git/wal-telegram --wal -g -r -b ~/Pictures/wallpaper.jpg'
'';
};
{
"special": {
"background": "#{{base00-hex}}",
"foreground": "#{{base07-hex}}",
"cursor": "#{{base07-hex}}"
},
"colors": {
"color0": "#{{base00-hex}}",
"color1": "#{{base01-hex}}",
"color2": "#{{base02-hex}}",
"color3": "#{{base03-hex}}",
"color4": "#{{base04-hex}}",
"color5": "#{{base05-hex}}",
"color6": "#{{base06-hex}}",
"color7": "#{{base07-hex}}",
"color8": "#{{base08-hex}}",
"color9": "#{{base09-hex}}",
"color10": "#{{base0A-hex}}",
"color11": "#{{base0B-hex}}",
"color12": "#{{base0C-hex}}",
"color13": "#{{base0D-hex}}",
"color14": "#{{base0E-hex}}",
"color15": "#{{base0F-hex}}"
}
}
this is in regard to :
Line 45 in 679a806
the expected behavior is to over the grum theme colors overwritten by stylix. currently stylix changes the entire theme.
current default stylix behavior:
when targed.grub.enable = false;
the default nixos theme is on..
E.g.,
{
programs.i3status = {
general = {
colors = true;
color_good = "#ffffff";
color_degraded = "#da8548";
color_bad = "#ff6c6b";
};
}
}
Not sure if this would be tied to #51.
Probably could have a theme and override its theme.conf with stylix's colors, font & background.
error: builder for '/nix/store/wlrrlqfmyzkvdarm90dx83kg41a6sv55-fonts.drv' failed with exit code 1;
last 1 log lines:
> ln: failed to create symbolic link '/nix/store/5jgyddi839rx80rpv79p65p2lgmr1icy-fonts/Library/Fonts/Caskaydia Cove Nerd Font Complete ExtraLight Italic.otf': File exists
For full logs, run 'nix log /nix/store/wlrrlqfmyzkvdarm90dx83kg41a6sv55-fonts.drv'.
Whenever I try to build my flake (nix-darwin config) I get an error about linking a font where the link already exists. I get this even if I don't specify a font configuration - in that case, the error refers to one of the default DejaVu fonts.
I've tried nix-store --delete /nix/store/5jgyddi839rx80rpv79p65p2lgmr1icy-fonts
, which completes successfully. The error will still occur, though.
I'm at a loss as to how to debug this issue, but I do not otherwise specify any font options (nix-darwin or home-manager) anywhere in my config.
I'm using Stylix and enabled Rofi inside Home Manager but it doesn't pick up the right font. Looking at the source, this seems to be because Stylix sets
Lines 20 to 21 in 6d3a046
programs.font.rofi = "${monospace.name} 12"
but the font size should probably depend on some option.
i cant quite get to it yet due to mid terms for the next few weeks, but i wanna open an issue to get opinions on implementation.
Add a way to override the automatically-selected colors.
base00
to base0A
).mkDefault
.I tried generating color schemes for different background images and it works like a charm - thanks ! But I also have night mode enabled constantly, and in dark mode this gives a reddish hue to the background color. I'd like to keep the color scheme generated by stylix, but override the background color to set it to something darker which won't get redshifted noticeably.
I assume I could just generate the color scheme myself using palette-generator
and override it before passing it to stylix.base16scheme
, but it'd be nice to have a configuration option like stylix.base16schemeOverrides
to do that automatically.
The README says:
After rebuilding, the full theme can be previewed at file:///etc/stylix/palette.html in a web browser.
On non-NixOS systems, the file can't be added to /etc/
. Where is it?
Right now the README describes the goals, but doesn't have any screenshots of it actually in use, which makes it hard to evaluate before actually trying it. May I suggest adding screenshots?
Right now this project edits the configs in a way that it is only written when a particular application is actually enabled. I was thinking it would be a good idea to add a switch to make each module opt in instead of opt out.
I am thinking of writing a module for this project that themes vim-lightline.
Not everyone uses lightline, and it would be nice to make this opt-in nature standard such that they do not have to enable lightline if they do not wish.
I was thinking a global makeOptIn
option which would require each module to be enabled separately. Or perhaps make certain modules opt-in, depending on what they need to configure to work properly.
A lightline module would likely have to configure a vim plugin with a custom package, thus automatically installing lightline. Being able to not opt-in to this would allow users to not install plugins they won't necessarily use.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.