Last active
February 13, 2025 20:01
-
-
Save FlawlessCasual17/43d727fa9cb0cd16da1e4a5eae879386 to your computer and use it in GitHub Desktop.
Wrappers for `nix profile install` for non-NixOS KDE Plasma Linux/Unix distributions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# # Do sudo first | |
# sudo -v | |
# # Check if the user has sudo privellages | |
# sudo -n true | |
# sudo_status=$? | |
# if [ $sudo_status -ne 0 ]; then | |
# echo 'Root-like/Sudo access is required.' | |
# exit 1 | |
# fi | |
# Check if a package name was provided | |
if [ -z "$1" ]; then | |
echo "Usage: $0 package-name" | |
exit 1 | |
fi | |
# Install the package with nix | |
if [ -z "$2" ]; then | |
nix profile install "nixpkgs#${1}" | |
else | |
nix profile install "nixpkgs#${1}" "$2" | |
fi | |
# Check exit code | |
exit_code=$? | |
if [ $exit_code -ne 0 ]; then | |
echo 'Try using the `--impure` option if your are installing a non-free package.' | |
printf "\\e[31mError: Installation of %s failed!\\e[0m" "$1" | |
exit 1 | |
fi | |
# Update desktop database | |
kbuildsycoca6 | |
echo "Package '${1}' installed and desktop database updated" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# # Do sudo first | |
# sudo -v | |
# # Check if the user has sudo privellages | |
# sudo -n true | |
# sudo_status=$? | |
# if [ $sudo_status -ne 0 ]; then | |
# echo 'Root-like/Sudo access is required.' | |
# exit 1 | |
# fi | |
# Check if a package name was provided | |
if [ -z "$1" ]; then | |
echo "Usage: $0 package-name" | |
exit 1 | |
fi | |
# Remove the package with nix | |
nix profile remove "$1" | |
# Update desktop databaseup | |
kbuildsycoca6 | |
echo "Package '${1}' removed and desktop database updated!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These currently only work for those who have set KDE Plasma 6+ as their desktop enviroment.