danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.22k stars 159 forks source link

The option `stylix.image' is used but not defined. #421

Open MercuryHgO opened 5 months ago

MercuryHgO commented 5 months ago
error:
       … while calling the 'head' builtin

         at /nix/store/giq1qbcwfx5gq0g9jf6id0b3m55a860j-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/giq1qbcwfx5gq0g9jf6id0b3m55a860j-source/lib/modules.nix:809:9:

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

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

       error: The option `stylix.image' is used but not defined.

Cant build flake with home-manager and stylix.

./flake.nix

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";

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

    stylix = {
      url = "github:danth/stylix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
        home-manager.follows = "home-manager";
      };
    };
  };

  outputs = { self, nixpkgs, stylix, home-manager, ...}@inputs:

    let 
      system = "x86_64-linux";
    in {
      nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {

        specialArgs = {
          pkgs-stable = import nixpkgs {
            inherit system;
            config.allowUnfree = true;
          };
          inherit inputs system;
        };

        modules = [
          ./nixos/configuration.nix
          inputs.stylix.nixosModules.stylix
          home-manager.nixosModules.default
        ];

        # home-manager.useGlobalPkgs = true;
        # home-manager.useUserPackages = true;
        # home-manager.users.bittermann = import ./home.nix;
      };
    };
}

home.nix

{ pkgs, ... }: {
  stylix = {
    base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-medium.yaml";
  };

  home.username = "bittermann";
  home.homeDirectory = "/home/bittermann";
  home.stateVersion = "24.05";
  programs.home-manager.enable = true;
}
danth commented 5 months ago

Hi! I'm not sure if you're just trying to install Stylix, or if this is a new issue as a result of recent updates.

Do you have any other Stylix settings in your nixos/configuration.nix?

If you're installing Stylix for the first time, then from the config you've provided, it looks like you'll need to do the following:

  1. Move your Stylix settings from home.nix to configuration.nix, since you imported the NixOS version of Stylix.
  2. Choose a wallpaper using stylix.image.
MercuryHgO commented 5 months ago

Hi! I'm not sure if you're just trying to install Stylix, or if this is a new issue as a result of recent updates.

Do you have any other Stylix settings in your nixos/configuration.nix?

If you're installing Stylix for the first time, then from the config you've provided, it looks like you'll need to do the following:

1. Move your Stylix settings from `home.nix` to `configuration.nix`, since you imported the NixOS version of Stylix.

2. Choose a wallpaper using `stylix.image`.

Same result, if i try adding the image it says

error: builder for '/nix/store/y5491140ymf8vcvgky4hdqkcfnghc3d6-stylix-kde-theme.drv' failed with exit code 1;
       last 1 log lines:
       > magick: unable to open image '/home/bittermann/nix/wallpaper.jpg': No such file or directory @ error/blob.c/OpenBlob/3596.

Directory is valid

MercuryHgO commented 5 months ago

Is it necessary to add wallpaper to config?

MercuryHgO commented 5 months ago

if i try adding the image it says

error: builder for '/nix/store/y5491140ymf8vcvgky4hdqkcfnghc3d6-stylix-kde-theme.drv' failed with exit code 1;
       last 1 log lines:
       > magick: unable to open image '/home/bittermann/nix/wallpaper.jpg': No such file or directory @ error/blob.c/OpenBlob/3596.

My fault, but even if i add the image, it says this:


error:
… while calling the 'head' builtin
     at /nix/store/giq1qbcwfx5gq0g9jf6id0b3m55a860j-source/lib/attrsets.nix:1575:11:

     1574|         || pred here (elemAt values 1) (head values) then
     1575|           head values
         |           ^
     1576|         else

   … while evaluating the attribute 'value'

     at /nix/store/giq1qbcwfx5gq0g9jf6id0b3m55a860j-source/lib/modules.nix:809:9:

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

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

   error: syntax error, unexpected invalid token

   at /nix/store/19njvlyri8lkvrq3md997i1adwzicldr-source/nixos/wallpaper.jpg:1:1:

        1| ����JFIF,,AMPF��
         | ^
        2| �ExifMM*
                  ����(1�2�<��i��%  XAppleiPhone 12 miniHH17.4.12024:05:16 17:33:37iPhone 12 mini$�������"�' �0232���
                  ```
danth commented 5 months ago

That error sounds like it's trying to import the image as if it was Nix code.

How did you set the wallpaper option?

MercuryHgO commented 5 months ago

That error sounds like it's trying to import the image as if it was Nix code.

How did you set the wallpaper option?

Yea, im accidentally imported as import ./wallaper.png.

Its still not processing this image if configures as absolute path:

  stylix = {
    enable = true;
    base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-medium.yaml";
    image = "/home/bittermann/nix/nixos/wallpaper.png";
  };

error

error: builder for '/nix/store/xzkgbldmbngj32m9glv5yjxf87ji0bxc-stylix-kde-theme.drv' failed with exit code 1;
       last 1 log lines:
       > magick: unable to open image '/home/bittermann/nix/nixos/wallpaper.png': No such file or directory @ error/blob.c/OpenBlob/3596.
       For full logs, run 'nix log /nix/store/xzkgbldmbngj32m9glv5yjxf87ji0bxc-stylix-kde-theme.drv'.
error: 1 dependencies of derivation '/nix/store/gjva7p2b3nvn7xng9h7cljgd5i3p11km-activation-script.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9pm011fcspbjka488shwr3ly2ivhj4ss-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/53dbnjp5mqfskr75aw067dlvg5dahrmn-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/89xbmkg0wn3fmac18gwdg6wcsykz8yc7-unit-home-manager-bittermann.service.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rclra762f5mx13cb8phl9zgr37pav3fh-system-units.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lj3ivdnaw5zwljhsv5rh30xmhw0cv05h-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hyj48amrxzwsr45k3hn6ij485h88rh6y-nixos-system-nixos-24.05.20240609.2819fff.drv' failed to build
danth commented 5 months ago

Try configuring it as a relative path without quotes, like this: ./wallpaper.png

It will need to be in the same directory as your Nix files.

geryzhydrox commented 5 months ago

Hey there, I've had various arcane errors with Stylix that I've tried - and failed - to get help with on Element, but now after switching to flakes my error message has switched to something that apparently at least someone else has too, error: The option 'stylix.image' is used but not defined.. I'm trying the same things now and am still stuck at that error.

MercuryHgO commented 5 months ago

Try configuring it as a relative path without quotes, like this: ./wallpaper.png

It will need to be in the same directory as your Nix files.

That fixed my issue, thanks. But still, is it should be necessary to define wallpaper?

MasonRhodesDev commented 5 months ago

I'd like to add that I experienced this issue after updating my flake with nix flake update It seems the recent(?) change that requires you set stylix.enable may have caused stylix.image not to be defined anymore.

I added stylix.enable = true; to my configuration.nix to solve the issue.

trueNAHO commented 5 months ago

But still, is it should be necessary to define wallpaper?

See https://github.com/danth/stylix/issues/200.

joefiorini commented 5 months ago

I have what I believe to be the latest stylix and the latest nix-darwin. I'm getting error: The option 'stylix.image' is used but not defined. as well when trying to use nix-darwin switch.

I noticed the error actually occurs at: /nix/store/c5d7z0g0mqdvqanndgcfxcffvkcn4ymd-source/stylix/home-manager-integration.nix. Based on that, is it breaking because the home-manager config doesn't have defs for stylix?

Here is the relevant subset of my nix flake metadata output:

├───home-manager: github:nix-community/home-manager/845a5c4c073f74105022533907703441e0464bc3?narHash=sha256-vWSkg6AMok1UUQiSYVdGMOXKD2cDFnajITiSi0Zjd1A%3D (2024-06-04 18:53:02)
│   └───nixpkgs follows input 'nixpkgs'
├───nix-darwin: github:lnl7/nix-darwin/58b905ea87674592aa84c37873e6c07bc3807aba?narHash=sha256-iMVwdob8F6P6Ib%2BpnhMZqyvYI10ZxmvA885jjnEaO54%3D (2024-06-15 08:40:58)
│   └───nixpkgs follows input 'nixpkgs-darwin'
└───stylix: github:danth/stylix/f13c946181730f98e1a5cd09714100490207b250?narHash=sha256-REUyeY%2BgD/QuTwAhuJycheej0FWFGPTosI%2BjiG5TsQk%3D (2024-06-17 14:30:35)
    ├───home-manager: github:nix-community/home-manager/e3ad5108f54177e6520535768ddbf1e6af54b59d?narHash=sha256-W9pyM3/vePxrffHtzlJI6lDS3seANQ%2BNqp%2Bi58O46LI%3D (2024-05-17 07:24:04)
    │   └───nixpkgs follows input 'stylix/nixpkgs'
    └───nixpkgs: github:NixOS/nixpkgs/ee4a6e0f566fe5ec79968c57a9c2c3c25f2cf41d?narHash=sha256-clkcOIkg8G4xuJh%2B1onLG4HPMpbtzdLv4rHxFzgsH9c%3D (2024-05-05 12:27:12)
georgealexanderday commented 3 months ago

Even when setting an image but specifying base16 theme, I'm seeing no/wrong application of themes with no build errors, think something might be afoot here but haven't had the chance to investigate further yet.

trueNAHO commented 3 months ago

Even when setting an image but specifying base16 theme, I'm seeing no/wrong application of themes with no build errors

If by "no/wrong", you mean that Stylix is not actually doing anything, consider reading https://github.com/danth/stylix/issues/417#issuecomment-2157942224.

RekitRalph commented 1 month ago

I am encountering a similar issue. if I do not define stylix.enable = true; along with the wallpaper and color theme, in the configuration.nix I get the same error: The option 'stylix.image' was accessed but has no value defined. Try setting the option.

I thought I could just put the options in home.nix instead of configuration.nix is the correct?

Here is my flake.

outputs = inputs@{ self, nixpkgs, home-manager, ... }: {

    nixosConfigurations = {

      nixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          inputs.stylix.nixosModules.stylix

          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.evan = import ./home/home.nix;

            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
      };
    };
  };
danth commented 1 month ago

It's the other way around - you can use configuration.nix and the settings will automatically be copied to Home Manager.