diff --git a/modules/services/hyprshell.nix b/modules/services/hyprshell.nix new file mode 100644 index 000000000..b9940c1c6 --- /dev/null +++ b/modules/services/hyprshell.nix @@ -0,0 +1,96 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + types + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.services.hyprshell; + + jsonFormat = pkgs.formats.json { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.services.hyprshell = { + enable = mkEnableOption "hyprshell"; + package = mkPackageOption pkgs "hyprshell" { nullable = true; }; + + settings = mkOption { + type = jsonFormat.type; + default = { }; + description = '' + Configuration settings for hyprshell. All the avaiblable + options can be found here: + ''; + }; + + style = mkOption { + type = with types; either path lines; + default = ""; + description = '' + CSS file for customizing hyprshell. All the available + options can be found here: + ''; + }; + + systemd = { + enable = mkEnableOption "the hyprshell Systemd service" // { + default = true; + }; + + target = mkOption { + type = types.str; + default = config.wayland.systemd.target; + description = "The Systemd target that will start the hyprshell service"; + }; + + args = mkOption { + type = types.str; + default = ""; + example = "-vv"; + description = "Arguments to pass to the hyprshell service"; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.hyprshell" pkgs lib.platforms.linux) + { + assertion = if (cfg.package == null) then (if cfg.systemd.enable then false else true) else true; + message = "Can't set programs.hyprshell.systemd.enable with the package set to null."; + } + ]; + + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."hyprshell/config.json" = mkIf (cfg.settings != { }) { + source = jsonFormat.generate "hyprshell-config" cfg.settings; + }; + + xdg.configFile."hyprshell/style.css" = mkIf (cfg.style != "") { + source = if lib.isString cfg.style then pkgs.writeText "hyprshell-style" cfg.style else cfg.style; + }; + + systemd.user.services.hyprshell = mkIf (cfg.systemd.enable && (cfg.package != null)) { + Unit = { + Description = "Starts Hyprshell daemon"; + After = [ cfg.systemd.target ]; + }; + Service = { + Type = "simple"; + ExecStart = "${lib.getExe cfg.package} run ${cfg.systemd.args}"; + Restart = "on-failure"; + }; + Install.WantedBy = [ cfg.systemd.target ]; + }; + }; +} diff --git a/tests/modules/services/hyprshell/config.json b/tests/modules/services/hyprshell/config.json new file mode 100644 index 000000000..51a13a438 --- /dev/null +++ b/tests/modules/services/hyprshell/config.json @@ -0,0 +1,9 @@ +{ + "kill_bind": "ctrl+shift+alt, h", + "layerrules": true, + "version": 1, + "windows": { + "items_per_row": 5, + "scale": 8.5 + } +} diff --git a/tests/modules/services/hyprshell/default.nix b/tests/modules/services/hyprshell/default.nix new file mode 100644 index 000000000..85bb7484a --- /dev/null +++ b/tests/modules/services/hyprshell/default.nix @@ -0,0 +1,5 @@ +{ lib, pkgs, ... }: + +lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + hyprshell-example = ./example-config.nix; +} diff --git a/tests/modules/services/hyprshell/example-config.nix b/tests/modules/services/hyprshell/example-config.nix new file mode 100644 index 000000000..b0b34876e --- /dev/null +++ b/tests/modules/services/hyprshell/example-config.nix @@ -0,0 +1,26 @@ +{ + services.hyprshell = { + enable = true; + settings = { + layerrules = true; + kill_bind = "ctrl+shift+alt, h"; + version = 1; + windows = { + scale = 8.5; + items_per_row = 5; + }; + }; + style = ./style.css; + }; + + nmt.script = '' + assertFileExists home-files/.config/hyprshell/config.json + assertFileExists home-files/.config/hyprshell/style.css + + assertFileContent home-files/.config/hyprshell/config.json \ + ${./config.json} + + assertFileContent home-files/.config/hyprshell/style.css \ + ${./style.css} + ''; +} diff --git a/tests/modules/services/hyprshell/style.css b/tests/modules/services/hyprshell/style.css new file mode 100644 index 000000000..eeba22a9e --- /dev/null +++ b/tests/modules/services/hyprshell/style.css @@ -0,0 +1,57 @@ +:root { + --border-color: rgba(90, 90, 120, 0.4); + --border-color-active: rgba(239, 9, 9, 0.9); + + --bg-color: rgba(20, 20, 20, 0.9); + --bg-color-hover: rgba(40, 40, 50, 1); + + --border-radius: 12px; + --border-size: 3px; + --border-style: solid; + --border-style-secondary: dashed; + + --text-color: rgba(245, 245, 245, 1); + + --window-padding: 2px; +} + +.window { +} + + +.monitor { +} + +.workspace { +} + +.client { +} + +.client-image { +} + + +.launcher { +} + +.launcher-input { +} + +.launcher-results { +} + +.launcher-item { +} + +.launcher-exec { +} + +.launcher-key { +} + +.launcher-plugins { +} + +.launcher-plugin { +} \ No newline at end of file