summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-11-18 11:45:25 +0000
committerAlyssa Ross <hi@alyssa.is>2022-03-22 21:17:52 +0000
commit1335d2450f16d5b3edc6dc764d152525ca13cd90 (patch)
treea33d5cdb6b0ee43bf5e7ff8e9d7d11b554b0d666
parente36854ec3c026b614d4bce8e45bccf076e814ec7 (diff)
downloadnixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar.gz
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar.bz2
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar.lz
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar.xz
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.tar.zst
nixpkgs-1335d2450f16d5b3edc6dc764d152525ca13cd90.zip
WIP
-rw-r--r--nixos/modules/services/wayland/cage.nix3
-rw-r--r--pkgs/applications/terminal-emulators/foot/Add-support-for-opening-an-existing-PTY.patch211
-rw-r--r--pkgs/applications/terminal-emulators/foot/default.nix4
-rw-r--r--pkgs/applications/window-managers/weston/default.nix13
-rw-r--r--pkgs/development/libraries/mesa/default.nix9
-rw-r--r--pkgs/os-specific/linux/libsepol/default.nix4
-rw-r--r--pkgs/tools/misc/colord/default.nix2
7 files changed, 238 insertions, 8 deletions
diff --git a/nixos/modules/services/wayland/cage.nix b/nixos/modules/services/wayland/cage.nix
index a32b81a916f..15b4e7163f9 100644
--- a/nixos/modules/services/wayland/cage.nix
+++ b/nixos/modules/services/wayland/cage.nix
@@ -24,7 +24,7 @@ in {
   };
 
   options.services.cage.program = mkOption {
-    type = types.path;
+    type = types.str;
     default = "${pkgs.xterm}/bin/xterm";
     defaultText = literalExpression ''"''${pkgs.xterm}/bin/xterm"'';
     description = ''
@@ -50,6 +50,7 @@ in {
       wants = [ "dbus.socket" "systemd-logind.service" "plymouth-quit.service"];
       wantedBy = [ "graphical.target" ];
       conflicts = [ "getty@tty1.service" ];
+      environment = { "LIBSEAT_BACKEND" = "logind"; };
 
       restartIfChanged = false;
       unitConfig.ConditionPathExists = "/dev/tty1";
diff --git a/pkgs/applications/terminal-emulators/foot/Add-support-for-opening-an-existing-PTY.patch b/pkgs/applications/terminal-emulators/foot/Add-support-for-opening-an-existing-PTY.patch
new file mode 100644
index 00000000000..f07a26bad6f
--- /dev/null
+++ b/pkgs/applications/terminal-emulators/foot/Add-support-for-opening-an-existing-PTY.patch
@@ -0,0 +1,211 @@
+From 6cb6fe265eb8c066fce8ce12473d6b8135f3b3cb Mon Sep 17 00:00:00 2001
+From: Alyssa Ross <hi@alyssa.is>
+Date: Fri, 10 Dec 2021 17:40:59 +0000
+Subject: [PATCH] Add support for opening an existing PTY
+
+---
+ main.c     | 12 +++++++++-
+ server.c   |  2 +-
+ terminal.c | 65 +++++++++++++++++++++++++++++++-----------------------
+ terminal.h |  2 +-
+ 4 files changed, 51 insertions(+), 30 deletions(-)
+
+diff --git a/main.c b/main.c
+index 4f2dc7b6..d1307a84 100644
+--- a/main.c
++++ b/main.c
+@@ -152,6 +152,10 @@ print_pid(const char *pid_file, bool *unlink_at_exit)
+         return false;
+ }
+ 
++enum {
++    PTY_OPTION = CHAR_MAX + 1,
++};
++
+ int
+ main(int argc, char *const *argv)
+ {
+@@ -187,6 +191,7 @@ main(int argc, char *const *argv)
+         {"maximized",              no_argument,       NULL, 'm'},
+         {"fullscreen",             no_argument,       NULL, 'F'},
+         {"presentation-timings",   no_argument,       NULL, 'P'}, /* Undocumented */
++        {"pty",                    required_argument, NULL, PTY_OPTION},
+         {"print-pid",              required_argument, NULL, 'p'},
+         {"log-level",              required_argument, NULL, 'd'},
+         {"log-colorize",           optional_argument, NULL, 'l'},
+@@ -202,6 +207,7 @@ main(int argc, char *const *argv)
+     const char *conf_title = NULL;
+     const char *conf_app_id = NULL;
+     const char *custom_cwd = NULL;
++    const char *pty_path = NULL;
+     bool login_shell = false;
+     tll(char *) conf_fonts = tll_init();
+     enum conf_size_type conf_size_type = CONF_SIZE_PX;
+@@ -320,6 +326,10 @@ main(int argc, char *const *argv)
+                 conf_server_socket_path = optarg;
+             break;
+ 
++        case PTY_OPTION:
++            pty_path = optarg;
++            break;
++
+         case 'P':
+             presentation_timings = true;
+             break;
+@@ -538,7 +548,7 @@ main(int argc, char *const *argv)
+         goto out;
+ 
+     if (!as_server && (term = term_init(
+-                           &conf, fdm, reaper, wayl, "foot", cwd, token,
++                           &conf, fdm, reaper, wayl, "foot", cwd, token, pty_path,
+                            argc, argv,
+                            &term_shutdown_cb, &shutdown_ctx)) == NULL) {
+         goto out;
+diff --git a/server.c b/server.c
+index 1d31abc6..190d224d 100644
+--- a/server.c
++++ b/server.c
+@@ -315,7 +315,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
+     instance->terminal = term_init(
+         conf != NULL ? conf : server->conf,
+         server->fdm, server->reaper, server->wayl, "footclient", cwd, token,
+-        cdata.argc, argv, &term_shutdown_handler, instance);
++        NULL, cdata.argc, argv, &term_shutdown_handler, instance);
+ 
+     if (instance->terminal == NULL) {
+         LOG_ERR("failed to instantiate new terminal");
+diff --git a/terminal.c b/terminal.c
+index ac887412..e11ef0d6 100644
+--- a/terminal.c
++++ b/terminal.c
+@@ -327,6 +327,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
+     if (hup) {
+         fdm_del(fdm, fd);
+         term->ptmx = -1;
++        term_shutdown(term);
+     }
+ 
+     return true;
+@@ -1035,10 +1036,12 @@ load_fonts_from_conf(struct terminal *term)
+ static void fdm_client_terminated(
+     struct reaper *reaper, pid_t pid, int status, void *data);
+ 
++static const int PTY_OPEN_FLAGS = O_RDWR | O_NOCTTY;
++
+ struct terminal *
+ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
+           struct wayland *wayl, const char *foot_exe, const char *cwd,
+-          const char *token, int argc, char *const *argv,
++          const char *token, const char *pty_path, int argc, char *const *argv,
+           void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data)
+ {
+     int ptmx = -1;
+@@ -1054,7 +1057,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
+         return NULL;
+     }
+ 
+-    if ((ptmx = posix_openpt(O_RDWR | O_NOCTTY)) < 0) {
++    ptmx = pty_path ? open(pty_path, PTY_OPEN_FLAGS) : posix_openpt(PTY_OPEN_FLAGS);
++    if (ptmx < 0) {
+         LOG_ERRNO("failed to open PTY");
+         goto close_fds;
+     }
+@@ -1116,6 +1120,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
+         .fdm = fdm,
+         .reaper = reaper,
+         .conf = conf,
++        .slave = -1,
+         .ptmx = ptmx,
+         .ptmx_buffers = tll_init(),
+         .ptmx_paste_buffers = tll_init(),
+@@ -1237,16 +1242,18 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
+     }
+     term->font_line_height = conf->line_height;
+ 
+-    /* Start the slave/client */
+-    if ((term->slave = slave_spawn(
+-             term->ptmx, argc, term->cwd, argv,
+-             conf->term, conf->shell, conf->login_shell,
+-             &conf->notifications)) == -1)
+-    {
+-        goto err;
+-    }
++    if (!pty_path) {
++        /* Start the slave/client */
++        if ((term->slave = slave_spawn(
++                 term->ptmx, argc, term->cwd, argv,
++                 conf->term, conf->shell, conf->login_shell,
++                 &conf->notifications)) == -1)
++        {
++            goto err;
++        }
+ 
+-    reaper_add(term->reaper, term->slave, &fdm_client_terminated, term);
++        reaper_add(term->reaper, term->slave, &fdm_client_terminated, term);
++    }
+ 
+     /* Guess scale; we're not mapped yet, so we don't know on which
+      * output we'll be. Pick highest scale we find for now */
+@@ -1506,26 +1513,30 @@ term_shutdown(struct terminal *term)
+         close(term->ptmx);
+ 
+     if (!term->shutdown.client_has_terminated) {
+-        LOG_DBG("initiating asynchronous terminate of slave; "
+-                "sending SIGTERM to PID=%u", term->slave);
++        if (term->slave <= 0) {
++            term->shutdown.client_has_terminated = true;
++        } else {
++            LOG_DBG("initiating asynchronous terminate of slave; "
++                    "sending SIGTERM to PID=%u", term->slave);
+ 
+-        kill(-term->slave, SIGTERM);
++            kill(-term->slave, SIGTERM);
+ 
+-        const struct itimerspec timeout = {.it_value = {.tv_sec = 60}};
++            const struct itimerspec timeout = {.it_value = {.tv_sec = 60}};
+ 
+-        int timeout_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
+-        if (timeout_fd < 0 ||
+-            timerfd_settime(timeout_fd, 0, &timeout, NULL) < 0 ||
+-            !fdm_add(term->fdm, timeout_fd, EPOLLIN, &fdm_terminate_timeout, term))
+-        {
+-            if (timeout_fd >= 0)
+-                close(timeout_fd);
+-            LOG_ERRNO("failed to create slave terminate timeout FD");
+-            return false;
++            int timeout_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
++            if (timeout_fd < 0 ||
++                timerfd_settime(timeout_fd, 0, &timeout, NULL) < 0 ||
++                !fdm_add(term->fdm, timeout_fd, EPOLLIN, &fdm_terminate_timeout, term))
++            {
++                if (timeout_fd >= 0)
++                    close(timeout_fd);
++                LOG_ERRNO("failed to create slave terminate timeout FD");
++                return false;
++            }
++
++            xassert(term->shutdown.terminate_timeout_fd < 0);
++            term->shutdown.terminate_timeout_fd = timeout_fd;
+         }
+-
+-        xassert(term->shutdown.terminate_timeout_fd < 0);
+-        term->shutdown.terminate_timeout_fd = timeout_fd;
+     }
+ 
+     term->selection.auto_scroll.fd = -1;
+diff --git a/terminal.h b/terminal.h
+index 09b04614..3beb3e80 100644
+--- a/terminal.h
++++ b/terminal.h
+@@ -671,7 +671,7 @@ struct config;
+ struct terminal *term_init(
+     const struct config *conf, struct fdm *fdm, struct reaper *reaper,
+     struct wayland *wayl, const char *foot_exe, const char *cwd,
+-    const char *token, int argc, char *const *argv,
++    const char *token, const char *pty_path, int argc, char *const *argv,
+     void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data);
+ 
+ bool term_shutdown(struct terminal *term);
+-- 
+2.33.0
+
diff --git a/pkgs/applications/terminal-emulators/foot/default.nix b/pkgs/applications/terminal-emulators/foot/default.nix
index 41154cc1034..a58e45e50dc 100644
--- a/pkgs/applications/terminal-emulators/foot/default.nix
+++ b/pkgs/applications/terminal-emulators/foot/default.nix
@@ -102,6 +102,10 @@ stdenv.mkDerivation rec {
     sha256 = "1d9bk8lhmw5lc8k0mw80g0vbwgxyh3gw5c7ppy3sir07s9y0y0fn";
   };
 
+  patches = [
+    ./Add-support-for-opening-an-existing-PTY.patch
+  ];
+
   depsBuildBuild = [
     pkg-config
   ];
diff --git a/pkgs/applications/window-managers/weston/default.nix b/pkgs/applications/window-managers/weston/default.nix
index deb39708106..2dc85866cb7 100644
--- a/pkgs/applications/window-managers/weston/default.nix
+++ b/pkgs/applications/window-managers/weston/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, fetchurl, fetchpatch, meson, ninja, pkg-config, wayland-scanner
-, python3, wayland, libGL, mesa, libxkbcommon, cairo, libxcb
+, python3, wayland, libGL, mesa, libxkbcommon, cairo, libxcb, seatd
 , libXcursor, xlibsWrapper, udev, libdrm, mtdev, libjpeg, pam, dbus, libinput, libevdev, pixman
 , colord, lcms2, pipewire ? null
 , pango ? null, libunwind ? null, freerdp ? null, vaapi ? null, libva ? null
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ meson ninja pkg-config /* wayland-scanner */ python3 ];
   buildInputs = [
-    wayland /* libGL mesa */ libxkbcommon cairo /* libxcb libXcursor xlibsWrapper udev */ libdrm
+    wayland libGL mesa libxkbcommon cairo /* libxcb libXcursor xlibsWrapper udev */ libdrm
     /* mtdev libjpeg pam dbus */ libinput libevdev /* pango libunwind freerdp vaapi libva */ pixman
     /* libwebp */ wayland-protocols
   #   colord lcms2 pipewire
@@ -29,10 +29,11 @@ stdenv.mkDerivation rec {
     "-Dimage-jpeg=false"
     "-Dimage-webp=false"
     "-Dlauncher-logind=false"
-    "-Drenderer-gl=false"
+    # "-Dlauncher-libseat=true"
+    # "-Drenderer-gl=false"
     "-Dbackend-drm-screencast-vaapi=false"
-    "-Dbackend-drm=false"
-    "-Dbackend-default=auto"
+    # "-Dbackend-drm=false"
+    "-Dbackend-default=drm"
     "-Dbackend-rdp=false"
     "-Dxwayland=false"
     "-Dcolor-management-lcms=false"
@@ -42,6 +43,8 @@ stdenv.mkDerivation rec {
     "-Dsimple-clients="
     "-Ddemo-clients=false"
     "-Dtest-junit-xml=false"
+    "-Dsystemd=false"
+    "-Dlauncher-logind=false"
   ];
 
   # mesonFlags= [
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 23163763ed9..3311bfe727e 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -71,6 +71,15 @@ self = stdenv.mkDerivation {
     # Fix aarch64-darwin build, remove when upstreaam supports it out of the box.
     # See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/1020
     ./aarch64-darwin.patch
+  ] ++ optionals (stdenv.hostPlatform.isMusl) [
+    (fetchpatch {
+      url = "https://gitlab.freedesktop.org/mesa/mesa/-/commit/2bc8e601b9120becd2ced18a8803bbed2641ba56.patch";
+      sha256 = "1b17z9w8snm9clw2x5byjqpwnx2pz1xksib5zvc1s68vcf6p86h3";
+    })
+    (fetchpatch {
+      url = "https://gitlab.freedesktop.org/mesa/mesa/-/commit/971853569f7084a89be79aad76178234ce07adad.patch";
+      sha256 = "1lkw5cc0p7lm67db1qnn3fz1lsgdnszg40dig3s5rfsg4gjdzg6m";
+    })
   ];
 
   postPatch = ''
diff --git a/pkgs/os-specific/linux/libsepol/default.nix b/pkgs/os-specific/linux/libsepol/default.nix
index 5fa51ac2238..362c6cef336 100644
--- a/pkgs/os-specific/linux/libsepol/default.nix
+++ b/pkgs/os-specific/linux/libsepol/default.nix
@@ -27,11 +27,11 @@ stdenv.mkDerivation rec {
     "MAN3DIR=$(man)/share/man/man3"
     "MAN8DIR=$(man)/share/man/man8"
     "SHLIBDIR=$(out)/lib"
-  ];
+  ] ++ lib.optional stdenv.hostPlatform.isStatic "DISABLE_SHARED=y";
 
   NIX_CFLAGS_COMPILE = "-Wno-error";
 
-  passthru = { inherit se_url; };
+  enableParallelBuilding = true;
 
   meta = with lib; {
     description = "SELinux binary policy manipulation library";
diff --git a/pkgs/tools/misc/colord/default.nix b/pkgs/tools/misc/colord/default.nix
index f3d7503b9c9..3a1a69c7842 100644
--- a/pkgs/tools/misc/colord/default.nix
+++ b/pkgs/tools/misc/colord/default.nix
@@ -26,6 +26,7 @@
 , docbook_xml_dtd_412
 , gtk-doc
 , libxslt
+, enableDaemon ? true
 }:
 
 stdenv.mkDerivation rec {
@@ -56,6 +57,7 @@ stdenv.mkDerivation rec {
     "-Dlibcolordcompat=true"
     "-Dsane=true"
     "-Dvapi=true"
+    "-Ddaemon=${lib.boolToString enableDaemon}"
     "-Ddaemon_user=colord"
   ];