From 63093d8a870b01e566aeed1bd882c2dfaeb55406 Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Sun, 23 Feb 2025 14:51:56 +0100 Subject: [PATCH] Progress on desktop system, added integration with nixgreety --- user-modules/desktop/custom/bar/waybar.nix | 1 + user-modules/desktop/custom/default.nix | 24 ++-- .../desktop/custom/window-manager/i3.nix | 2 +- .../desktop/custom/window-manager/river.nix | 8 +- user-modules/desktop/default.nix | 118 +++++++++++++++++- user-modules/desktop/systemwide.nix | 1 - 6 files changed, 134 insertions(+), 20 deletions(-) diff --git a/user-modules/desktop/custom/bar/waybar.nix b/user-modules/desktop/custom/bar/waybar.nix index 92406c7..7693393 100644 --- a/user-modules/desktop/custom/bar/waybar.nix +++ b/user-modules/desktop/custom/bar/waybar.nix @@ -32,6 +32,7 @@ in programs.waybar = { enable = true; + systemd.enable = false; settings = { mainBar = { layer = "top"; diff --git a/user-modules/desktop/custom/default.nix b/user-modules/desktop/custom/default.nix index ac475db..2d465be 100644 --- a/user-modules/desktop/custom/default.nix +++ b/user-modules/desktop/custom/default.nix @@ -20,12 +20,6 @@ in options.modules.desktop = { wayland = mkEnableOption "wayland"; - # TODO: Remove, not needed with session/display manager - initScript = mkOption { - type = types.lines; - default = "${pkgs.bash}/bin/bash"; - description = "Bash script to execute after logging in."; - }; # TODO: Find a nicer way to do this as this is also executed on startup reloadScript = mkOption { type = types.lines; @@ -69,16 +63,16 @@ in ); }; - home.file.".initrc" = { - enable = true; - executable = true; - text = - '' - #!${pkgs.bash}/bin/bash + # home.file.".initrc" = { + # enable = true; + # executable = true; + # text = + # '' + # #!${pkgs.bash}/bin/bash - '' - + cfg.initScript; - }; + # '' + # + cfg.initScript; + # }; } ( # TODO: Move to dedicated module within desktop or maybe theming? diff --git a/user-modules/desktop/custom/window-manager/i3.nix b/user-modules/desktop/custom/window-manager/i3.nix index 6d5903f..c599caf 100644 --- a/user-modules/desktop/custom/window-manager/i3.nix +++ b/user-modules/desktop/custom/window-manager/i3.nix @@ -16,7 +16,7 @@ in # modules.desktop.x11 = true; modules.rofi.enable = true; - modules.desktop.initScript = '' + desktop.initScript = '' i3 ''; diff --git a/user-modules/desktop/custom/window-manager/river.nix b/user-modules/desktop/custom/window-manager/river.nix index c2fe126..b8c6741 100644 --- a/user-modules/desktop/custom/window-manager/river.nix +++ b/user-modules/desktop/custom/window-manager/river.nix @@ -32,10 +32,13 @@ in ]; # Change desktop to execute river - modules.desktop.initScript = '' - river + desktop.initScript = '' + ${pkgs.dbus}/bin/dbus-run-session ${pkgs.river}/bin/river ''; + desktop.session.type = "wayland"; + desktop.session.desktop = "river"; + # TODO: Fix this # modules.desktop.reloadScript = '' # ${pkgs.river}/bin/riverctl background-color 0x${config.theming.colors.bg} @@ -62,6 +65,7 @@ in wayland.windowManager.river = { enable = true; xwayland.enable = false; + systemd.enable = false; settings = let layout = "filtile"; diff --git a/user-modules/desktop/default.nix b/user-modules/desktop/default.nix index 082a006..f9b7ae6 100644 --- a/user-modules/desktop/default.nix +++ b/user-modules/desktop/default.nix @@ -1,8 +1,124 @@ -{ ... }: +{ + lib, + config, + pkgs, + ... +}: +with lib; +let + # Desktop configuration module + desktopConfigurationModule = types.submodule { + options = { + name = mkOption { + type = types.str; + description = "Desktop environment name."; + }; + type = mkOption { + type = types.enum [ + "custom" + "gnome" + ]; + description = "Desktop environment type."; + }; + config = mkOption { + type = types.attrs; + default = { }; + description = "Desktop environment configuration"; + }; + extraConfig = mkOption { + type = types.attrs; + default = { }; + description = "Extra configuration for the configured desktop environment"; + }; + }; + }; + + customBuilder = config: { + configuration = recursiveUpdate { desktop.name = config.name; } config.extraConfig; + }; + + # Environment builders + environmentBuilders = { + custom = customBuilder; + }; + + cfg = config.desktop; +in { imports = [ ./custom/default.nix ./theming/default.nix ]; + + options.desktop = { + name = mkOption { + type = types.str; + default = "Shell"; + description = "Desktop configuration name."; + }; + initScript = mkOption { + type = types.lines; + default = '' + ${pkgs.ncurses}/bin/clear + ${pkgs.bashInteractive}/bin/bash + ''; + description = "Bash script to execute after logging in."; + }; + session = { + type = mkOption { + type = types.enum [ + "wayland" + "x11" + "tty" + ]; + default = "tty"; + description = "Session type."; + }; + desktop = mkOption { + type = types.str; + default = "tty"; + description = "Desktop environment name."; + }; + }; + environments = mkOption { + type = types.attrsOf desktopConfigurationModule; + default = { }; + description = "Desktop environments. Every environment will be built as a specialization."; + }; + }; + + config = { + specialisation = mapAttrs ( + name: value: (environmentBuilders."${value.type}" value) + ) cfg.environments; + + # Create session files + home.extraBuilderCommands = '' + mkdir $out/session + echo "${cfg.name}" > $out/session/name + ln -s ${ + pkgs.writeTextFile { + name = "desktop-init"; + text = + '' + #!${pkgs.bash}/bin/bash + + '' + + cfg.initScript; + executable = true; + } + } $out/session/init + ln -s ${ + pkgs.writeTextFile { + name = "session-env"; + text = '' + XDG_SESSION_TYPE=${cfg.session.type} + XDG_CURRENT_DESKTOP=${cfg.session.desktop} + XDG_SESSION_DESKTOP=${cfg.session.desktop} + ''; + } + } $out/session/env + ''; + }; } diff --git a/user-modules/desktop/systemwide.nix b/user-modules/desktop/systemwide.nix index 5e274e6..a8193ac 100644 --- a/user-modules/desktop/systemwide.nix +++ b/user-modules/desktop/systemwide.nix @@ -10,7 +10,6 @@ layout = "us"; xkbVariant = ""; enable = true; - windowManager.i3.enable = true; desktopManager = { xterm.enable = true; xfce = {