~ruther/nixos-config

4429e050649adc6733552021cbcd1f88f591d97d — Frantisek Bohacek 8 months ago 75b58bc
feat: add mako program
M home/modules/profiles/desktop/dwl/default.nix => home/modules/profiles/desktop/dwl/default.nix +43 -0
@@ 20,6 20,8 @@ let
  wlopmEnableScreens = wlopmScreens "on";
in {
  imports = [
    ./mako.nix
    ./mako-hm-impl.nix
  ];

  options = {


@@ 112,6 114,46 @@ in {
      };
    };

    rutherther.programs.mako = {
      enable = true;

      config = with config.themes.default; {
        default = {
          font = "Ubuntu Mono 10";
          text-color = "#${foreground.text}FF";
          background-color = "#${background.primary}CC";

          border-size = 2;
          border-color = "#${foreground.active}FF";

          height = 250;
          margin = 5;
          padding = 16;
          max-icon-size = 16;
          layer = "overlay";

          default-timeout = 5000;
        };

        sections = [
          {
            conditions = { urgency = "critical"; };
            config = {
              border-color = "#${urgent}FF";
            };
          }

          {
            conditions = { mode = "idle"; };
            config = {
              ignore-timeout = 1;
              default-timeout = 0;
            };
          }
        ];
      };
    };

    services.cliphist = {
      enable = true;
      systemdTarget = "wlr-session.target";


@@ 126,6 168,7 @@ in {
      timeouts = [
        { timeout = 300; command = lib.getExe wlopmDisableScreens; resumeCommand = lib.getExe wlopmEnableScreens; }
        { timeout = 1800; command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; }
        { timeout = 5; command = "${lib.getExe' pkgs.mako "makoctl"} -a idle"; resumeCommand = "${lib.getExe' pkgs.mako "makoctl"} -r idle"; }
      ];
    };


A home/modules/profiles/desktop/dwl/mako-hm-impl.nix => home/modules/profiles/desktop/dwl/mako-hm-impl.nix +15 -0
@@ 0,0 1,15 @@
{ config, lib, ... }:

let
  cfg = config.rutherther.programs.mako;
in {
  config = lib.mkIf cfg.enable {
    home.packages = [
      cfg.package
    ];

    xdg.dataFile."dbus-1/services/${builtins.baseNameOf (builtins.unsafeDiscardStringContext
 cfg.dbusFile)}".source = cfg.dbusFile;
    xdg.configFile."mako/config".source = cfg.configFile;
  };
}

A home/modules/profiles/desktop/dwl/mako.nix => home/modules/profiles/desktop/dwl/mako.nix +84 -0
@@ 0,0 1,84 @@
{ config, lib, pkgs, ... }:

let
  cfg = config.rutherther.programs.mako;

  inherit (lib) mkOption mkEnableOption mkPackageOption;
  inherit (lib.types) str package number path attrsOf listOf oneOf submodule;

  configOptionType = oneOf [ str number ];
  configOptionsType = attrsOf configOptionType;
  mapConfigOptions = options: lib.mapAttrsToList (name: value: "${name}=${builtins.toString value}") options;
  sectionsType = submodule ({ config, ... }: {
    options = {
      conditions = mkOption {
        type = configOptionsType;
        description = "The conditions for current section.";
        example = {
          urgency = "critical";
        };
      };
      config = mkOption {
        type = configOptionsType;
        description = "Options to configure for the specified condition.";
        example = {
          border-color = "#FFFFFFFF";
        };
      };
      configText = mkOption {
        type = str;
        readOnly = true;
      };
    };

    config = {
      configText = ''[${lib.concatStringsSep " " (mapConfigOptions config.conditions)}]
${lib.concatStringsSep "\n" (mapConfigOptions config.config)}'';
    };
  });

  sectionsConfigs = lib.lists.map (section: section.configText) cfg.config.sections;
in {
  options.rutherther.programs.mako = {
    enable = mkEnableOption "Program - simple wayland notification daemon";

    package = mkPackageOption pkgs "mako" {};

    config.default = mkOption {
      type = configOptionsType;
      description = ''
        Text for the configuration file.
      '';
    };

    config.sections = mkOption {
      type = listOf sectionsType;
      description = "Sections to append to the config file. These apply only if conditions for those are satisfied.";
    };

    configFile = mkOption {
      type = package;
      readOnly = true;
      description = "Resulting file with the configuration text.";
    };

    configText = mkOption {
      type = str;
      readOnly = true;
      description = ''
        Resulting text of the configuration file.
      '';
    };

    dbusFile = mkOption {
      type = path;
      description = "D-Bus service file";
    };
  };

  config.rutherther.programs.mako = {
    configText = lib.concatStringsSep "\n" ((mapConfigOptions cfg.config.default) ++ sectionsConfigs) + "\n";
    configFile = pkgs.writeText "mako-config" cfg.configText;
    dbusFile = "${cfg.package}/share/dbus/fr.emersion.mako.service";
  };
}

Do not follow this link