From 1da6d4e38eb934bf6542d7565179e8f06ab44e94 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 10 Aug 2022 12:46:40 +0800 Subject: [PATCH] pop-launcher: follow from NixOS/nixpkgs#176303 --- pkgs/pop-launcher.nix | 49 +++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/pkgs/pop-launcher.nix b/pkgs/pop-launcher.nix index d72f2752..3861d5cc 100644 --- a/pkgs/pop-launcher.nix +++ b/pkgs/pop-launcher.nix @@ -1,4 +1,9 @@ -{ lib, fetchFromGitHub, rustPlatform, just, runtimeShell }: +{ rustPlatform +, fetchFromGitHub +, lib +, fd +, libqalculate +}: rustPlatform.buildRustPackage rec { pname = "pop-launcher"; @@ -7,22 +12,44 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "pop-os"; repo = "launcher"; - rev = version; + rev = "${version}"; sha256 = "sha256-BQAO9IodZxGgV8iBmUaOF0yDbAMVDFslKCqlh3pBnb0="; }; - cargoSha256 = "sha256-cTvrq0fH057UIx/O9u8zHMsg+psMGg1q9klV5OMxtok="; - - # Replace the distribution plugins path since it is only usable with traditional Linux distros. postPatch = '' - substituteInPlace justfile --replace "#!/usr/bin/env sh" "#!${runtimeShell}" - substituteInPlace src/lib.rs --replace "/usr/lib/pop-launcher" "$out/share/pop-launcher" - substituteInPlace plugins/src/scripts/mod.rs --replace "/usr/lib/pop-launcher" "$out/share/pop-launcher" + substituteInPlace src/lib.rs \ + --replace '/usr/lib/pop-launcher' "$out/share/pop-launcher" + substituteInPlace plugins/src/scripts/mod.rs \ + --replace '/usr/lib/pop-launcher' "$out/share/pop-launcher" + substituteInPlace plugins/src/calc/mod.rs \ + --replace 'Command::new("qalc")' 'Command::new("${libqalculate}/bin/qalc")' + substituteInPlace plugins/src/find/mod.rs \ + --replace 'spawn("fd")' 'spawn("${fd}/bin/fd")' + substituteInPlace plugins/src/terminal/mod.rs \ + --replace '/usr/bin/gnome-terminal' 'gnome-terminal' ''; - nativeBuildInputs = [ just ]; - buildPhase = "just"; - installPhase = "just base_dir=$out/ install"; + cargoSha256 = "sha256-cTvrq0fH057UIx/O9u8zHMsg+psMGg1q9klV5OMxtok="; + + cargoBuildFlags = [ "--package" "pop-launcher-bin" ]; + + postInstall = '' + mv $out/bin/pop-launcher{-bin,} + + plugins_dir=$out/share/pop-launcher/plugins + scripts_dir=$out/share/pop-launcher/scripts + mkdir -p $plugins_dir $scripts_dir + + for plugin in $(find plugins/src -mindepth 1 -maxdepth 1 -type d -printf '%f\n'); do + mkdir $plugins_dir/$plugin + cp plugins/src/$plugin/*.ron $plugins_dir/$plugin + ln -sf $out/bin/pop-launcher $plugins_dir/$plugin/$(echo $plugin | sed 's/_/-/') + done + + for script in scripts/*; do + cp -r $script $scripts_dir + done + ''; meta = with lib; { description = "Modular IPC-based desktop launcher service";