From 642754a8c50a27e8c2ce2483606fad422b4c560d Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:48:10 +0530 Subject: [PATCH] nixos/uwsm: init module, temporarily import the package derivation here --- modules-overlays/default.nix | 5 ++ modules-overlays/uwsm/package.nix | 71 +++++++++++++++++++++++ modules-overlays/uwsm/uwsm-module.nix | 49 ++++++++++++++++ modules-overlays/uwsm/uwsm-wm-wrapper.nix | 29 +++++++++ 4 files changed, 154 insertions(+) create mode 100644 modules-overlays/uwsm/package.nix create mode 100644 modules-overlays/uwsm/uwsm-module.nix create mode 100644 modules-overlays/uwsm/uwsm-wm-wrapper.nix diff --git a/modules-overlays/default.nix b/modules-overlays/default.nix index 378c32d0..a47801e4 100644 --- a/modules-overlays/default.nix +++ b/modules-overlays/default.nix @@ -7,6 +7,7 @@ }: { imports = [ #./amdgpu.nix # import modules here to test + ./uwsm/uwsm-module.nix ]; nixpkgs.overlays = [ @@ -14,4 +15,8 @@ # bcachefs-tools = inputs.bcachefs-tools.packages.${pkgs.system}.bcachefs-tools; }) ]; + + programs.uwsm.enable = true; + programs.uwsm.package = pkgs.callPackage ./uwsm/package.nix {}; + programs.uwsm.withHyprland = true; } diff --git a/modules-overlays/uwsm/package.nix b/modules-overlays/uwsm/package.nix new file mode 100644 index 00000000..9a695aab --- /dev/null +++ b/modules-overlays/uwsm/package.nix @@ -0,0 +1,71 @@ +{ + stdenv, + lib, + fetchFromGitHub, + meson, + ninja, + scdoc, + pkg-config, + nix-update-script, + dmenu, + libnotify, + python3Packages, + util-linux, + fumonSupport ? true, + uuctlSupport ? true, + uwsmAppSupport ? true, +}: +let + python = python3Packages.python.withPackages (ps: [ + ps.pydbus + ps.dbus-python + ps.pyxdg + ]); +in +stdenv.mkDerivation (finalAttrs: { + pname = "uwsm"; + version = "0.17.0"; + + src = fetchFromGitHub { + owner = "Vladimir-csp"; + repo = "uwsm"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-M2j7l5XTSS2IzaJofAHct1tuAO2A9Ps9mCgAWKEvzoE="; + }; + + nativeBuildInputs = [ + meson + ninja + pkg-config + scdoc + ]; + + buildInputs = [ + libnotify + util-linux + ] ++ (lib.optionals uuctlSupport [ dmenu ]); + + propagatedBuildInputs = [ python ]; + + mesonFlags = [ + "--prefix=${placeholder "out"}" + (lib.mapAttrsToList lib.mesonEnable { + "uwsm-app" = uwsmAppSupport; + "fumon" = fumonSupport; + "uuctl" = uuctlSupport; + "man-pages" = true; + }) + ]; + + passthru = { + updateScript = nix-update-script { }; + }; + + meta = { + description = "Universal wayland session manager"; + homepage = "https://github.com/Vladimir-csp/uwsm"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ johnrtitor ]; + platforms = lib.platforms.linux; + }; +}) \ No newline at end of file diff --git a/modules-overlays/uwsm/uwsm-module.nix b/modules-overlays/uwsm/uwsm-module.nix new file mode 100644 index 00000000..37fca5b7 --- /dev/null +++ b/modules-overlays/uwsm/uwsm-module.nix @@ -0,0 +1,49 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.uwsm; + hyprlandCfg = config.programs.hyprland; + swayCfg = config.programs.sway; +in +{ + options = { + programs.uwsm = { + enable = lib.mkEnableOption ''uwsm, which wraps standalone + Wayland compositors into a set of Systemd units on the fly + ''; + package = lib.mkPackageOption pkgs "uwsm" {}; + withHyprland = lib.mkEnableOption null // { + default = cfg.enable && hyprlandCfg.enable; + }; + withSway = lib.mkEnableOption null // { + default = cfg.enable && swayCfg.enable; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + systemd.packages = [ cfg.package ]; + services.dbus.implementation = "broker"; + + services.displayManager.sessionPackages = lib.optionals cfg.withHyprland [ + (pkgs.callPackage ./uwsm-wm-wrapper.nix { + uwsm = cfg.package; + wmName = "Hyprland"; + wmCmd = "hyprland"; + }) + ] ++ lib.optionals cfg.withSway [ + (pkgs.callPackage ./uwsm-wm-wrapper.nix { + uwsm = cfg.package; + wmName = "Sway"; + wmCmd = "sway"; + }) + ]; + }; + + meta.maintainers = with lib.maintainers; [ johnrtitor ]; +} \ No newline at end of file diff --git a/modules-overlays/uwsm/uwsm-wm-wrapper.nix b/modules-overlays/uwsm/uwsm-wm-wrapper.nix new file mode 100644 index 00000000..3f2730f9 --- /dev/null +++ b/modules-overlays/uwsm/uwsm-wm-wrapper.nix @@ -0,0 +1,29 @@ +{ + lib, + stdenvNoCC, + writeText, + uwsm, + wmName ? "Example", + wmCmd ? "example", +}: +let +wm-desktop-entry = writeText "${wmName}_uwsm.desktop" '' + [Desktop Entry] + Name=${wmName} (with UWSM) + Comment=${wmName} compositor managed by UWSM + Exec=${lib.getExe uwsm} start -S -- ${wmCmd} + Type=Application +''; +in stdenvNoCC.mkDerivation { + pname = "${wmName}_uwsm"; + version = "1.0.0"; + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + mkdir -p $out/share/wayland-sessions + cp ${wm-desktop-entry} $out/share/wayland-sessions/${wmName}_uwsm.desktop + runHook postInstall + ''; + passthru.providedSessions = ["${wmName}_uwsm"]; +} \ No newline at end of file