about summary refs log tree commit diff stats
path: root/pkgs/by-name/no
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/no/notify-run/.envrc (renamed from pkgs/by-name/ya/yambar-modules/.envrc)11
-rw-r--r--pkgs/by-name/no/notify-run/.gitignore (renamed from pkgs/by-name/ge/generate_moz_extension/.gitignore)3
-rw-r--r--pkgs/by-name/no/notify-run/Cargo.lock25
-rw-r--r--pkgs/by-name/no/notify-run/Cargo.toml (renamed from pkgs/by-name/ya/yambar-modules/Cargo.toml)7
-rw-r--r--pkgs/by-name/no/notify-run/flake.lock27
-rw-r--r--pkgs/by-name/no/notify-run/flake.lock.license (renamed from pkgs/by-name/ge/generate_moz_extension/flake.lock.license)0
-rw-r--r--pkgs/by-name/no/notify-run/flake.nix34
-rw-r--r--pkgs/by-name/no/notify-run/package.nix (renamed from pkgs/by-name/ge/generate_moz_extension/package.nix)34
-rw-r--r--pkgs/by-name/no/notify-run/src/main.rs65
-rwxr-xr-xpkgs/by-name/no/notify-run/update.sh (renamed from pkgs/by-name/ge/generate_moz_extension/update.sh)2
10 files changed, 191 insertions, 17 deletions
diff --git a/pkgs/by-name/ya/yambar-modules/.envrc b/pkgs/by-name/no/notify-run/.envrc
index 294de504..880b1809 100644
--- a/pkgs/by-name/ya/yambar-modules/.envrc
+++ b/pkgs/by-name/no/notify-run/.envrc
@@ -10,4 +10,13 @@
 # You should have received a copy of the License along with this program.
 # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use flake
+use flake || use nix
+watch_file flake.nix
+
+PATH_add ./target/debug
+PATH_add ./target/release
+PATH_add ./scripts
+
+if on_git_branch; then
+    echo && git status --short --branch
+fi
diff --git a/pkgs/by-name/ge/generate_moz_extension/.gitignore b/pkgs/by-name/no/notify-run/.gitignore
index cc03ebd7..8f29eabf 100644
--- a/pkgs/by-name/ge/generate_moz_extension/.gitignore
+++ b/pkgs/by-name/no/notify-run/.gitignore
@@ -8,6 +8,9 @@
 # You should have received a copy of the License along with this program.
 # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
+# build
 /target
 /result
+
+# dev env
 .direnv
diff --git a/pkgs/by-name/no/notify-run/Cargo.lock b/pkgs/by-name/no/notify-run/Cargo.lock
new file mode 100644
index 00000000..1e065d25
--- /dev/null
+++ b/pkgs/by-name/no/notify-run/Cargo.lock
@@ -0,0 +1,25 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+version = 4
+
+[[package]]
+name = "anyhow"
+version = "1.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
+
+[[package]]
+name = "notify-run"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+]
diff --git a/pkgs/by-name/ya/yambar-modules/Cargo.toml b/pkgs/by-name/no/notify-run/Cargo.toml
index 45078170..c4b9a659 100644
--- a/pkgs/by-name/ya/yambar-modules/Cargo.toml
+++ b/pkgs/by-name/no/notify-run/Cargo.toml
@@ -9,11 +9,12 @@
 # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
 [package]
-name = "yambar-modules"
+name = "notify-run"
+description = "An safe way to run applications that might fail"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-sysinfo = "0.28.4"
+anyhow = "1.0.100"
diff --git a/pkgs/by-name/no/notify-run/flake.lock b/pkgs/by-name/no/notify-run/flake.lock
new file mode 100644
index 00000000..4822d9da
--- /dev/null
+++ b/pkgs/by-name/no/notify-run/flake.lock
@@ -0,0 +1,27 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1765270179,
+        "narHash": "sha256-g2a4MhRKu4ymR4xwo+I+auTknXt/+j37Lnf0Mvfl1rE=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "677fbe97984e7af3175b6c121f3c39ee5c8d62c9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/pkgs/by-name/ge/generate_moz_extension/flake.lock.license b/pkgs/by-name/no/notify-run/flake.lock.license
index eae6a84c..eae6a84c 100644
--- a/pkgs/by-name/ge/generate_moz_extension/flake.lock.license
+++ b/pkgs/by-name/no/notify-run/flake.lock.license
diff --git a/pkgs/by-name/no/notify-run/flake.nix b/pkgs/by-name/no/notify-run/flake.nix
new file mode 100644
index 00000000..07be3258
--- /dev/null
+++ b/pkgs/by-name/no/notify-run/flake.nix
@@ -0,0 +1,34 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+  description = "An safe way to run applications, that might fail";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+  };
+
+  outputs = {nixpkgs, ...}: let
+    system = "x86_64-linux";
+    pkgs = nixpkgs.legacyPackages."${system}";
+  in {
+    devShells."${system}".default = pkgs.mkShell {
+      packages = [
+        pkgs.cargo
+        pkgs.clippy
+        pkgs.rustc
+        pkgs.rustfmt
+
+        pkgs.cargo-edit
+      ];
+    };
+  };
+}
+# vim: ts=2
+
diff --git a/pkgs/by-name/ge/generate_moz_extension/package.nix b/pkgs/by-name/no/notify-run/package.nix
index aae5ea6c..1f9337be 100644
--- a/pkgs/by-name/ge/generate_moz_extension/package.nix
+++ b/pkgs/by-name/no/notify-run/package.nix
@@ -9,21 +9,33 @@
 # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 {
   rustPlatform,
-  openssl,
-  pkg-config,
+  lib,
+  libnotify,
+  makeWrapper,
 }:
-rustPlatform.buildRustPackage {
-  pname = "generate_firefox_extensions";
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "notify-run";
   version = "0.1.0";
 
-  src = ./.;
-  cargoLock = {
-    lockFile = ./Cargo.lock;
-  };
   buildInputs = [
-    openssl # needed for openssl-sys crate
+    libnotify
   ];
   nativeBuildInputs = [
-    pkg-config # needed for openssl dependency
+    makeWrapper
   ];
-}
+
+  src = ./.;
+  cargoLock = {
+    lockFile = ./Cargo.lock;
+  };
+
+  postInstall = ''
+    # NOTE: We cannot clear the path, because we need access to the programs to start. <2025-12-03>
+    wrapProgram $out/bin/notify-run \
+      --prefix PATH : ${lib.makeBinPath finalAttrs.buildInputs}
+  '';
+
+  meta = {
+    mainProgram = "notify-run";
+  };
+})
diff --git a/pkgs/by-name/no/notify-run/src/main.rs b/pkgs/by-name/no/notify-run/src/main.rs
new file mode 100644
index 00000000..a6a0165a
--- /dev/null
+++ b/pkgs/by-name/no/notify-run/src/main.rs
@@ -0,0 +1,65 @@
+// nixos-config - My current NixOS configuration
+//
+// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// This file is part of my nixos-config.
+//
+// You should have received a copy of the License along with this program.
+// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+use std::{env::args, path::PathBuf, process::Command};
+
+use anyhow::{Context, Result};
+
+fn main() -> Result<()> {
+    let args = args().skip(1).collect::<Vec<_>>();
+
+    let mut cmd = Command::new(&args[0]);
+    if let Some(arguments) = args.get(1) {
+        cmd.args(arguments.split(" ").collect::<Vec<_>>().as_slice());
+    }
+
+    eprintln!("Spawning {:?}", cmd);
+
+    let output = cmd
+        .output()
+        .with_context(|| format!("Failed to spawn and await output of {:?}", cmd))?;
+
+    if !output.status.success() {
+        let mut notify_send = Command::new("notify-send");
+        notify_send.args([
+            format!("Command {:?} failed", cmd).as_str(),
+            &String::from_utf8_lossy(output.stderr.as_slice()),
+        ]);
+
+        notify_send.status().with_context(|| {
+            format!(
+                "Failed to run `notify-send` to tell about failed command ({:?}).",
+                cmd
+            )
+        })?;
+    } else {
+        let name = PathBuf::from(&args[0])
+            .file_name()
+            .expect("this to be a command, and thus have a file_name")
+            .to_string_lossy()
+            .to_string();
+
+        print!("{}", append_name(&name, &output.stdout));
+        eprint!("{}", append_name(&name, &output.stderr));
+    }
+
+    Ok(())
+}
+
+fn append_name(name: &str, base: &[u8]) -> String {
+    let base = String::from_utf8_lossy(base).to_string();
+
+    let mut output = String::new();
+    for line in base.lines() {
+        output.push_str(format!("{name}> {line}\n").as_str());
+    }
+
+    output
+}
diff --git a/pkgs/by-name/ge/generate_moz_extension/update.sh b/pkgs/by-name/no/notify-run/update.sh
index c7c35d39..23d90a86 100755
--- a/pkgs/by-name/ge/generate_moz_extension/update.sh
+++ b/pkgs/by-name/no/notify-run/update.sh
@@ -12,5 +12,3 @@
 
 [ "$1" = "upgrade" ] && cargo upgrade
 cargo update
-
-# vim: ft=sh