Skip to content

Commit

Permalink
nixos/uwsm: init module, temporarily import the package derivation here
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor committed Jul 26, 2024
1 parent a81caa3 commit 642754a
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules-overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
}: {
imports = [
#./amdgpu.nix # import modules here to test
./uwsm/uwsm-module.nix
];

nixpkgs.overlays = [
(final: prev: {
# 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;
}
71 changes: 71 additions & 0 deletions modules-overlays/uwsm/package.nix
Original file line number Diff line number Diff line change
@@ -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;
};
})
49 changes: 49 additions & 0 deletions modules-overlays/uwsm/uwsm-module.nix
Original file line number Diff line number Diff line change
@@ -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 ];
}
29 changes: 29 additions & 0 deletions modules-overlays/uwsm/uwsm-wm-wrapper.nix
Original file line number Diff line number Diff line change
@@ -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"];
}

0 comments on commit 642754a

Please sign in to comment.