From 90a49ac1743c36d8823ccd56ed16726a57ed9b70 Mon Sep 17 00:00:00 2001 From: mood <74420740+no-mood@users.noreply.github.com> Date: Sat, 17 Aug 2024 01:32:31 +0200 Subject: [PATCH] stylix: adding option for other wallpapers and improvements (DRAFT) --- stylix/darwin/default.nix | 2 +- stylix/flake-wallpaper.nix | 41 +++++++++++++++++++++++ stylix/hm/default.nix | 2 +- stylix/nix-wallpaper.nix | 14 ++++++++ stylix/nixos/default.nix | 2 +- stylix/{pixel.nix => pixel-wallpaper.nix} | 2 +- 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 stylix/flake-wallpaper.nix create mode 100644 stylix/nix-wallpaper.nix rename stylix/{pixel.nix => pixel-wallpaper.nix} (87%) diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index 19e7c6e12..331943ede 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -6,7 +6,7 @@ let autoload = import ../autoload.nix { inherit lib; } "darwin"; in { imports = [ - ../pixel.nix + ../nix-wallpaper.nix ../target.nix ../opacity.nix ./fonts.nix diff --git a/stylix/flake-wallpaper.nix b/stylix/flake-wallpaper.nix new file mode 100644 index 000000000..fd8e49581 --- /dev/null +++ b/stylix/flake-wallpaper.nix @@ -0,0 +1,41 @@ +{ pkgs, config, ... }: +{ width +, height +, logoScale +, backgroundColor ? config.lib.stylix.colors.withHashtag.base01 +, logoColor1 ? config.lib.stylix.colors.withHashtag.base0C +, logoColor2 ? config.lib.stylix.colors.withHashtag.base0D +}: +pkgs.stdenv.mkDerivation { + name = "generated-nix-wallpaper-${config.lib.stylix.colors.slug}.png"; + src = pkgs.writeTextFile { + name = "template.svg"; + text = '' + + + + + + + + + + + + ''; + }; + buildInputs = with pkgs; [ inkscape ]; + unpackPhase = "true"; + buildPhase = '' + inkscape --export-type="png" $src -w ${toString width} -h ${ + toString height + } -o wallpaper.png + ''; + installPhase = "install -Dm0644 wallpaper.png $out"; +} diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index a5cae1774..66db44f0c 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -6,7 +6,7 @@ let autoload = import ../autoload.nix { inherit lib; } "hm"; in { imports = [ - ../pixel.nix + ../nix-wallpaper.nix ../target.nix ../opacity.nix ./cursor.nix diff --git a/stylix/nix-wallpaper.nix b/stylix/nix-wallpaper.nix new file mode 100644 index 000000000..86fb5a189 --- /dev/null +++ b/stylix/nix-wallpaper.nix @@ -0,0 +1,14 @@ +{ pkgs ? import { } }: +rec { + # Takes a scheme, resulting wallpaper height and width, plus logo scale, and ouputs the generated wallpaper path + # Example: + # wallpaper = nixWallpaperFromScheme { + # width = 2560; + # height = 1440; + # logoScale = 5.0; + # }; + config.lib.stylix.flake = import ./flake-wallpaper.nix { inherit pkgs; }; + + config.lib.stylix.pixel = import ./pixel-wallpaper.nix { inherit pkgs; }; + +} \ No newline at end of file diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 56c4741b5..c254b758e 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -6,7 +6,7 @@ let autoload = import ../autoload.nix { inherit lib; } "nixos"; in { imports = [ - ../pixel.nix + ../nix-wallpaper.nix ../target.nix ../opacity.nix ./cursor.nix diff --git a/stylix/pixel.nix b/stylix/pixel-wallpaper.nix similarity index 87% rename from stylix/pixel.nix rename to stylix/pixel-wallpaper.nix index 7c1049286..40cf5668b 100644 --- a/stylix/pixel.nix +++ b/stylix/pixel-wallpaper.nix @@ -2,7 +2,7 @@ { # Generate a PNG image containing a named color - config.lib.stylix.pixel = color: + color: pkgs.runCommand "${color}-pixel.png" { color = config.lib.stylix.colors.withHashtag.${color}; } "${pkgs.imagemagick}/bin/convert xc:$color png32:$out";