oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

add desktop entry to package and cleanup nix module

Commit
3fbd72efab235342e6ed27ff8c6e1b085ffc9b8e
Parent
6ed620e
Author
emzywastaken <amiamemetoo@gmail.com>
Date
2025-10-11 00:30:03

Diff

diff --git a/default.nix b/default.nix
index a57726b..3aabb1f 100644
--- a/default.nix
+++ b/default.nix
@@ -1,12 +1,13 @@
-{ lib
-, rustPlatform
-, pkg-config
-, xorg
-, freetype
-, fontconfig
+{
+  lib,
+  rustPlatform,
+  pkg-config,
+  xorg,
+  freetype,
+  fontconfig,
+  makeDesktopItem,
 }:
-
-rustPlatform.buildRustPackage {
+rustPlatform.buildRustPackage (finalAttrs: {
   pname = "oxwm";
   version = "0.1.0";
 
@@ -28,12 +29,24 @@ rustPlatform.buildRustPackage {
     fontconfig
   ];
 
+  postInstall = let
+    oxwmDesktopItem = makeDesktopItem rec {
+      name = finalAttrs.pname;
+      exec = name;
+      desktopName = name;
+      comment = finalAttrs.meta.description;
+    };
+  in ''
+    install -Dt $out/share/xsessions ${oxwmDesktopItem}/share/applications/oxwm.desktop
+  '';
+
+  passthru.providedSessions = ["oxwm"];
+
   meta = with lib; {
     description = "A dynamic window manager written in Rust, inspired by dwm";
     homepage = "https://github.com/tonybanters/oxwm";
     license = licenses.gpl3;
-    maintainers = [ ];
     platforms = platforms.linux;
     mainProgram = "oxwm";
   };
-}
+})
diff --git a/flake.nix b/flake.nix
index b337c2f..97049c9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -46,21 +46,7 @@
       ...
     }: let
       inherit (lib) mkEnableOption mkOption mkIf types;
-
       cfg = config.services.xserver.windowManager.oxwm;
-      oxwmDesktopItem = pkgs.writeTextFile {
-        name = "oxwm.desktop";
-        destination = "/share/xsessions/oxwm.desktop";
-        text = ''
-          [Desktop Entry]
-          Name=OXWM
-          Comment=A dynamic window manager written in Rust
-          Exec=${cfg.package}/bin/oxwm
-          Type=Application
-          DesktopNames=OXWM
-        '';
-        passthru.providedSessions = ["oxwm"];
-      };
     in {
       options.services.xserver.windowManager.oxwm = {
         enable = mkEnableOption "oxwm window manager";
@@ -72,27 +58,10 @@
       };
 
       config = mkIf cfg.enable {
-        services.xserver.windowManager.session = [
-          {
-            name = "oxwm";
-            start = ''
-              ${cfg.package}/bin/oxwm &
-              waitPID=$!
-            '';
-          }
-        ];
-        services.displayManager.sessionPackages = [oxwmDesktopItem];
+        services.displayManager.sessionPackages = [cfg.package];
 
         environment.systemPackages = [
           cfg.package
-          pkgs.rustc
-          pkgs.cargo
-          pkgs.pkg-config
-          pkgs.xorg.libX11
-          pkgs.xorg.libXft
-          pkgs.xorg.libXrender
-          pkgs.freetype
-          pkgs.fontconfig
         ];
       };
     };