Unverified Commit 6abfe96f authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

nixos/dwm-status: use structured RFC42 style settings (#416212)

parents 109b17dc daf30d2f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@

- The `services.siproxd` module has been removed as `siproxd` is unmaintained and broken with libosip 5.x.

- `services.dwm-status.extraConfig` was replaced by [RFC0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md)-compliant [](#opt-services.dwm-status.settings), which is used to generate the config file. `services.dwm-status.order` is now moved to [](#opt-services.dwm-status.settings.order), as it's a part of the config file.

- `renovate` was updated to v40. See the [upstream release notes](https://github.com/renovatebot/renovate/releases/tag/40.0.0) for breaking changes.

- The Postfix module has been updated and likely requires configuration changes:
+45 −36
Original line number Diff line number Diff line
@@ -7,30 +7,36 @@
let
  cfg = config.services.dwm-status;

  order = lib.concatMapStringsSep "," (feature: ''"${feature}"'') cfg.order;
  format = pkgs.formats.toml { };

  configFile = pkgs.writeText "dwm-status.toml" ''
    order = [${order}]

    ${cfg.extraConfig}
  '';
  configFile = format.generate "dwm-status.toml" cfg.settings;
in

{

  ###### interface
  imports = [
    (lib.mkRenamedOptionModule
      [ "services" "dwm-status" "order" ]
      [ "services" "dwm-status" "settings" "order" ]
    )
    (lib.mkRemovedOptionModule [
      "services"
      "dwm-status"
      "extraConfig"
    ] "Use services.dwm-status.settings instead.")
  ];

  options = {

    services.dwm-status = {

      enable = lib.mkEnableOption "dwm-status user service";

      package = lib.mkPackageOption pkgs "dwm-status" {
        example = "dwm-status.override { enableAlsaUtils = false; }";
      };

      order = lib.mkOption {
      settings = lib.mkOption {
        type = lib.types.submodule {
          freeformType = format.type;
          options.order = lib.mkOption {
            type = lib.types.listOf (
              lib.types.enum [
                "audio"
@@ -41,37 +47,40 @@ in
                "time"
              ]
            );
            default = [ ];
            description = ''
              List of enabled features in order.
            '';
          };

      extraConfig = lib.mkOption {
        type = lib.types.lines;
        default = "";
        };
        default = { };
        example = {
          order = [
            "battery"
            "cpu_load"
            "time"
          ];
          time = {
            format = "%F %a %r";
            update_seconds = true;
          };
        };
        description = ''
          Extra config in TOML format.
          Config options for dwm-status, see https://github.com/Gerschtli/dwm-status#configuration
          for available options.
        '';
      };

    };

  };

  ###### implementation

  config = lib.mkIf cfg.enable {

    services.upower.enable = lib.mkIf (lib.elem "battery" cfg.order) true;
    services.upower.enable = lib.mkIf (lib.elem "battery" cfg.settings.order) true;

    systemd.user.services.dwm-status = {
      description = "Highly performant and configurable DWM status service";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];

      serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile} --quiet";
    };

  };

}