From 8703e243eb4e9dbd256d7ec1f3306e58758161b8 Mon Sep 17 00:00:00 2001 From: e-tho <128100160+e-tho@users.noreply.github.com> Date: Wed, 23 Oct 2024 07:03:07 +0200 Subject: [PATCH] Add optional systemd support to flake package (#63) * Enable systemd support in the flake package * Add optional derivation without systemd support --- flake.nix | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 5eacbde..f9c3876 100644 --- a/flake.nix +++ b/flake.nix @@ -15,11 +15,39 @@ let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; + lib = pkgs.lib; + naersk' = pkgs.callPackage naersk { cargo = pkgs.rust-bin.stable.latest.default; rustc = pkgs.rust-bin.stable.latest.default; }; - in { + + buildXwaylandSatellite = { withSystemd ? false }: naersk'.buildPackage { + src = ./.; + + nativeBuildInputs = with pkgs; [ + rustPlatform.bindgenHook + rust-bin.stable.latest.default + pkg-config + + xcb-util-cursor + xorg.libxcb + + makeWrapper + ] ++ lib.optional withSystemd pkgs.systemd; + + buildInputs = [ pkgs.xwayland ]; + + cargoBuildOptions = opts: opts ++ lib.optional withSystemd "--features systemd"; + + postInstall = '' + wrapProgram $out/bin/xwayland-satellite \ + --prefix PATH : ${pkgs.xwayland}/bin + ''; + }; + + in + { devShell = (pkgs.mkShell.override { stdenv = pkgs.clangStdenv; }) { buildInputs = with pkgs; [ rustPlatform.bindgenHook @@ -33,26 +61,9 @@ }; packages = rec { - xwayland-satellite = naersk'.buildPackage { - src = ./.; + xwayland-satellite-nosd = buildXwaylandSatellite { withSystemd = false; }; - nativeBuildInputs = with pkgs; [ - rustPlatform.bindgenHook - rust-bin.stable.latest.default - pkg-config - - xcb-util-cursor - xorg.libxcb - - makeWrapper - ]; - buildInputs = [ pkgs.xwayland ]; - - postInstall = '' - wrapProgram $out/bin/xwayland-satellite \ - --prefix PATH : ${pkgs.xwayland}/bin - ''; - }; + xwayland-satellite = buildXwaylandSatellite { withSystemd = true; }; default = xwayland-satellite; };