Release Ver 1.2.0
This commit is contained in:
parent
7f73899c91
commit
89600ebb06
25 changed files with 1862 additions and 57 deletions
180
nyx/bash/nyx-info.sh
Normal file
180
nyx/bash/nyx-info.sh
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
#!/usr/bin/env bash
|
||||
nyx-info() {
|
||||
############################################
|
||||
# CONFIG (injected by Nix)
|
||||
############################################
|
||||
local info_dir="@LOG_DIR@/info"
|
||||
local topic_name="Homemanager-Support"
|
||||
local msg_file="${info_dir}/${topic_name}-message.txt"
|
||||
local inform_enable=false
|
||||
local sleeptimer=3
|
||||
|
||||
|
||||
# ⚠ IMPORTANT PROJECT UPDATE ⚠
|
||||
|
||||
local information="
|
||||
⚠ IMPORTANT PROJECT UPDATE ⚠
|
||||
|
||||
Please note that I will soon switch Nyx from a Home Manager module to a NixOS module.
|
||||
You can still use the Home Manager module, but I will only continue developing it for Nyx at a specific legacy commit/revision.
|
||||
|
||||
Please consider pinning Nyx to that commit:
|
||||
[https://github.com/Peritia-System/Nyx-Tools/blob/main/Documentation/How-to-Homemanager.md](https://github.com/Peritia-System/Nyx-Tools/blob/main/Documentation/How-to-Homemanager.md)
|
||||
|
||||
If you use this, you can keep the current version indefinitely but wont receive updates.
|
||||
If you dont pin to that commit, I wont take any responsibility for breakage.
|
||||
(Note: I dont take any responsibility regardless — this is a hobby project.)
|
||||
If you want to ensure it works, help me develop it.
|
||||
|
||||
Thank you for your understanding <3
|
||||
|
||||
This is not supposed to discourage you from using Nyx!!! I am so, so glad you use Nyx :)
|
||||
But it is very early in development so things move quick and big changes will be common.
|
||||
Plus as I said, it is a hobby project and at the moment I develop alone.
|
||||
"
|
||||
|
||||
############################################
|
||||
# Helpers
|
||||
############################################
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: nyx-info [--acknowledge] [--print-force] [--help]
|
||||
|
||||
--acknowledge Record acknowledgment for the current notice and print it.
|
||||
--print-force Print the current notice without reading/writing state.
|
||||
--help Show this help.
|
||||
|
||||
Notes:
|
||||
- You'll be prompted again if the notice text changes.
|
||||
- State is stored under @LOG_DIR@/info per topic, in this format:
|
||||
|
||||
-----Acknowledged-----
|
||||
$ack
|
||||
-----BEGIN INFO-----
|
||||
$information
|
||||
-----END INFO-----
|
||||
-----BEGIN SHA-----
|
||||
$sha
|
||||
-----END SHA-----
|
||||
EOF
|
||||
}
|
||||
|
||||
ensure_storage() {
|
||||
mkdir -p "${info_dir}"
|
||||
}
|
||||
|
||||
hash_text() {
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum | awk '{print $1}'
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 | awk '{print $1}'
|
||||
else
|
||||
echo "ERROR: Need sha256sum or shasum on PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
current_sha() {
|
||||
printf '%s' "${information}" | hash_text
|
||||
}
|
||||
|
||||
save_state() {
|
||||
# $1 = ack (true/false), $2 = sha
|
||||
{
|
||||
echo "-----Acknowledged-----"
|
||||
echo "$1"
|
||||
echo "-----BEGIN INFO-----"
|
||||
printf '%s\n' "${information}"
|
||||
echo "-----END INFO-----"
|
||||
echo "-----BEGIN SHA-----"
|
||||
echo "$2"
|
||||
echo "-----END SHA-----"
|
||||
} > "${msg_file}"
|
||||
}
|
||||
|
||||
load_state() {
|
||||
# Sets globals: stored_ack, stored_sha, stored_info (empty if no file).
|
||||
stored_ack=""
|
||||
stored_sha=""
|
||||
stored_info=""
|
||||
|
||||
[[ -f "${msg_file}" ]] || return 0
|
||||
|
||||
stored_ack="$(awk '/^-----Acknowledged-----$/{getline; print; exit}' "${msg_file}" || true)"
|
||||
|
||||
stored_info="$(awk '
|
||||
BEGIN{p=0}
|
||||
/^-----BEGIN INFO-----$/ {p=1; next}
|
||||
/^-----END INFO-----$/ {p=0}
|
||||
p==1 {print}
|
||||
' "${msg_file}" || true)"
|
||||
|
||||
stored_sha="$(awk '
|
||||
BEGIN{p=0}
|
||||
/^-----BEGIN SHA-----$/ {p=1; next}
|
||||
/^-----END SHA-----$/ {p=0}
|
||||
p==1 {print}
|
||||
' "${msg_file}" || true)"
|
||||
}
|
||||
|
||||
print_notice() {
|
||||
cat <<EOF
|
||||
-----BEGIN NYX INFO NOTICE-----
|
||||
|
||||
${information}
|
||||
|
||||
-----END NYX INFO NOTICE-----
|
||||
|
||||
To acknowledge this message run: nyx-info --acknowledge
|
||||
EOF
|
||||
}
|
||||
|
||||
should_skip_notice() {
|
||||
local now_sha="$1"
|
||||
[[ -n "${stored_sha:-}" && "${stored_sha}" == "${now_sha}" && "${stored_ack:-}" == "true" ]]
|
||||
}
|
||||
|
||||
############################################
|
||||
# Main
|
||||
############################################
|
||||
local acknowledge=false print_force=false
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--acknowledge) acknowledge=true ;;
|
||||
--print-force) print_force=true ;;
|
||||
--help|-h) usage; exit 0 ;;
|
||||
*) echo "Unknown option: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[[ "${inform_enable}" == true ]] || exit 0
|
||||
ensure_storage
|
||||
|
||||
local now_sha
|
||||
now_sha="$(current_sha)"
|
||||
|
||||
if [[ "${print_force}" == true ]]; then
|
||||
print_notice
|
||||
exit 0
|
||||
fi
|
||||
|
||||
load_state
|
||||
|
||||
if [[ "${acknowledge}" == true ]]; then
|
||||
save_state "true" "${now_sha}"
|
||||
print_notice
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if should_skip_notice "${now_sha}"; then
|
||||
echo "Notice already acknowledged. To reread: ${info_dir} -> ${msg_file}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
save_state "false" "${now_sha}"
|
||||
print_notice
|
||||
}
|
||||
|
||||
nyx-info "$@"
|
||||
|
|
@ -49,6 +49,7 @@ nyx-tool() {
|
|||
echo ""
|
||||
echo -e "${LABEL}📌 Message: ${BOLD}${message}${RESET}"
|
||||
echo ""
|
||||
nyx-info
|
||||
}
|
||||
|
||||
nyx-tool "$@"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ let
|
|||
(toString (cfg.keepGenerations or 5))
|
||||
(if (nyxCfg.autoPush or false) then "true" else "false")
|
||||
"${pkgs.git}/bin/git"
|
||||
"1.1.0"
|
||||
"1.2.0"
|
||||
]
|
||||
src;
|
||||
in
|
||||
|
|
@ -40,11 +40,11 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf ((nyxCfg.enable or false) && (cfg.enable or false)) {
|
||||
home.packages = [
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "nyx-cleanup" cleanupScript)
|
||||
];
|
||||
|
||||
home.shellAliases = lib.mkIf (cfg.enableAlias or true) {
|
||||
environment.shellAliases = lib.mkIf (cfg.enableAlias or true) {
|
||||
nc = "nyx-cleanup";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ let
|
|||
"${pkgs.git}/bin/git"
|
||||
"${pkgs.nix-output-monitor}/bin/nom"
|
||||
(if nyxCfg.autoPush then "true" else "false")
|
||||
"1.1.0"
|
||||
"1.2.0"
|
||||
]
|
||||
src;
|
||||
in
|
||||
|
|
@ -40,14 +40,14 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf (nyxCfg.enable && cfg.enable) {
|
||||
home.packages =
|
||||
environment.systemPackages =
|
||||
lib.optionals (cfg.enableFormatting && cfg.formatter == "alejandra") [ pkgs.alejandra ]
|
||||
++ [
|
||||
# Ensure nyx-tool exists if you call it in the script
|
||||
(pkgs.writeShellScriptBin "nyx-rebuild" rebuiltScript)
|
||||
];
|
||||
|
||||
home.shellAliases = lib.mkIf cfg.enableAlias {
|
||||
environment.shellAliases = lib.mkIf cfg.enableAlias {
|
||||
nr = "nyx-rebuild";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,20 +1,31 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
nyxCfg = config.nyx;
|
||||
cfg = config.nyx.nyx-tool;
|
||||
infoScript =
|
||||
let
|
||||
src = builtins.readFile ./bash/nyx-info.sh;
|
||||
in
|
||||
builtins.replaceStrings
|
||||
[ "@LOG_DIR@" ]
|
||||
[ (toString nyxCfg.logDir) ]
|
||||
src;
|
||||
in
|
||||
{
|
||||
options.nyx.nyx-tool = {
|
||||
enable = lib.mkEnableOption "Enable nyx-tool banner script";
|
||||
enable = lib.mkEnableOption "Enable nyx-tool banner script and the current info";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.zsh.enable = lib.mkDefault true;
|
||||
home.packages = [
|
||||
environment.systemPackages = [
|
||||
pkgs.figlet
|
||||
(pkgs.writeShellScriptBin "nyx-tool"
|
||||
(builtins.readFile ./bash/nyx-tool.sh)
|
||||
)
|
||||
(pkgs.writeShellScriptBin "nyx-info"
|
||||
infoScript
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ let
|
|||
[
|
||||
(toString nyxCfg.logDir)
|
||||
(toString nyxCfg.nixDirectory)
|
||||
"1.1.1"
|
||||
"1.2.0"
|
||||
"${pkgs.dialog}/bin/dialog"
|
||||
]
|
||||
src;
|
||||
|
|
@ -24,6 +24,7 @@ in
|
|||
{
|
||||
options.nyx."nyx-tui" = {
|
||||
enable = lib.mkEnableOption "Enable nyx-tui script";
|
||||
|
||||
enableAlias = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
|
|
@ -32,14 +33,12 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf ((nyxCfg.enable or false) && (cfg.enable or false)) {
|
||||
home.packages = [
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "nyx-tui" tuiScript)
|
||||
];
|
||||
|
||||
home.shellAliases = lib.mkIf (cfg.enableAlias or true) {
|
||||
environment.shellAliases = lib.mkIf (cfg.enableAlias or true) {
|
||||
nyx = "nyx-tui";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue