aboutsummaryrefslogtreecommitdiffhomepage
path: root/nix
diff options
context:
space:
mode:
authorMihai Fufezan <[email protected]>2023-12-14 20:02:20 +0200
committerGitHub <[email protected]>2023-12-14 20:02:20 +0200
commitf7cde9c92cb9e7c908f18ecf10ebdb366d0832b5 (patch)
tree7bdc70263a081ea10b0c7a853a208f69cb789ebb /nix
parent01e5c59d752d3fe7fa484330fa48e010054b8fa1 (diff)
downloadHyprland-f7cde9c92cb9e7c908f18ecf10ebdb366d0832b5.tar.gz
Hyprland-f7cde9c92cb9e7c908f18ecf10ebdb366d0832b5.zip
Nix: remove duplicate options from modules (#4012)
Diffstat (limited to 'nix')
-rw-r--r--nix/hm-module.nix170
-rw-r--r--nix/module.nix92
2 files changed, 13 insertions, 249 deletions
diff --git a/nix/hm-module.nix b/nix/hm-module.nix
index 9b065e6f..e3c788d0 100644
--- a/nix/hm-module.nix
+++ b/nix/hm-module.nix
@@ -4,171 +4,11 @@ self: {
pkgs,
...
}: let
- cfg = config.wayland.windowManager.hyprland;
- defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
- enableXWayland = cfg.xwayland.enable;
- };
-in {
- disabledModules = ["services/window-managers/hyprland.nix"];
-
- meta.maintainers = [lib.maintainers.fufexan];
-
- options.wayland.windowManager.hyprland = {
- enable =
- lib.mkEnableOption null
- // {
- description = lib.mdDoc ''
- Whether to enable Hyprland, the dynamic tiling Wayland compositor
- that doesn't sacrifice on its looks.
-
- You can manually launch Hyprland by executing {command}`Hyprland` on
- a TTY.
-
- See <https://wiki.hyprland.org> for more information.
- '';
- };
-
- package = lib.mkOption {
- type = with lib.types; nullOr package;
- default = defaultHyprlandPackage;
- defaultText = lib.literalExpression ''
- hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
- enableXWayland = config.wayland.windowManager.hyprland.xwayland.enable;
- }
- '';
- description = lib.mdDoc ''
- Hyprland package to use. Will override the 'xwayland' option.
-
- Defaults to the one provided by the flake. Set it to
- {package}`pkgs.hyprland` 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.
- '';
- };
-
- plugins = lib.mkOption {
- type = with lib.types; listOf (either package path);
- default = [];
- description = lib.mdDoc ''
- List of Hyprland plugins to use. Can either be packages or
- absolute plugin paths.
- '';
- };
-
- systemdIntegration = lib.mkOption {
- type = lib.types.bool;
- default = pkgs.stdenv.isLinux;
- description = lib.mdDoc ''
- Whether to enable {file}`hyprland-session.target` on
- Hyprland startup. This links to {file}`graphical-session.target`.
- Some important environment variables will be imported to systemd
- and dbus user environment before reaching the target, including
- - {env}`DISPLAY`
- - {env}`HYPRLAND_INSTANCE_SIGNATURE`
- - {env}`WAYLAND_DISPLAY`
- - {env}`XDG_CURRENT_DESKTOP`
- '';
- };
-
- disableAutoreload =
- lib.mkEnableOption null
- // {
- description = lib.mdDoc ''
- Whether to disable automatically reloading Hyprland's configuration when
- rebuilding the Home Manager profile.
- '';
- };
+ inherit (pkgs.stdenv.hostPlatform) system;
- xwayland.enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
-
- extraConfig = lib.mkOption {
- type = lib.types.nullOr lib.types.lines;
- default = "";
- description = lib.mdDoc ''
- Extra configuration lines to add to {file}`~/.config/hypr/hyprland.conf`.
- '';
- };
-
- recommendedEnvironment =
- lib.mkEnableOption null
- // {
- description = lib.mdDoc ''
- Whether to set the recommended environment variables.
- '';
- };
- };
-
- config = lib.mkIf cfg.enable {
- warnings =
- if (cfg.systemdIntegration || cfg.plugins != []) && cfg.extraConfig == null
- then [
- ''
- You have enabled hyprland.systemdIntegration or listed plugins in hyprland.plugins.
- Your Hyprland config will be linked by home manager.
- Set hyprland.extraConfig or unset hyprland.systemdIntegration and hyprland.plugins to remove this warning.
- ''
- ]
- else [];
-
- home.packages =
- lib.optional (cfg.package != null) cfg.package
- ++ lib.optional cfg.xwayland.enable pkgs.xwayland;
-
- home.sessionVariables =
- lib.mkIf cfg.recommendedEnvironment {NIXOS_OZONE_WL = "1";};
-
- xdg.configFile."hypr/hyprland.conf" = lib.mkIf (cfg.systemdIntegration || cfg.extraConfig != null || cfg.plugins != []) {
- 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
- '')
- + lib.concatStrings (builtins.map (entry: let
- plugin =
- if lib.types.package.check entry
- then "${entry}/lib/lib${entry.pname}.so"
- else entry;
- in "plugin = ${plugin}\n")
- cfg.plugins)
- + (
- if cfg.extraConfig != null
- then cfg.extraConfig
- else ""
- );
-
- onChange = let
- hyprlandPackage =
- if cfg.package == null
- then defaultHyprlandPackage
- else cfg.package;
- in
- lib.mkIf (!cfg.disableAutoreload) ''
- ( # execute in subshell so that `shopt` won't affect other scripts
- shopt -s nullglob # so that nothing is done if /tmp/hypr/ does not exist or is empty
- for instance in /tmp/hypr/*; do
- HYPRLAND_INSTANCE_SIGNATURE=''${instance##*/} ${hyprlandPackage}/bin/hyprctl reload config-only \
- || true # ignore dead instance(s)
- done
- )
- '';
- };
-
- 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"];
- };
- };
+ package = self.packages.${system}.default;
+in {
+ config = {
+ wayland.windowManager.hyprland.package = lib.mkDefault package;
};
-
- imports = [
- (lib.mkRemovedOptionModule ["wayland" "windowManager" "hyprland" "xwayland" "hidpi"]
- "Support for this option has been removed. Refer to https://wiki.hyprland.org/Configuring/XWayland for more info")
- (lib.mkRemovedOptionModule ["wayland" "windowManager" "hyprland" "xwayland" "enableNvidiaPatches"]
- "Nvidia patches are no longer needed for Hyprland")
- ];
}
diff --git a/nix/module.nix b/nix/module.nix
index 1f1d2585..6f553893 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -2,96 +2,20 @@ inputs: {
config,
lib,
pkgs,
- options,
...
-}:
-with lib; let
- cfg = config.programs.hyprland;
+}: let
inherit (pkgs.stdenv.hostPlatform) system;
+ cfg = config.programs.hyprland;
- finalPortalPackage = cfg.portalPackage.override {
+ package = inputs.self.packages.${system}.hyprland;
+ portalPackage = inputs.self.packages.${system}.xdg-desktop-portal-hyprland.override {
hyprland = cfg.finalPackage;
};
in {
- # disables Nixpkgs Hyprland module to avoid conflicts
- disabledModules = ["programs/hyprland.nix"];
-
- options.programs.hyprland = {
- enable =
- mkEnableOption null
- // {
- description = mdDoc ''
- Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
-
- You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
-
- A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
- See <https://wiki.hyprland.org> for more information.
- '';
- };
-
- package = mkPackageOptionMD inputs.self.packages.${system} "hyprland" { };
-
- finalPackage = mkOption {
- type = types.package;
- readOnly = true;
- default = cfg.package.override {
- enableXWayland = cfg.xwayland.enable;
- };
- defaultText =
- literalExpression
- "`programs.hyprland.package` with applied configuration";
- description = mdDoc ''
- The Hyprland package after applying configuration.
- '';
- };
-
- portalPackage = mkPackageOptionMD inputs.xdph.packages.${system} "xdg-desktop-portal-hyprland" {};
-
- xwayland.enable = mkEnableOption (mdDoc "support for XWayland") // {default = true;};
- };
-
- config = mkIf cfg.enable {
- environment.systemPackages = [cfg.finalPackage];
-
- # NixOS changed the name of this attribute between NixOS 23.05 and
- # 23.11
- fonts = if builtins.hasAttr "enableDefaultPackages" options.fonts
- then {enableDefaultPackages = mkDefault true;}
- else {enableDefaultFonts = mkDefault true;};
-
- hardware.opengl.enable = mkDefault true;
-
- programs = {
- dconf.enable = mkDefault true;
- xwayland.enable = mkDefault cfg.xwayland.enable;
- };
-
- security.polkit.enable = true;
-
- services.xserver.displayManager.sessionPackages = [cfg.finalPackage];
-
- xdg.portal = {
- enable = mkDefault true;
- extraPortals = [finalPortalPackage];
+ config = {
+ programs.hyprland = {
+ package = lib.mkDefault package;
+ portalPackage = lib.mkDefault portalPackage;
};
};
-
- imports = with lib; [
- (
- mkRemovedOptionModule
- ["programs" "hyprland" "xwayland" "hidpi"]
- "XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
- )
- (
- mkRemovedOptionModule
- ["programs" "hyprland" "enableNvidiaPatches"]
- "Nvidia patches are no longer needed"
- )
- (
- mkRemovedOptionModule
- ["programs" "hyprland" "nvidiaPatches"]
- "Nvidia patches are no longer needed"
- )
- ];
}