Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added plugin to launch nix applications without installing them #83

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switched from nix-shell -p <pkg> --run <pkg> -> `nix run nixpkgs#<p…
…kg>`
sntx committed Aug 16, 2023
commit 4f4c345b8ec312ff3759d5663633d8296970cfd2
17 changes: 12 additions & 5 deletions plugins/nix/src/lib.rs
Original file line number Diff line number Diff line change
@@ -28,6 +28,13 @@ pub struct NixEntry {
name: RString,
desc: RString,
}
impl NixEntry {
fn get_command(&self) -> RString {
let mut cmd = RString::from("nixpkgs#");
cmd.push_str(&self.name);
cmd
}
}

#[handler]
pub fn handler(selection: Match, state: &State) -> HandleResult {
@@ -43,11 +50,11 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
})
.unwrap();

if let Err(why) = Command::new("nix-shell")
.arg("-p")
.arg(&*entry.name)
.arg("--run")
.arg(&*entry.name)
if let Err(why) = Command::new("nix")
.arg("--experimental-features")
.arg("nix-command flakes")
.arg("run")
.arg(&*entry.get_command())
.spawn()
{
eprintln!("Error running desktop entry: {}", why);