aboutsummaryrefslogtreecommitdiffhomepage
path: root/nix
diff options
context:
space:
mode:
authorGabriel Fontes <[email protected]>2022-07-27 11:32:42 -0300
committerGitHub <[email protected]>2022-07-27 17:32:42 +0300
commit1d3e1472f2073b53d2906dc7b15275e8f233c265 (patch)
tree92f4aa65d1ef9d783c7422f4613fa2737242e6c6 /nix
parentb2627c05c4e92495008628f7ec47c4d0ccbe9354 (diff)
downloadHyprland-1d3e1472f2073b53d2906dc7b15275e8f233c265.tar.gz
Hyprland-1d3e1472f2073b53d2906dc7b15275e8f233c265.zip
nix: add home-manager module (#395)
Diffstat (limited to 'nix')
-rw-r--r--nix/hm-module.nix98
1 files changed, 98 insertions, 0 deletions
diff --git a/nix/hm-module.nix b/nix/hm-module.nix
new file mode 100644
index 00000000..8b2ce883
--- /dev/null
+++ b/nix/hm-module.nix
@@ -0,0 +1,98 @@
+self: {
+ config,
+ lib,
+ pkgs,
+ ...
+}: let
+ cfg = config.wayland.windowManager.hyprland;
+ defaultHyprlandPackage = self.packages.${pkgs.system}.default.override {
+ enableXWayland = cfg.xwayland;
+ };
+in {
+ options.wayland.windowManager.hyprland = {
+ enable = lib.mkEnableOption "hyprland wayland compositor";
+ package = lib.mkOption {
+ type = with lib.types; nullOr package;
+ default = defaultHyprlandPackage;
+ description = ''
+ Hyprland package to use. Will override the 'xwayland' option.
+
+ Defaults to the one provided by the flake. Set it to
+ <literal>pkgs.hyprland</literal> to use the one provided by nixpkgs or
+ if you have an overlay.
+
+ Set to null to not add any Hyprland package to your path. This should
+ be done if you want to use the NixOS module to install Hyprland.
+ '';
+ };
+ systemdIntegration = lib.mkOption {
+ type = lib.types.bool;
+ default = pkgs.stdenv.isLinux;
+ description = ''
+ Whether to enable <filename>hyprland-session.target</filename> on
+ hyprland startup. This links to <filename>graphical-session.target</filename>.
+ Some important environment variables will be imported to systemd
+ and dbus user environment before reaching the target, including
+ <itemizedlist>
+ <listitem><para><literal>DISPLAY</literal></para></listitem>
+ <listitem><para><literal>WAYLAND_DISPLAY</literal></para></listitem>
+ <listitem><para><literal>HYPRLAND_INSTANCE_SIGNATURE</literal></para></listitem>
+ <listitem><para><literal>XDG_CURRENT_DESKTOP</literal></para></listitem>
+ </itemizedlist>
+ '';
+ };
+ xwayland = lib.mkOption {
+ type = lib.types.bool;
+ default = true;
+ description = ''
+ Enable xwayland.
+ '';
+ };
+
+ extraConfig = lib.mkOption {
+ type = lib.types.lines;
+ default = "";
+ description = ''
+ Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
+ '';
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ home.packages =
+ lib.optional (cfg.package != null) cfg.package
+ ++ lib.optional cfg.xwayland pkgs.xwayland;
+
+ xdg.configFile."hypr/hyprland.conf" = {
+ text =
+ (lib.optionalString cfg.systemdIntegration "
+ exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP; systemctl --user start hyprland-session.target
+ ")
+ + cfg.extraConfig;
+
+ onChange = let
+ hyprlandPackage =
+ if cfg.package == null
+ then defaultHyprlandPackage
+ else cfg.package;
+ in "${hyprlandPackage}/bin/hyprctl reload";
+ };
+
+ systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
+ Unit = {
+ Description = "hyprland compositor session";
+ Documentation = ["man:systemd.special(7)"];
+ BindsTo = ["graphical-session.target"];
+ Wants = ["graphical-session-pre.target"];
+ After = ["graphical-session-pre.target"];
+ };
+ };
+
+ systemd.user.targets.tray = {
+ Unit = {
+ Description = "Home Manager System Tray";
+ Requires = ["graphical-session-pre.target"];
+ };
+ };
+ };
+}