summary refs log tree commit diff
diff options
context:
space:
mode:
authorTom Fitzhenry <tom@tom-fitzhenry.me.uk>2022-01-08 12:46:23 +1100
committerTom Fitzhenry <tom@tom-fitzhenry.me.uk>2022-05-06 00:04:48 +1000
commit1d7cd163ce0830086932a138fcc6a8e1c86ec46d (patch)
tree0718b2bbe5eabc1e6e8f15f9448ebd029e7ef51f
parent76b29a450007df2912e8190be178ae6b5d220731 (diff)
downloadnixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar.gz
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar.bz2
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar.lz
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar.xz
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.tar.zst
nixpkgs-1d7cd163ce0830086932a138fcc6a8e1c86ec46d.zip
nixos/phosh: add Phosh, the Phone Shell
-rw-r--r--nixos/modules/services/x11/desktop-managers/default.nix2
-rw-r--r--nixos/modules/services/x11/desktop-managers/phosh.nix73
2 files changed, 74 insertions, 1 deletions
diff --git a/nixos/modules/services/x11/desktop-managers/default.nix b/nixos/modules/services/x11/desktop-managers/default.nix
index 8247a7e381c..f48eac21bd8 100644
--- a/nixos/modules/services/x11/desktop-managers/default.nix
+++ b/nixos/modules/services/x11/desktop-managers/default.nix
@@ -18,7 +18,7 @@ in
   # determines the default: later modules (if enabled) are preferred.
   # E.g., if Plasma 5 is enabled, it supersedes xterm.
   imports = [
-    ./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix
+    ./none.nix ./xterm.nix ./phosh.nix ./xfce.nix ./plasma5.nix ./lumina.nix
     ./lxqt.nix ./enlightenment.nix ./gnome.nix ./retroarch.nix ./kodi.nix
     ./mate.nix ./pantheon.nix ./surf-display.nix ./cde.nix
     ./cinnamon.nix
diff --git a/nixos/modules/services/x11/desktop-managers/phosh.nix b/nixos/modules/services/x11/desktop-managers/phosh.nix
new file mode 100644
index 00000000000..e768f6f4c63
--- /dev/null
+++ b/nixos/modules/services/x11/desktop-managers/phosh.nix
@@ -0,0 +1,73 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.xserver.desktopManager.phosh;
+in
+
+{
+  options = {
+    services.xserver.desktopManager.phosh = {
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Enable the Phone Shell.";
+      };
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.phosh;
+        defaultText = literalExpression "pkgs.phosh";
+        example = literalExpression "pkgs.phosh";
+        description = ''
+          Package that should be used for Phosh.
+        '';
+      };
+
+      user = mkOption {
+        description = "The user to run the Phosh service.";
+        type = types.str;
+        example = "alice";
+      };
+
+      group = mkOption {
+        description = "The group to run the Phosh service.";
+        type = types.str;
+        example = "users";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    programs.phosh.enable = true;
+
+    systemd.defaultUnit = "graphical.target";
+    # Inspired by https://gitlab.gnome.org/World/Phosh/phosh/-/blob/main/data/phosh.service
+    systemd.services.phosh = {
+      wantedBy = [ "graphical.target" ];
+      serviceConfig = {
+        ExecStart = "${cfg.package}/bin/phosh";
+        User = cfg.user;
+        Group = cfg.group;
+        PAMName = "login";
+        WorkingDirectory = "~";
+        Restart = "always";
+
+        TTYPath = "/dev/tty7";
+        TTYReset = "yes";
+        TTYVHangup = "yes";
+        TTYVTDisallocate = "yes";
+
+        # Fail to start if not controlling the tty.
+        StandardInput = "tty-fail";
+        StandardOutput = "journal";
+        StandardError = "journal";
+
+        # Log this user with utmp, letting it show up with commands 'w' and 'who'.
+        UtmpIdentifier = "tty7";
+        UtmpMode = "user";
+      };
+    };
+  };
+}