Giter Site home page Giter Site logo

nix-colors's Introduction

Nix Colors

About

This repo is designed to help with Nix(OS) theming.

At the core, we expose a nix attribute set with 220+ base16 schemes, as well as a home-manager module for globally setting your preferred one.

These schemes are not vendored in: they are directly fetch (and flake locked!) from base16-schemes, then converted using our (pure nix) schemeFromYAML function, which is also exposed for your convenience. This means you can easily make your own schemes, in either nix-colors (.nix) or base16 (.yaml) format, freely converting between the two.

The core portion of nix-colors is very unopinionated and should work with all possible workflows very easily, without any boilerplate code.

We also have some optional contrib functions for opinionated, common use cases (generating scheme from image, generating wallpaper, vim scheme, gtk theme).

Base16?

Base16 is a standard for defining palettes (schemes), and how each app should be themed (templates).

nix-colors focuses on delivering and helping you use the schemes, all in a Nix-friendly way.

Setup

The usual setup looks like this:

  • Either add the repo to your flake inputs, or add the channel on a legacy setup.
  • Import the home-manager module nix-colors.homeManagerModules.default
  • Set the option colorScheme to your preferred color scheme, such as nix-colors.colorSchemes.dracula (or create/convert your own)
  • Use config.colorScheme.palette.base0X to refer to any of the 16 colors from anywhere!

Importing

Flake

First add nix-colors to your flake inputs:

{
  inputs = {
    # ...
    nix-colors.url = "github:misterio77/nix-colors";
  };
}

Then, you need some way to pass this onwards to your home-manager configuration.

If you're using standalone home-manager, use extraSpecialArgs for this:

homeConfigurations = {
  "foo@bar" = home-manager.lib.homeManagerConfiguration {
    # ...
    extraSpecialArgs = { inherit nix-colors; };
  };
};

Or, if using it as a NixOS module, use specialArgs on your flake (and extraSpecialArgs wherever you import your home nix file):

nixosConfigurations = {
  bar = nixpkgs.lib.nixosSystem {
    # ...
    specialArgs = { inherit nix-colors; };
  };
};

Legacy (non-flake)

If you're not using flakes, the most convenient method is adding nix-colors to your channels:

nix-channel --add https://github.com/misterio77/nix-colors/archive/main.tar.gz nix-colors
nix-channel --update

Then, instead of adding nix-colors as a argument in your config file(s), use a let binding. For example:

{ pkgs, config, ... }: # Don't put 'nix-colors' here
let
  nix-colors = import <nix-colors> { };
in {
  import = [
    nix-colors.homeManagerModules.default
  ];

  colorScheme = nix-colors.colorSchemes.paraiso;

  # ...
}

Using

With that done, move on to your home manager configuration.

You should import the nix-colors.homeManagerModules.default, and set the option colorScheme to your preferred scheme, such as nix-colors.colorSchemes.dracula

Here's a quick example on how to use it with, say, a terminal emulator (kitty) and a browser (qutebrowser):

{ pkgs, config, nix-colors, ... }: {
  imports = [
    nix-colors.homeManagerModules.default
  ];

  colorScheme = nix-colors.colorSchemes.dracula;

  programs = {
    kitty = {
      enable = true;
      settings = {
        foreground = "#${config.colorScheme.palette.base05}";
        background = "#${config.colorScheme.palette.base00}";
        # ...
      };
    };
    qutebrowser = {
      enable = true;
      colors = {
        # Becomes either 'dark' or 'light', based on your colors!
        webppage.preferred_color_scheme = "${config.colorScheme.variant}";
        tabs.bar.bg = "#${config.colorScheme.palette.base00}";
        keyhint.fg = "#${config.colorScheme.palette.base05}";
        # ...
      };
    };
  };
}

If you change colorScheme for anything else (say, nix-colors.colorSchemes.nord), both qutebrowser and kitty will match the new scheme! Awesome!

You can, of course, specify (or generate somehow) your nix-colors scheme directly:

{
  colorScheme = {
    slug = "pasque";
    name = "Pasque";
    author = "Gabriel Fontes (https://github.com/Misterio77)";
    palette = {
      base00 = "#271C3A";
      base01 = "#100323";
      base02 = "#3E2D5C";
      base03 = "#5D5766";
      base04 = "#BEBCBF";
      base05 = "#DEDCDF";
      base06 = "#EDEAEF";
      base07 = "#BBAADD";
      base08 = "#A92258";
      base09 = "#918889";
      base0A = "#804ead";
      base0B = "#C6914B";
      base0C = "#7263AA";
      base0D = "#8E7DC6";
      base0E = "#953B9D";
      base0F = "#59325C";
    };
  };
}

This is it for basic usage! You're ready to nixify your colors. Read on if you're interested in converting schemes between our format and base16's, or want to check out our opinionated contrib functions.

Lib functions

Core

Our core functions do not require nixpkgs. Nix all the way down (at least until you get to nix-the-package-manager code) baby!

All of these are exposed at nix-colors.lib.

schemeFromYAML

This function is used internally to convert base16's schemes to nix-colors format, but is exposed so you can absolutely do the same.

Just grab (or create yours) a .yaml file, read it into a string (with readFile, for example) and you're golden:

{ nix-colors, ... }:
{
  colorScheme = nix-colors.lib.schemeFromYAML "cool-scheme" (builtins.readFile ./cool-scheme.yaml);
}

This path can come from wherever nix can read, even another repo! That's what we do to expose base16's schemes.

More soon(TM)

We plan on helping you turn existing base16 templates into nifty nix functions real soon, as well as converting colors between hex and decimal. Stay tuned!

Contributed functions

We also have a few opinionated functions for some common scheme usecases: such as generating schemes from an image, generating an image from a scheme... You get the idea.

These nifty pals are listed (and documented) at lib/contrib/default.nix. They are exposed at nix-colors.lib.contrib.

Do note these require nixpkgs, however. You should pass your pkgs instance to nix-colors.lib.contrib to use them. For example:

{ pkgs, nix-colors, ... }:

let
  nix-colors-lib = nix-colors.lib.contrib { inherit pkgs; };
in {
  colorScheme = nix-colors-lib.colorSchemeFromPicture {
    path = ./wallpapers/example.png;
    variant = "light";
  };
}

Upstreaming new schemes

Please please upstream nice schemes you have created!

It's pretty easy to do. Just open up a PR on base16-schemes, and once it's in it will be available here.

If it takes a while to be merged, you can temporarily put it together with your config and use schemeFromYAML to load it.

Alternatively, you can tell nix-colors to follow your base16-schemes fork.

In your flake inputs, add base16-schemes and override nix-colors.inputs.base16-schemes.follows:

{
  description = "Your cool config flake";
  inputs = {
    base16-schemes = "github:you/base16-schemes"; # Your base16-schemes fork

    nix-colors.url = "github:misterio77/nix-colors";
    nix-colors.inputs.base16-schemes.follows = "base16-schemes"; # Be sure to add this
    # ...
  };
  # ...
}

Thanks

Special thanks to rycee for most of this repo's inspiration, plus for the amazing home-manager.

Huge thanks for everyone involved with base16.

Gigantic thanks to arcnmx, for his pure-nix fromYAML function.

Extra special thanks for my folks at the NixOS Brasil Telegram group, for willing to try this out!

nix-colors's People

Contributors

0oastro avatar djacu avatar iogamaster avatar lucasew avatar martin-lndbl avatar mateusauler avatar misterio77 avatar montchr avatar schwarmco avatar strout avatar xlambein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-colors's Issues

Infinite Recursion Error on Standalone Legacy Setup

Hi there,

I'm currently trying out nix and home-manager in a virtual machine, and I'd like to be able to use this module for creating a colorscheme setup. Here is my current HM config (standalone in EndeavourOS), though any time I run ``home-manager switch`, I get an infinite-recursion error whenever I try to import the module:

{ config, pkgs, nix-colors ? import <nix-colors> { },... }:  {
 ...
  targets.genericLinux.enable = true;
  fonts.fontconfig.enable = true;
  
  imports = [ nix-colors.homeManagerModule ];
  extraSpecialArgs = { inherit nix-colors; };
  colorScheme = nix-colors.colorSchemes.dracula;
}
...

I'm still fairly new to nix, so if I had done something wrong please let me know. If you need the entire config, here is the link to it.

Error: The option `colorScheme' does not exist

Hello, I am creating a new issue but it is similar to the closed #35 . I have the exact same error as described.
Unfortunately I went through the fix for #35 but did not fixed mine.

I am running home-manager in a standalone. Here is my flake.nix for home-manager :

{
  description = "Home Manager configuration of virgil";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-colors.url = "github:misterio77/nix-colors";

  };

  outputs = { nixpkgs, home-manager, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations."virgil" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        extraSpecialArgs = { inherit inputs; };

        modules = [ ./home.nix ];
      };
    };
}

Here is the relevant part of my home.nix :

{ pkgs, inputs, ... }:

{
   import = [
      inputs.nix-colors.homeManagerModules.colorscheme
     ./alacritty.nix
   ];

  colorScheme = inputs.nix-colors.colorSchemes.onedark;

Here is the error I get when running home-manager switch

╰─>$ home-manager switch
error:
       … while evaluating a branch condition

         at /nix/store/n2g5cqwv8qf5p6vjxny6pg3blbdij12k-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/n2g5cqwv8qf5p6vjxny6pg3blbdij12k-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `colorScheme' does not exist. Definition values:
       - In `/nix/store/qp2259lwhq39p4pq51qilq6b0s0mnpnj-source/home.nix':
           {
             author = "Lalit Magant (http://github.com/tilal6991)";
             name = "OneDark";
             palette = {
               base00 = "282c34";
           ...

I have double checked and I cannot figure out why it do not find the option.
I ran $ nix eval github:misterio77/nix-colors#homeManagerModules
And here is the output :

{ colorScheme = { imports = [ /nix/store/qdbkj8di083m9cj11zylzkzzqwn9wsaz-source/module/colorscheme.nix ]; }; colorscheme = «repeated»; default = «repeated»; }

Clearly colorScheme is there and exists. If you have any insight.

Colorscheme from image failing to work with home-manager switch

I can't seem to get the colorscheme generator to work.

Heres the code:

{ pkgs, nix-colors, ... }:

let
  nix-colors-lib = nix-colors.lib.contrib { inherit pkgs; };
in {
  colorScheme = nix-colors-lib.colorSchemeFromPicture {
    path = ./wallpaper.jpg;
    kind = "dark";
  };
}

I know its not some weird syntax error because i've been getting those but finally got it to work. (i also know that the file is correctly added and is in the correct location) help?

[bongo@laptop:/System32]$ home-manager switch --flake ./
error:
       … while evaluating a branch condition

         at /nix/store/dg2g5qwvs36dhfqj9khx4sfv0klwl9f0-source/lib/lists.nix:57:9:

           56|       fold' = n:
           57|         if n == len
             |         ^
           58|         then nul

       … while calling the 'length' builtin

         at /nix/store/dg2g5qwvs36dhfqj9khx4sfv0klwl9f0-source/lib/lists.nix:55:13:

           54|     let
           55|       len = length list;
             |             ^
           56|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: builder for '/nix/store/bl5ksnsc54yhcsy1ip0m16igx2c3i190-generated-colorscheme.drv' failed with exit code 1;
       last 8 log lines:
       > unpacking sources
       > patching sources
       > updateAutotoolsGnuConfigScriptsPhase
       > configuring
       > no configure script, doing nothing
       > building
       > Error: failed to fill whole buffer
       > Error: EOF while parsing a value
       For full logs, run 'nix log /nix/store/bl5ksnsc54yhcsy1ip0m16igx2c3i190-generated-colorscheme.drv'.

[bongo@laptop:/System32]$ nix log /nix/store/bl5ksnsc54yhcsy1ip0m16igx2c3i190-generated-colorscheme.drv
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/bl5ksnsc54yhcsy1ip0m16igx2c3i190-generated-colorscheme.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Error: failed to fill whole buffer
Error: EOF while parsing a value

base24 support

I said in another issue that the extra colors from base24 are missing in this project: #7 (comment). Without the extra colors, using nix-colors would kind of be a downgrade for me. Can base24 support please be added? The colorschemes that are only base16 would not have to be made base24 of course.

Usage with nixos module

IMO belongs to "Discussions" but since it is disabled, here it goes.

Is it somehow possible to use this on a nixos module?
For example to set console.colors etc.

Rose-Piné Colors are off

Hi,

I'm pretty new to nix and I'm unable to fix this problem on my own. I noticed, that the colors for rose-pine are not consistent with the upstream in https://github.com/tinted-theming/base16-schemes/blob/main/rose-pine.yaml
I created a waybar style to test this and got the following colors:

#custom-00 { background: #191724; color: #e0def4; }
#custom-01 { background: #1f1d2e; color: #e0def4; }
#custom-02 { background: #26233a; color: #e0def4; }
#custom-03 { background: #555169; color: #e0def4; }
#custom-04 { background: #6e6a86; color: #e0def4; }
#custom-05 { background: #e0def4; }
#custom-06 { background: #f0f0f3; }
#custom-07 { background: #c5c3ce; }
#custom-08 { background: #e2e1e7; }
#custom-09 { background: #eb6f92; }
#custom-0A { background: #f6c177; }
#custom-0B { background: #ebbcba; }
#custom-0C { background: #31748f; }
#custom-0D { background: #9ccfd8; }
#custom-0E { background: #c4a7e7; }
#custom-0F { background: #e5e5e5; }

while upstream of base16-schemes has the following colors

base00: "191724"
base01: "1f1d2e"
base02: "26233a"
base03: "6e6a86"
base04: "908caa"
base05: "e0def4"
base06: "e0def4"
base07: "524f67"
base08: "eb6f92"
base09: "f6c177"
base0A: "ebbcba"
base0B: "31748f"
base0C: "9ccfd8"
base0D: "c4a7e7"
base0E: "f6c177"
base0F: "524f67"

My guess is, that the used commit is locked in the flake.lock file of this repo, but as I said, I'm pretty new to nix and it is still confusing sometimes. I might create a PR if I am able to understand the problem, but for now I'm just happy to create a working config for my system ☮️ The config, which showcases this issue can be found here https://github.com/randomn4me/nix-flakes/tree/dev with the waybar config placed here https://github.com/randomn4me/nix-flakes/blob/dev/home/phil/features/desktop/common/wayland-wm/waybar.nix

Cheers

More base GTK themes?

The generated GTK theme is based on Materia, which is a great theme, but it would be nice to have more options. IMHO, Materia doesn't look that great with Tokyo Night and a lot of others themes.

I personally would like to see Colloid, but it may be a little bit harder to implement than Materia.

More lib functions?

Hey this is a great module and thanks for creating it!

One thing I had to do was convert hex values to comma separated RGB values so I could use them with waybar. The styling uses CSS and I needed them in RGB so I could use them with an opacity. I created several small functions to do the conversion which you can find here. Would be happy to put in a PR adding them to the lib of this module if it is desired.

reconciliating nix-colors with transparency?

i tried using nix-colors to swap out the theme for e.g. rofi, then realized that otherwise i might use rgba to also set a transparency value.
now, i'm not sure baking transparency into the color scheme (over application style) would make sense, as i suppose transparency isn't part of a color.
but then, what might be a good way to go about setting transparency while using nix-colors?

Is `schemeToYAML` deprecation really necessary?

I recently discovered that nix-colors comes with a schemeToYAML helper function. This is a helpful function to manage my wezterm colorscheme. Docs to Wezterm load_base16_scheme

For context: this is how I configured wezterm

{
  inputs,
  lib,
  config,
  ...
}: let
  cfg = config.myHomeModules.wezterm;
  # generate a YAML file for wezterm to generate the colorscheme
  pathToScheme = builtins.toFile "wezterm-base16.yaml" (inputs.nix-colors.lib.schemeToYAML config.colorScheme);
in {
  options.myHomeModules.wezterm = {
    enable =
      lib.mkEnableOption "enables wezterm"
      // {
        default = false;
      };
  };
  config = lib.mkIf cfg.enable {
    programs = {
      wezterm = {
        enable = true;
        extraConfig = ''
          -- load the base16 scheme from the path
          local colors, _ = wezterm.color.load_base16_scheme("${pathToScheme}")

          return {
            -- ## COLORSCHEME ##
            colors = colors,
            -- other config
          }
        '';
      };
    };
  };
}

My question is, can we keep the utils? If that's out of the question, can you suggest an alternative method? Thank you.
Awesome tool btw 💯

Freezes when using shell theme with zsh

Running the script using zsh causes it freeze:

otavio@micro ~ % zsh -x /nix/store/k63kv2airapd8pdkcffwysa0v8jqa3kn-shell-theme-default-dark.sh
+/etc/zshenv:5> [ -n '' ']'
+/etc/zshenv:6> __ETC_ZSHENV_SOURCED=1
+/etc/zshenv:8> [ -z 1 ']'
+/etc/zshenv:12> HELPDIR=/nix/store/05kh07z7xhadarx6s488z1jf25g660p0-zsh-5.9/share/zsh/5.9/help
+/etc/zshenv:15> p=/run/current-system/sw
+/etc/zshenv:16> fpath+=( /run/current-system/sw/share/zsh/site-functions /run/current-system/sw/share/zsh/5.9/functions /run/current-system/sw/share/zsh/vendor-completions )
+/etc/zshenv:15> p=/nix/var/nix/profiles/default
+/etc/zshenv:16> fpath+=( /nix/var/nix/profiles/default/share/zsh/site-functions /nix/var/nix/profiles/default/share/zsh/5.9/functions /nix/var/nix/profiles/default/share/zsh/vendor-completions )
+/etc/zshenv:15> p=/etc/profiles/per-user/otavio
+/etc/zshenv:16> fpath+=( /etc/profiles/per-user/otavio/share/zsh/site-functions /etc/profiles/per-user/otavio/share/zsh/5.9/functions /etc/profiles/per-user/otavio/share/zsh/vendor-completions )
+/etc/zshenv:15> p=/home/otavio/.nix-profile
+/etc/zshenv:16> fpath+=( /home/otavio/.nix-profile/share/zsh/site-functions /home/otavio/.nix-profile/share/zsh/5.9/functions /home/otavio/.nix-profile/share/zsh/vendor-completions )
+/etc/zshenv:25> test -f /etc/zshenv.local
+/home/otavio/.zshenv:1> source /home/otavio/.config/zsh/.zshenv
+/home/otavio/.config/zsh/.zshenv:2> . /etc/profiles/per-user/otavio/etc/profile.d/hm-session-vars.sh
+/etc/profiles/per-user/otavio/etc/profile.d/hm-session-vars.sh:2> [ -n 1 ']'
+/etc/profiles/per-user/otavio/etc/profile.d/hm-session-vars.sh:2> return
+/home/otavio/.config/zsh/.zshenv:5> [[ -z 1 ]]
+/home/otavio/.config/zsh/.zshenv:10> ZDOTDIR=/home/otavio/.config/zsh
+/home/otavio/.config/zsh/.zshenv:13> [ -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ']'
+/home/otavio/.config/zsh/.zshenv:17> export NIX_PATH='/home/otavio/.nix-defexpr/channels:/home/otavio/.nix-defexpr/channels:/home/otavio/.nix-defexpr/channels:/home/otavio/.nix-defexpr/channels:/home/otavio/.nix-defexpr/channels:nixpkgs=/etc/nix/channels/nixpkgs:home-manager=/etc/nix/channels/home-manager'
+/nix/store/k63kv2airapd8pdkcffwysa0v8jqa3kn-shell-theme-default-dark.sh:2> [ xterm '=' screen ']'
+/nix/store/k63kv2airapd8pdkcffwysa0v8jqa3kn-shell-theme-default-dark.sh:4> [ -n /tmp/tmux-1000/default,3810,0 ']'
+/nix/store/k63kv2airapd8pdkcffwysa0v8jqa3kn-shell-theme-default-dark.sh:11> apply_color '4;0;#181818'
+apply_color:0> echo -ne '\033Ptmux;\033\033]4;0;#181818\033\033\\033\'

Never gets out of the last echo.

iterm color schemes

https://github.com/colemickens/nix-rice/blob/1a08dc6d6d37f6b4919d332f4fde931447ac873d/flake.nix#L41-L68

I threw this together a while back and use it to set colorschemes across alacritty/wezterm/etc.

Not sure exactly how iTerm2-color-schemes [1] stacks up to base16-schemes... but thought I'd mention it. You have some momentum, the original repo I forked from is back to life and going another direction and I'll likely never get back to this:
https://github.com/mbadolato/iTerm2-Color-Schemes

Infinite recursion on nix-colors.homeManagerModule import

Good evening, @Misterio77,

After adding nix-colors to my home-manager flake inputs in

inputs = {
  # ...
  nix-colors.url = "github:misterio77/nix-colors";
};

Then trying to import nix-colors' home manager module with

{ config, pkgs, nix-colors, ... }: {
  # ...
  imports = [
    # ...
    nix-colors.homeManagerModule
  ];
}

I end up with a infinite recursion module:

+/nixpkgs$ hms
warning: Git tree '/home/marcosrdac/.config/nixpkgs' is dirty
error: infinite recursion encountered

       at /nix/store/s6wigis38dnikj5y92jrrj7ywc38b78g-source/lib/modules.nix:365:28:

          364|         builtins.addErrorContext (context name)
          365|           (args.${name} or config._module.args.${name})
             |                            ^
          366|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

When I remove the imports part, my configs start working again. Do you have any idea why it could be happening? My home-manager config are here, if it happens to matter.

Thank you beforehand for your attention!

[Question] Usage with SDDM Theme

Hi there, thanks for maintaining this. I really like being able to quickly get a consistent colorscheme for all my programs.

I'm currently creating a package for the sddm-sugar-dark theme, and trying to use nix-colors to create a wallpaper for it in a virtual machine. However, I'm getting an error that says argument nix-colors is required but not being passed. Here is my flake, and here are the files I'm using. I'm not sure what's going wrong, but I'd love to be able to use nix-colors to rice my login manager as well as my desktop.

HSL feature in nix-colors

@Misterio77 hi and thank you so much for the nix-colors, it’s amazing)

I was making a library to use base16 in Qtile, my main goal was to use only base16.
But sometimes there really aren’t enough colors, so I wrote a small class that receives a base16 color as input and shifts it according to HSL.
hslpicker

This is what it looks like:

Alt text

This is result:

  #...
 from base16_colorlib import Color
 from base16_colorlib import catppuccin_mocha
 #...

 colors = Color(**catppuccin_mocha)

 #...
 widgets = {
     #...
     'Timelabel': widget.TextBox(
         background=colors.lightness(colors.scheme['base0D'], -4),  # <= look this
         foreground=colors.scheme['base00'],
        #...
     ),
     'Time': widget.Clock(
         background=colors.scheme['base0D'],  # <= look this
         foreground=colors.scheme['base00'],
         #...
     ),
     #...
 }

Alt text

I saw some math in the nix-colors source code)
Maybe try implementing lib functions for nix-color that could allow changing colors in the configuration?

The shift is universal for all color schemes.
If, as in the example above, you need one color to be slightly darker or more saturated than another, this will work with any theme switched on the fly, etc.

For example, I rewrote the implementation from python to lua for awesomewm.
colorize
The difficulty with math is mainly in the functions for converting hex-rgb-hsl-rgb-hex, otherwise everything is elementary.
But as for Nix, unfortunately I don't know nixpkgs.lib well and can only write simple nix expressions(

I know that nix is ​​primarily a package manager, but it is also a functional language)

using extraSpecialArgs in home-manager fails

When I add this to my config:

{
  description = "A nix config";

  inputs = {
    nix-colors.url = "github:misterio77/nix-colors";
  };

  outputs = inputs@{ clip, nx, musnix, sops-nix, nixpkgs, nix-colors, home-manager, ... }:
    let 
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
    nixosConfigurations = {
      host1 = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        specialArgs = {  
          inherit nix-colors; 
        };
        modules = [
          nix-colors.homeManagerModules.default
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.thoth = import ../../users/thoth/home.nix;
            extraSpecialArgs = {inherit nix-colors;};
          }
        ];
      };
    };
  };
}

I get:

sudo nixos-rebuild switch --flake .#
trace: warning: External use of `lib.modules.applyModuleArgsIfFunction` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/.
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
trace: lib.crossLists is deprecated, use lib.cartesianProductOfSets instead
trace: warning: External use of `lib.modules.dischargeProperties` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/.
trace: warning: External use of `lib.modules.evalOptionValue` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/.
trace: warning: literalExample is deprecated, use literalExpression instead, or use literalMD for a non-Nix description.
error:
       … while calling the 'seq' builtin

         at /nix/store/f6lbic2a83c51ygb2czksw9gv8x6w5wg-source/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       … while calling the 'throw' builtin

         at /nix/store/f6lbic2a83c51ygb2czksw9gv8x6w5wg-source/lib/modules.nix:296:18:

          295|                     ''
          296|             else throw baseMsg
             |                  ^
          297|         else null;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/3cw7ichm2mrdkffyvhfrkwzkjafyixm0-source/maintainers': No such file or directory

Have I configured something wrong?

Getting length-12 hex strings for rgb values when expecting length-6 strings

I have just added nix-colors to my flake, and am attempting to use it in home-manager.
I was getting errors at first because all the color values I tried were 12-character hex strings, instead of 6. Upon inspection the 12-character strings were the 6-character strings repeated twice. For example, instead of 282828 for nix-colors.colorSchemes.gruvbox-mark-medium.base00, I am getting 282828282828.

The error seems to be consistent, so I'm using builtins.subString 0 6 as a temporary workaround.

The relevant portion from my flake.lock is as follows

    "nix-colors": {
      "inputs": {
        "base16-schemes": "base16-schemes",
        "nixpkgs-lib": "nixpkgs-lib"
      },
      "locked": {
        "lastModified": 1707825078,
        "narHash": "sha256-hTfge2J2W+42SZ7VHXkf4kjU+qzFqPeC9k66jAUBMHk=",
        "owner": "misterio77",
        "repo": "nix-colors",
        "rev": "b01f024090d2c4fc3152cd0cf12027a7b8453ba1",
        "type": "github"
      },
      "original": {
        "owner": "misterio77",
        "repo": "nix-colors",
        "type": "github"
      }
    },

Documentation for setting GTK theme

I am trying to figure out how to use the gtk theme generation functionality, and how to make it set as the gtk theme. I've tried but can't figure out how to do this. a short example in the README.md would be very helpful. thanks

`error: infinite recursion encountered` when trying out example in readme

The example of a config for kitty and qutebrowser in the readme gives an error when trying to switch:

error: infinite recursion encountered

       at /nix/store/f5hg16l66fhp7qpszkn82fazh2x4pnin-source/lib/modules.nix:365:28:

          364|         builtins.addErrorContext (context name)
          365|           (args.${name} or config._module.args.${name})
             |                            ^
          366|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

I'm using exactly the config form the readme but i don't understand what the error is saying at all.

`inputs.nix-colors.colorSchemes.3024` cannot be evaluated

When inspecting the nix-colors flake outputs in nix repl, I get the following error when attempting to see the contents of the 3024 scheme:

nix-repl> inputs.nix-colors.colorSchemes.3024
error: attempt to call something which is not a function but a set

       at «string»:1:1:

            1| inputs.nix-colors.colorSchemes.3024
             | ^

I haven't encountered this with any other color scheme in the flake outputs, though I can't say I've tested more than a couple.

Full demonstration

asciicast

kitty spams "-ne" when setting the shell theme in fish

relevant home manager section:

fish.interactiveShellInit = {
  fish_vi_key_bindings
  sh ${nix-colors-lib.shellThemeFromScheme { scheme = config.colorScheme; }}
};

Removing sh ${nix-colors-lib.shellThemeFromScheme { scheme = config.colorScheme; }} fixes the issue.

darwin: invalid regular expression in `schemeFromYAML.nix`

Since updating to the latest version, I'm getting the following error on macOS:

error: invalid regular expression '([^#]*)(#.*|)'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:33:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                                 ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

FWIW, I've seen similar Darwin-specific errors in home-manager relating to regular expressions.

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
these 2 paths will be fetched (0.34 MiB download, 2.06 MiB unpacked):
  /nix/store/dwc47n75p5zbml53x8p25phnks1hlr9h-bash-interactive-5.1-p16-doc
  /nix/store/gzwsyaz1p2cj70rxgbj026s3bx8bsy6f-bash-interactive-5.1-p16-dev
copying path '/nix/store/dwc47n75p5zbml53x8p25phnks1hlr9h-bash-interactive-5.1-p16-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/gzwsyaz1p2cj70rxgbj026s3bx8bsy6f-bash-interactive-5.1-p16-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-darwin"`
 - host os: `Darwin 21.5.0, macOS 10.16`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.8.1`
 - channels(montchr): `"home-manager, nixos-unstable, nixpkgs, nixpkgs-unstable, unstable"`
 - channels(root): `"nixpkgs-22.05pre357729.22dc22f8ced, unstable-22.05pre357729.22dc22f8ced, channel-nixpkgs-unstable-22.05pre357729.22dc22f8ced"`
 - nixpkgs: `/etc/nix/inputs/nixpkgs`

Stack Trace

$ nix flake update && darwin-rebuild build --verbose --flake . --show-trace
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
building the system configuration...
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
error: invalid regular expression '([^#]*)(#.*|)'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:33:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                                 ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

       … while evaluating 'stripLine'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:19:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                   ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

       … from call site

       … while evaluating 'usefulLine'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:29:20:

           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;
             |                    ^
           30|       parseString = token:

       … from call site

       … while evaluating 'mapListToAttrs'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:5:23:

            4|   # All of these are borrowed from nixpkgs
            5|   mapListToAttrs = f: l: listToAttrs (map f l);
             |                       ^
            6|   escapeRegex = escape (stringToCharacters "\\[{()^$?*+|.");

       … from call site

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:47:5:

           46|     in
           47|     mapListToAttrs attrLine lines'';
             |     ^
           48|

       … while evaluating 'fromYAML'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:26:14:

           25|   # From https://github.com/arcnmx/nixexprs
           26|   fromYAML = yaml:
             |              ^
           27|     let

       … from call site

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:59:55:

           58|
           59|   schemeFromYAML = slug: content: convertScheme slug (fromYAML content);
             |                                                       ^
           60| in

       … while evaluating the attribute 'value.content'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:918:14:

          917|     { _type = "override";
          918|       inherit priority content;
             |              ^
          919|     };

       … while evaluating the attribute 'value._type'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:871:73:

          870|       highestPrio = foldl' (prio: def: min (getPrio def) prio) 9999 defs;
          871|       strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
             |                                                                         ^
          872|     in {

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:19:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |                   ^
          771|           then sortProperties defs''.values

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:14:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          771|           then sortProperties defs''.values

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.colorScheme.colors.base00':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'default'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/module/colorscheme.nix:35:7:

           34|       type = types.enum [ "dark" "light" ];
           35|       default =
             |       ^
           36|         if builtins.substring 0 1 cfg.colors.base00 < "5" then

       … while evaluating the attribute 'value.content'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:918:14:

          917|     { _type = "override";
          918|       inherit priority content;
             |              ^
          919|     };

       … while evaluating the attribute 'value._type'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:871:73:

          870|       highestPrio = foldl' (prio: def: min (getPrio def) prio) 9999 defs;
          871|       strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
             |                                                                         ^
          872|     in {

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:19:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |                   ^
          771|           then sortProperties defs''.values

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:14:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          771|           then sortProperties defs''.values

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.colorScheme.kind':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:436:60:

          435|           # Push down position info.
          436|           (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs)));
             |                                                            ^
          437|       emptyValue = { value = {}; };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/s6lzqq8mzb7j5kbyfm801sqy78wiwfz2-source/users/profiles/firefox':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.programs.firefox.profiles.home.settings':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'condition'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:903:14:

          902|     { _type = "if";
          903|       inherit condition content;
             |              ^
          904|     };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/programs/firefox.nix':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.home.file':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating 'mapAttrsToList'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:355:23:

          354|   */
          355|   mapAttrsToList = f: attrs:
             |                       ^
          356|     map (name: f name attrs.${name}) (attrNames attrs);

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:48:14:

           47|             (foldAttrs (acc: v: acc + v) 0
           48|             (mapAttrsToList (n: v: { ${v.target} = 1; }) cfg)));
             |              ^
           49|         dupsStr = concatStringsSep ", " dups;

       … while evaluating 'fold''

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == len

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while evaluating 'foldr'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     let

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:47:14:

           46|             (filterAttrs (n: v: v > 1)
           47|             (foldAttrs (acc: v: acc + v) 0
             |              ^
           48|             (mapAttrsToList (n: v: { ${v.target} = 1; }) cfg)));

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:46:14:

           45|           attrNames
           46|             (filterAttrs (n: v: v > 1)
             |              ^
           47|             (foldAttrs (acc: v: acc + v) 0

       … while evaluating the attribute 'assertion'

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:51:9:

           50|       in {
           51|         assertion = dups == [];
             |         ^
           52|         message = ''

       … while evaluating the attribute 'assertion'

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/nix-darwin/default.nix:120:32:

          119|           {
          120|             inherit (assertion) assertion;
             |                                ^
          121|             message = "${user} profile: ${assertion.message}";

       … while evaluating anonymous lambda

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:11:50:

           10|
           11|   failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
             |                                                  ^
           12|

       … from call site

       … while evaluating 'throwAssertions'

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:13:21:

           12|
           13|   throwAssertions = res: if (failedAssertions != []) then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" else res;
             |                     ^
           14|   showWarnings = res: fold (w: x: builtins.trace "warning: ${w}" x) res config.warnings;

       … from call site

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:73:29:

           72|
           73|     system.build.toplevel = throwAssertions (showWarnings (stdenvNoCC.mkDerivation {
             |                             ^
           74|       name = "darwin-system-${cfg.darwinLabel}";

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:436:60:

          435|           # Push down position info.
          436|           (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs)));
             |                                                            ^
          437|       emptyValue = { value = {}; };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `system.build':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

Installation problem

Hi,
I am very new to NixOS and had difficulty in following your installation instructions. I tried modifying my ~/.config/home-manager/flake.nix file as recommended for the standalone home manager installation and kept getting "undefined variable: nix-colors" error. Please see below my flake.nix file.

`{
description = "Home Manager configuration of user";

inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-colors.url = "github:misterio77/nix-colors";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
homeConfigurations."user" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./home.nix ];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = { inherit nix-colors; };
};
};
}`

I appreciate any pointers about what I am doing wrong.

On Alacritty autoreload

Hey, you who currently use alacritty as main terminal.

Alacritty is known for its ability of automatically reload configs when they are changed. For some reason, it seems not to automatically reload when the configuration file is a symlink (usual for home-manager users) which gets replaced with another link, at least in my experience. This means that changing a colorscheme does not change the existing windows, but the new ones. I tried importing colors from another file (that was also a link hahaha), writing the config as true YAML (home-manager module actually writes it as a JSON), signalling it with SIGUSR1 and SIGHUP (I only killed my existing windows on these tests).

After configuring and automatically reloading colors for almost all my applications using nix-colors (thank @Misterio77 for that), I could not update the one that I though was going to be easy! 😆

Did anyone achieve reloading alacritty after a nix-colors scheme change?

Add variants/target to schemes

Hello!

Since this is the first time I'm opening an issue let me say thank you for creating this project.

I added a colorscheme to kitty first and I noticed there is a separate scheme for terminals.

I was wondering if the target audience/software could become a first class citizen in schemes.

For example: terminal emulators could use the terminal variant (if there is any) and use the primary one as a fallback.

I know this would introduce a complexity (and would make the scheme differ from base16), but I also think it would make application theming better (right now, I specified an override colorscheme for kitty to use the terminal variant).

Error: The option `colorScheme' does not exist

I use nix-colors in the standalone home manager, but the home manager says there is no colorScheme option.

error: The option colorScheme' does not exist. Definition values: - In /nix/store/qk95iszvpf2bclnbdps1n8j080kvv8an-source/home-manager/global/colors.nix':
{
author = "https://github.com/catppuccin/catppuccin";
colors = {
base00 = "303446";
base01 = "292c3c";
...

I don't know what I missed. I have checked my configuration in detail.

Here is my relevant sample file:

# flake.nix
{
  description = "QingyaoLin's nix config";

  inputs = {
    # Nixpkgs
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
    # You can access packages and modules from different nixpkgs revs
    # at the same time. Here's an working example:
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    # Also see the 'unstable-packages' overlay at 'overlays/default.nix'.

    # Home manager
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    # TODO: Add any other flake you might need
    # hardware.url = "github:nixos/nixos-hardware";

    # Shameless plug: looking for a way to nixify your themes and make
    # everything match nicely? Try nix-colors!
    nix-colors.url = "github:misterio77/nix-colors";
    picom.url = "github:yaocccc/picom";
  };

  outputs = { self, nixpkgs, home-manager, ... }@inputs:
    let
      inherit (self) outputs;
      forAllSystems = nixpkgs.lib.genAttrs [
        "x86_64-linux"
      ];
    in
    rec {
      # Your custom packages
      # Acessible through 'nix build', 'nix shell', etc
      packages = forAllSystems (system:
        let pkgs = nixpkgs.legacyPackages.${system};
        in import ./pkgs { inherit pkgs; }
      );
      # Devshell for bootstrapping
      # Acessible through 'nix develop' or 'nix-shell' (legacy)
      devShells = forAllSystems (system:
        let pkgs = nixpkgs.legacyPackages.${system};
        in import ./shell.nix { inherit pkgs; }
      );

      # Your custom packages and modifications, exported as overlays
      overlays = import ./overlays { inherit inputs; };
      # Reusable nixos modules you might want to export
      # These are usually stuff you would upstream into nixpkgs
      nixosModules = import ./modules/nixos;
      # Reusable home-manager modules you might want to export
      # These are usually stuff you would upstream into home-manager
      homeManagerModules = import ./modules/home-manager;

      # NixOS configuration entrypoint
      # Available through 'nixos-rebuild --flake .#NixOS'
      nixosConfigurations = {
        "NixOS" = nixpkgs.lib.nixosSystem {
          specialArgs = { inherit inputs outputs; };
          modules = [
            # > Our main NixOS configuration file <
            ./nixos/configuration.nix
          ];
        };
      };

      # Standalone home-manager configuration entrypoint
      # Available through 'home-manager --flake .#lqy@NixOS'
      homeConfigurations = {
        "lqy@NixOS" = home-manager.lib.homeManagerConfiguration {
          pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
          extraSpecialArgs = { inherit inputs outputs; };
          modules = [
            # > Our main home-manager configuration file <
            ./home-manager/home.nix
          ];
        };
      };
    };
}
# home-manager/home.nix
{ inputs, outputs, lib, config, pkgs, ... }:
{
  imports = [
    inputs.nix-colors.homeManagerModules
  ];
  nixpkgs = {
    # You can add overlays here
    overlays = [
      # Add overlays your own flake exports (from overlays and pkgs dir):
      outputs.overlays.additions
      outputs.overlays.modifications
      outputs.overlays.unstable-packages

      # You can also add overlays exported from other flakes:
      # neovim-nightly-overlay.overlays.default
      inputs.picom.overlays.default

      # Or define it inline, for example:
      # (final: prev: {
      #   hi = final.hello.overrideAttrs (oldAttrs: {
      #     patches = [ ./change-hello-to-hi.patch ];
      #   });
      # })
    ];
    # Configure your nixpkgs instance
    config = {
      # Disable if you don't want unfree packages
      allowUnfree = true;
      # Workaround for https://github.com/nix-community/home-manager/issues/2942
      allowUnfreePredicate = (_: true);
    };
  };

  # Set your username
  home = {
    username = "lqy";
    homeDirectory = "/home/lqy";
  };

  # Add stuff for your user as you see fit:
  home.packages = with pkgs; [
    microsoft-edge
    pavucontrol
    gnome.gucharmap
    tdesktop
    papirus-icon-theme
    wget
    (nerdfonts.override { fonts = [
      "FiraCode"
	    "Hack"
	    "JetBrainsMono"
    ]; })
  ];

  # Enable home-manager and git
  programs.home-manager.enable = true;

  # Nicely reload system units when changing configs
  systemd.user.startServices = "sd-switch";

  # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
  home.stateVersion = "22.11";
}
# colors.nix
{ inputs, lib, config, pkgs, ... }:
{
  colorScheme = inputs.nix-colors.colorSchemes.catppuccin-frappe;
}

vim plugin usage is unavaialbe in vim, only in neovim

In home-manager, programs.vim.plugins expects a package from vimPlugins, neovim.plugins will take a submodule .
If you try to use this with vim.plugins, you'll get an error:

error: A definition for option `programs.vim.plugins."[definition 1-entry 2]"' is not of type `string or package'. Definition values:
       - In `/nix/store/ijy10wfrhv0iinskckx0wzp95igb5zcb-source/home-manager/cole/cli/vim.nix':
           {
             config = "colorscheme nix-material-darker";
             plugin = <derivation /nix/store/h3lr56hl0l5hi2bksaiabyx2v38d2lhx-nix-material-darker.vim.drv>;
           }

Documentation should make this clearer. Happy to take any thoughts/suggestions and make a pr.

Infinite recursion

Hey. As the others before me #11, I'm encountering the dreaded infinite recursion
I know the issue likely comes from my setup. Feel free to close this issue and ignore it

Otherwise, if you want to have a look, here's my config. It should be familiar to you, as I was heavily inspired by yours.
I have taken care to pass extraArgs, so I don't think that is the issue.

Trace:

building the system configuration...
error: infinite recursion encountered

       at /nix/store/mmwiiajx1lbly4pqg4zi6ficvjfkszsp-source/lib/modules.nix:483:28:

          482|         builtins.addErrorContext (context name)
          483|           (args.${name} or config._module.args.${name})
             |                            ^
          484|       ) (lib.functionArgs f);

       … while evaluating the module argument `nix-colors' in ":anon-5:anon-1":

       … while evaluating anonymous lambda

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.