diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-29 21:17:01 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-11-29 21:17:01 +0100 |
| commit | c9ccf8491f732499fb9e1834e61b4edc77d18423 (patch) | |
| tree | 511366c2be4843bdef613e336c6ecef2c2c9c5ec /pkgs/by-name/no | |
| parent | modules/qutebrowser: Change default search engine (diff) | |
| download | nixos-config-c9ccf8491f732499fb9e1834e61b4edc77d18423.zip | |
pkgs/notify-run: Init
Diffstat (limited to 'pkgs/by-name/no')
| -rw-r--r-- | pkgs/by-name/no/notify-run/.envrc | 22 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/.gitignore | 16 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/Cargo.lock | 25 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/Cargo.toml | 20 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/flake.lock | 27 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/flake.lock.license | 9 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/flake.nix | 34 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/package.nix | 23 | ||||
| -rw-r--r-- | pkgs/by-name/no/notify-run/src/main.rs | 46 | ||||
| -rwxr-xr-x | pkgs/by-name/no/notify-run/update.sh | 14 |
10 files changed, 236 insertions, 0 deletions
diff --git a/pkgs/by-name/no/notify-run/.envrc b/pkgs/by-name/no/notify-run/.envrc new file mode 100644 index 00000000..880b1809 --- /dev/null +++ b/pkgs/by-name/no/notify-run/.envrc @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +# 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 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/no/notify-run/.gitignore b/pkgs/by-name/no/notify-run/.gitignore new file mode 100644 index 00000000..8f29eabf --- /dev/null +++ b/pkgs/by-name/no/notify-run/.gitignore @@ -0,0 +1,16 @@ +# 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>. + +# 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/no/notify-run/Cargo.toml b/pkgs/by-name/no/notify-run/Cargo.toml new file mode 100644 index 00000000..c4b9a659 --- /dev/null +++ b/pkgs/by-name/no/notify-run/Cargo.toml @@ -0,0 +1,20 @@ +# 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>. + +[package] +name = "notify-run" +description = "An safe way to run applications that might fail" +version = "0.1.0" +edition = "2024" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +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..b67bb39a --- /dev/null +++ b/pkgs/by-name/no/notify-run/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1764230294, + "narHash": "sha256-Z63xl5Scj3Y/zRBPAWq1eT68n2wBWGCIEF4waZ0bQBE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d59e0290eefe0f12512043842d7096c4070f30e", + "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/no/notify-run/flake.lock.license b/pkgs/by-name/no/notify-run/flake.lock.license new file mode 100644 index 00000000..eae6a84c --- /dev/null +++ b/pkgs/by-name/no/notify-run/flake.lock.license @@ -0,0 +1,9 @@ +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>. 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/no/notify-run/package.nix b/pkgs/by-name/no/notify-run/package.nix new file mode 100644 index 00000000..a5b0a1d7 --- /dev/null +++ b/pkgs/by-name/no/notify-run/package.nix @@ -0,0 +1,23 @@ +# 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>. +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "notify-run"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + + 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..18b7af58 --- /dev/null +++ b/pkgs/by-name/no/notify-run/src/main.rs @@ -0,0 +1,46 @@ +// 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, process::Command}; + +use anyhow::{Context, Result}; + +fn main() -> Result<()> { + let args = args().skip(1).collect::<Vec<_>>(); + + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]); + + 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 { + print!("{}", String::from_utf8_lossy(&output.stdout)); + eprint!("{}", String::from_utf8_lossy(&output.stderr)); + } + + Ok(()) +} diff --git a/pkgs/by-name/no/notify-run/update.sh b/pkgs/by-name/no/notify-run/update.sh new file mode 100755 index 00000000..23d90a86 --- /dev/null +++ b/pkgs/by-name/no/notify-run/update.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +# 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>. + +[ "$1" = "upgrade" ] && cargo upgrade +cargo update |
