main
 1{
 2  inputs,
 3  lib,
 4  ...
 5}: {
 6  flake-file.inputs = {
 7    stylix = {
 8      url = "github:nix-community/stylix";
 9      inputs.nixpkgs.follows = "nixpkgs";
10    };
11    wallpapers = {
12      url = "git+https://repo.hpcesia.com/HPCesia/Wallpapers?shallow=1";
13      flake = false;
14    };
15  };
16
17  flake.modules.nixos.core = {
18    pkgs,
19    config,
20    ...
21  }: let
22    base16-schemes = pkgs.base16-schemes;
23    base24-schemes = base16-schemes.overrideAttrs {
24      installPhase = ''
25        runHook preInstall
26
27        mkdir -p $out/share/themes/
28        install base24/*.yaml $out/share/themes/
29
30        runHook postInstall
31      '';
32    };
33  in {
34    imports = [inputs.stylix.nixosModules.stylix];
35
36    stylix = let
37      schemeName = "catppuccin-mocha";
38      theme = "${base24-schemes}/share/themes/${schemeName}.yaml";
39
40      inputImage = "${inputs.wallpapers}/Corin-1.jpg";
41      # brightness =
42      #   if config.lib.stylix.colors.variant == "dark"
43      #   then "-20"
44      #   else "0";
45      # contrast =
46      #   if config.lib.stylix.colors.variant == "dark"
47      #   then "10"
48      #   else "0";
49      # fillColor =
50      #   if config.lib.stylix.colors.variant == "dark"
51      #   then "black"
52      #   else "white";
53    in {
54      enable = true;
55      base16Scheme = theme;
56      polarity = config.lib.stylix.colors.variant;
57      # Commented out because I'm using a darker background image.
58      # This is because the previous background image is too bright for my taste.
59      # image = pkgs.runCommand "dimmed-background.png" {} ''
60      #   ${lib.getExe' pkgs.imagemagick "convert"} "${inputImage}" -brightness-contrast ${brightness},${contrast} -fill ${fillColor} $out
61      # '';
62      image = inputImage;
63      opacity = {
64        applications = 0.9;
65        desktop = 0.9;
66        popups = 0.9;
67        terminal = 1.0;
68      };
69    };
70  };
71}