Merge pull request #55 from cnsta/openesesel

cleanup script changes and fixing openssl
This commit is contained in:
cnsta
2024-09-15 10:52:47 +02:00
committed by GitHub
7 changed files with 363 additions and 150 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Script to clean up old initrd and kernel files in /boot/EFI/nixos
#
@@ -8,11 +8,23 @@
# nix run .#cleanup-boot -- --dry-run
# The '--' is required to pass arguments to the script.
#
# This script keeps the latest N kernel/initrd pairs (entries).
# Each entry consists of a kernel and an initrd file identified by the same version number.
# This script keeps the latest N versions and allows you to specify how many
# kernel/initrd files to keep per version.
# Default number of entries to keep
KEEP_ENTRIES=4
# Exit on any error, undefined variable, or pipeline failure
set -euo pipefail
# Ensure Bash 4 or newer is being used
if ((BASH_VERSINFO[0] < 4)); then
echo "Error: This script requires Bash version 4 or higher."
exit 1
fi
# Default number of versions to keep
KEEP_VERSIONS=4
# Default number of files to keep per version (0 means keep all)
KEEP_FILES_PER_VERSION=0
# Log file for cleanup actions
LOG_FILE="/var/log/cleanup-boot.log"
@@ -20,24 +32,21 @@ LOG_FILE="/var/log/cleanup-boot.log"
# Dry run flag
DRY_RUN=false
# Include incomplete entries flag
INCLUDE_INCOMPLETE=false
# Function to display usage information
usage() {
echo "Usage: $0 [--dry-run] [--keep N] [--include-incomplete] [--help]"
echo "Usage: $0 [--dry-run] [--keep N] [--keep-per-version M] [--help]"
echo
echo "Note: When running with 'nix run', use '--' before script arguments."
echo
echo "Options:"
echo " --dry-run Perform a trial run with no changes made."
echo " --keep N Keep the latest N kernel/initrd pairs (default: 4)."
echo " --include-incomplete Include incomplete entries in deletion."
echo " --keep N Keep the latest N versions (default: 4)."
echo " --keep-per-version M Keep the latest M files per version (default: keep all)."
echo " --help, -h Show this help message."
echo
echo "Examples:"
echo " nix run .#cleanup-boot -- --dry-run"
echo " ./result --keep 5"
echo " ./result --keep 5 --keep-per-version 2"
exit 1
}
@@ -48,16 +57,22 @@ while [[ "$#" -gt 0 ]]; do
DRY_RUN=true
;;
--keep)
if [[ -n "${2:-}" && "$2" =~ ^[0-9]+$ ]]; then
KEEP_ENTRIES="$2"
if [[ -n "${2:-}" && "$2" =~ ^[1-9][0-9]*$ ]]; then
KEEP_VERSIONS="$2"
shift
else
echo "Error: --keep requires a numeric argument."
echo "Error: --keep requires a positive integer."
usage
fi
;;
--include-incomplete)
INCLUDE_INCOMPLETE=true
--keep-per-version)
if [[ -n "${2:-}" && "$2" =~ ^[0-9]+$ ]]; then
KEEP_FILES_PER_VERSION="$2"
shift
else
echo "Error: --keep-per-version requires a non-negative integer."
usage
fi
;;
--help | -h)
usage
@@ -70,9 +85,6 @@ while [[ "$#" -gt 0 ]]; do
shift
done
# Exit on any error, undefined variable, or pipeline failure
set -euo pipefail
# Check for root privileges
if [ "$EUID" -ne 0 ]; then
echo "Error: Please run as root."
@@ -87,123 +99,184 @@ fi
# Function to log messages with timestamps
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
local message
message="$(date '+%Y-%m-%d %H:%M:%S') - $1"
echo "$message" | tee -a "$LOG_FILE"
logger -t cleanup-boot "$message"
}
log "Starting cleanup script. Keeping the latest $KEEP_ENTRIES kernel/initrd pairs."
log "Starting cleanup script. Keeping the latest $KEEP_VERSIONS versions."
if [ "$KEEP_FILES_PER_VERSION" -gt 0 ]; then
log "Keeping the latest $KEEP_FILES_PER_VERSION files per version."
else
log "Keeping all files per version."
fi
# Collect all .efi files in /boot/EFI/nixos
mapfile -t efi_files < <(find /boot/EFI/nixos -type f -name '*.efi')
mapfile -d '' -t efi_files < <(find /boot/EFI/nixos -type f -name '*.efi' -print0)
declare -A entries
declare -A kernels_files_by_version
declare -A initrds_files_by_version
declare -A versions_mtime
# Parse filenames to group kernel and initrd files by their version number
for file in "${efi_files[@]}"; do
basename=$(basename "$file")
# Extract the version number
if [[ "$basename" =~ ^(initrd|kernel)-(.*)-(.*)\.efi$ ]]; then
type="${BASH_REMATCH[1]}"
# Pattern 1: <hash>-linux-<version>-bzImage.efi (kernel)
if [[ "$basename" =~ ^(.*)-linux-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-bzImage\.efi$ ]]; then
version="${BASH_REMATCH[2]}"
# hash="${BASH_REMATCH[3]}" # Removed unused variable
elif [[ "$basename" =~ ^(.*)-(.*)-(initrd|kernel)\.efi$ ]]; then
# hash="${BASH_REMATCH[1]}" # Removed unused variable
type="kernel"
# Pattern 1: <hash>-initrd-linux-<version>-initrd.efi (initrd)
elif [[ "$basename" =~ ^(.*)-initrd-linux-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-initrd\.efi$ ]]; then
version="${BASH_REMATCH[2]}"
type="${BASH_REMATCH[3]}"
type="initrd"
# Pattern 2: kernel-<version>-<hash>.efi (kernel)
elif [[ "$basename" =~ ^kernel-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-([a-zA-Z0-9]+)\.efi$ ]]; then
version="${BASH_REMATCH[1]}"
type="kernel"
# Pattern 2: initrd-<version>-<hash>.efi (initrd)
elif [[ "$basename" =~ ^initrd-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-([a-zA-Z0-9]+)\.efi$ ]]; then
version="${BASH_REMATCH[1]}"
type="initrd"
else
log "Warning: Unrecognized filename format: $basename"
continue
fi
key="$version"
entries["$key,$type"]="$file"
# Get file modification time
if ! file_mtime=$(stat -c '%Y' "$file" 2>/dev/null); then
log "Warning: Failed to get modification time for $file"
continue
fi
# Store the earliest modification time among kernel and initrd
file_mtime=$(stat -c '%Y' "$file")
existing_mtime="${entries["$key,mtime"]:-}"
if [[ -z "$existing_mtime" ]] || [[ "$file_mtime" -lt "$existing_mtime" ]]; then
entries["$key,mtime"]="$file_mtime"
# Append the file to the list of files per version and type
entry="$file_mtime|$file"
if [[ "$type" == "kernel" ]]; then
kernels_files_by_version["$version"]+="$entry"$'\n'
elif [[ "$type" == "initrd" ]]; then
initrds_files_by_version["$version"]+="$entry"$'\n'
fi
# Update the latest modification time for the version
version_mtime="${versions_mtime["$version"]:-0}"
if [[ "$file_mtime" -gt "$version_mtime" ]]; then
versions_mtime["$version"]="$file_mtime"
fi
done
# Decide whether to include incomplete entries
declare -A valid_entries
# Collect all versions
all_versions=("${!versions_mtime[@]}")
if [ "$INCLUDE_INCOMPLETE" = true ]; then
# Include all entries
for key in "${!entries[@]}"; do
if [[ "$key" =~ ,mtime$ ]]; then
version="${key%,mtime}"
valid_entries["$version,initrd"]="${entries["$version,initrd"]:-}"
valid_entries["$version,kernel"]="${entries["$version,kernel"]:-}"
valid_entries["$version,mtime"]="${entries["$version,mtime"]}"
fi
done
else
# Include only complete entries
for key in "${!entries[@]}"; do
if [[ "$key" =~ ,mtime$ ]]; then
version="${key%,mtime}"
if [[ -n "${entries["$version,initrd"]:-}" && -n "${entries["$version,kernel"]:-}" ]]; then
valid_entries["$version,initrd"]="${entries["$version,initrd"]}"
valid_entries["$version,kernel"]="${entries["$version,kernel"]}"
valid_entries["$version,mtime"]="${entries["$version,mtime"]}"
else
log "Warning: Incomplete entry detected for version $version."
fi
fi
done
fi
# Sort the entries by modification time (newest first)
mapfile -t sorted_entries < <(
for key in "${!valid_entries[@]}"; do
if [[ "$key" =~ ,mtime$ ]]; then
version="${key%,mtime}"
mtime="${valid_entries[$key]}"
echo "$mtime:$version"
fi
done | sort -rn | awk -F: '{print $2}'
# Sort versions by their latest modification time (newest first)
mapfile -t sorted_versions < <(
for version in "${all_versions[@]}"; do
echo "${versions_mtime[$version]}:$version"
done | sort -rn -k1,1 | awk -F: '{print $2}'
)
# Remove duplicates
unique_versions=()
declare -A seen_versions
for version in "${sorted_entries[@]}"; do
if [[ -z "${seen_versions[$version]:-}" ]]; then
unique_versions+=("$version")
seen_versions["$version"]=1
fi
done
version_count=${#sorted_versions[@]}
entry_count=${#unique_versions[@]}
log "Found $version_count versions."
log "Found $entry_count kernel/initrd pairs."
if [ "$entry_count" -le "$KEEP_ENTRIES" ]; then
log "Fewer than or equal to $KEEP_ENTRIES pairs found. No files will be deleted."
if [ "$version_count" -le "$KEEP_VERSIONS" ]; then
log "Fewer than or equal to $KEEP_VERSIONS versions found. No files will be deleted."
exit 0
fi
# Determine entries to delete
entries_to_delete=("${unique_versions[@]:$KEEP_ENTRIES}")
# Determine versions to delete
versions_to_delete=("${sorted_versions[@]:$KEEP_VERSIONS}")
# Initialize delete_files array
delete_files=()
# Log the files identified for deletion
log "Files identified for deletion:"
delete_files=()
for version in "${entries_to_delete[@]}"; do
initrd_file="${valid_entries["$version,initrd"]:-}"
kernel_file="${valid_entries["$version,kernel"]:-}"
if [ -n "$initrd_file" ]; then
delete_files+=("$initrd_file")
log "$initrd_file"
# Process versions to delete
for version in "${versions_to_delete[@]}"; do
kernel_files="${kernels_files_by_version["$version"]:-}"
initrd_files="${initrds_files_by_version["$version"]:-}"
# Delete all kernel files
if [ -n "$kernel_files" ]; then
IFS=''
mapfile -t kernel_files_array <<<"$kernel_files"
unset IFS
if [ "${#kernel_files_array[@]}" -gt 0 ]; then
for entry in "${kernel_files_array[@]}"; do
file="${entry#*|}"
delete_files+=("$file")
log "$file"
done
fi
fi
# Delete all initrd files
if [ -n "$initrd_files" ]; then
IFS=''
mapfile -t initrd_files_array <<<"$initrd_files"
unset IFS
if [ "${#initrd_files_array[@]}" -gt 0 ]; then
for entry in "${initrd_files_array[@]}"; do
file="${entry#*|}"
delete_files+=("$file")
log "$file"
done
fi
if [ -n "$kernel_file" ]; then
delete_files+=("$kernel_file")
log "$kernel_file"
fi
done
# Process versions to keep
for version in "${sorted_versions[@]:0:$KEEP_VERSIONS}"; do
# Process kernel files
kernel_files="${kernels_files_by_version["$version"]:-}"
if [ -n "$kernel_files" ]; then
IFS=''
mapfile -t kernel_files_array <<<"$kernel_files"
unset IFS
# Sort kernel files by mtime and filename (newest first)
mapfile -t sorted_kernel_files < <(printf '%s\n' "${kernel_files_array[@]}" | sort -rn -k1,1 -k2,2)
kernel_file_count=${#sorted_kernel_files[@]}
if [ "$KEEP_FILES_PER_VERSION" -gt 0 ] && [ "$kernel_file_count" -gt "$KEEP_FILES_PER_VERSION" ]; then
files_to_delete=("${sorted_kernel_files[@]:$KEEP_FILES_PER_VERSION}")
for entry in "${files_to_delete[@]}"; do
file="${entry#*|}"
delete_files+=("$file")
log "$file"
done
fi
fi
# Process initrd files
initrd_files="${initrds_files_by_version["$version"]:-}"
if [ -n "$initrd_files" ]; then
IFS=''
mapfile -t initrd_files_array <<<"$initrd_files"
unset IFS
# Sort initrd files by mtime and filename (newest first)
mapfile -t sorted_initrd_files < <(printf '%s\n' "${initrd_files_array[@]}" | sort -rn -k1,1 -k2,2)
initrd_file_count=${#sorted_initrd_files[@]}
if [ "$KEEP_FILES_PER_VERSION" -gt 0 ] && [ "$initrd_file_count" -gt "$KEEP_FILES_PER_VERSION" ]; then
files_to_delete=("${sorted_initrd_files[@]:$KEEP_FILES_PER_VERSION}")
for entry in "${files_to_delete[@]}"; do
file="${entry#*|}"
delete_files+=("$file")
log "$file"
done
fi
fi
done
if [ ${#delete_files[@]} -eq 0 ]; then
log "No files to delete."
exit 0
fi
# Confirm dry run mode
if [ "$DRY_RUN" = true ]; then
log "Dry run mode enabled. No files will be deleted."
@@ -211,20 +284,22 @@ fi
# Remove old files
for file in "${delete_files[@]}"; do
# Resolve absolute path
resolved_file=$(realpath "$file")
# Security check: Ensure the file is within /boot/EFI/nixos
if [[ "$file" != /boot/EFI/nixos/* ]]; then
log "Warning: Attempted to delete file outside of /boot/EFI/nixos: $file"
if [[ "$resolved_file" != /boot/EFI/nixos/* ]]; then
log "Warning: Attempted to delete file outside of /boot/EFI/nixos: $resolved_file"
continue
fi
if [ "$DRY_RUN" = false ]; then
if rm -f "$file"; then
log "Deleted: $file"
if rm -f -- "$resolved_file"; then
log "Deleted: $resolved_file"
else
log "Failed to delete: $file"
log "Failed to delete: $resolved_file"
fi
else
log "Dry run - would delete: $file"
log "Dry run - would delete: $resolved_file"
fi
done

157
flake.lock generated
View File

@@ -133,6 +133,27 @@
}
},
"crane_2": {
"inputs": {
"nixpkgs": [
"helix-flake",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709610799,
"narHash": "sha256-5jfLQx0U9hXbi2skYMGodDJkIgffrjIOgMRjZqms2QE=",
"owner": "ipetkov",
"repo": "crane",
"rev": "81c393c776d5379c030607866afef6406ca1be57",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"crane_3": {
"inputs": {
"nixpkgs": [
"lanzaboote",
@@ -460,7 +481,25 @@
},
"flake-utils_5": {
"inputs": {
"systems": "systems_7"
"systems": "systems_5"
},
"locked": {
"lastModified": 1709126324,
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_6": {
"inputs": {
"systems": "systems_8"
},
"locked": {
"lastModified": 1710146030,
@@ -569,6 +608,27 @@
"type": "github"
}
},
"helix-flake": {
"inputs": {
"crane": "crane_2",
"flake-utils": "flake-utils_5",
"nixpkgs": "nixpkgs_5",
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1725976743,
"narHash": "sha256-pLQQbiC9uO4lF58fAnlcDxlbsBB1XFWswsU1oZOIVqU=",
"owner": "helix-editor",
"repo": "helix",
"rev": "237cbe4bca46eed52efed39ed75eb44aaccbdde3",
"type": "github"
},
"original": {
"owner": "helix-editor",
"repo": "helix",
"type": "github"
}
},
"hercules-ci-effects": {
"inputs": {
"flake-parts": [
@@ -725,8 +785,8 @@
"hyprlang": "hyprlang",
"hyprutils": "hyprutils",
"hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": "nixpkgs_5",
"systems": "systems_5",
"nixpkgs": "nixpkgs_6",
"systems": "systems_6",
"xdph": "xdph"
},
"locked": {
@@ -988,12 +1048,12 @@
},
"lanzaboote": {
"inputs": {
"crane": "crane_2",
"crane": "crane_3",
"flake-compat": "flake-compat_3",
"flake-parts": "flake-parts_3",
"nixpkgs": "nixpkgs_6",
"nixpkgs": "nixpkgs_7",
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
"rust-overlay": "rust-overlay_2"
"rust-overlay": "rust-overlay_3"
},
"locked": {
"lastModified": 1725379389,
@@ -1047,7 +1107,7 @@
},
"microfetch": {
"inputs": {
"nixpkgs": "nixpkgs_7"
"nixpkgs": "nixpkgs_8"
},
"locked": {
"lastModified": 1723918449,
@@ -1262,6 +1322,22 @@
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1709479366,
"narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b8697e57f10292a6165a20f03d2f42920dfaf973",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1725983898,
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
@@ -1277,7 +1353,7 @@
"type": "github"
}
},
"nixpkgs_6": {
"nixpkgs_7": {
"locked": {
"lastModified": 1722264024,
"narHash": "sha256-gomyYQrlOltr2/prDRikRDQoPz+J5Qq6SEJrqVC5x2c=",
@@ -1293,7 +1369,7 @@
"type": "github"
}
},
"nixpkgs_7": {
"nixpkgs_8": {
"locked": {
"lastModified": 1722719969,
"narHash": "sha256-E47qbT/mRtBCSZra+9S9208sp/QnNeOAq7EhHX+eMNE=",
@@ -1308,7 +1384,7 @@
"type": "github"
}
},
"nixpkgs_8": {
"nixpkgs_9": {
"locked": {
"lastModified": 1726062873,
"narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=",
@@ -1364,6 +1440,7 @@
"flake-utils": "flake-utils_3",
"hardware": "hardware",
"helix": "helix",
"helix-flake": "helix-flake",
"hm": "hm",
"hypridle": "hypridle",
"hyprland": "hyprland",
@@ -1374,9 +1451,9 @@
"microfetch": "microfetch",
"nix-gaming": "nix-gaming",
"nixpak": "nixpak",
"nixpkgs": "nixpkgs_8",
"nixpkgs": "nixpkgs_9",
"nixpkgs-small": "nixpkgs-small",
"systems": "systems_6",
"systems": "systems_7",
"wezterm": "wezterm"
}
},
@@ -1440,6 +1517,31 @@
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"helix-flake",
"flake-utils"
],
"nixpkgs": [
"helix-flake",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709604635,
"narHash": "sha256-le4fwmWmjGRYWwkho0Gr7mnnZndOOe4XGbLw68OvF40=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "e86c0fb5d3a22a5f30d7f64ecad88643fe26449d",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_3": {
"inputs": {
"nixpkgs": [
"lanzaboote",
@@ -1460,7 +1562,7 @@
"type": "github"
}
},
"rust-overlay_3": {
"rust-overlay_4": {
"inputs": {
"nixpkgs": [
"wezterm",
@@ -1543,16 +1645,16 @@
},
"systems_5": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"repo": "default",
"type": "github"
}
},
@@ -1572,6 +1674,21 @@
}
},
"systems_7": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_8": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -1613,14 +1730,14 @@
},
"wezterm": {
"inputs": {
"flake-utils": "flake-utils_5",
"flake-utils": "flake-utils_6",
"freetype2": "freetype2",
"harfbuzz": "harfbuzz",
"libpng": "libpng",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay_3",
"rust-overlay": "rust-overlay_4",
"zlib": "zlib"
},
"locked": {

View File

@@ -96,6 +96,8 @@
# Miscellaneous
helix.url = "github:SoraTenshi/helix/new-daily-driver";
helix-flake.url = "github:helix-editor/helix";
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs = {

View File

@@ -20,7 +20,8 @@ in {
config = mkIf cfg.enable {
programs.helix = {
enable = true;
package = inputs.helix.packages.${pkgs.system}.default;
# package = inputs.helix.packages.${pkgs.system}.default;
package = inputs.helix-flake.packages.${pkgs.system}.default;
settings = {
theme = "gruvbox_custom";

View File

@@ -48,7 +48,7 @@
# Check if we're in a nix-shell or nix develop environment
if [[ -n "$IN_NIX_SHELL" ]]; then
PROMPT='%F{red}󰫱󰫲󰬃%f%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
PROMPT='%F{red}DEV%f%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
%F{143}$ '
else
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)

View File

@@ -7,18 +7,18 @@
syntaxHighlighting.enable = true;
shellAliases = {
usermodules = "nvim /home/toothpick/.nix-config/home/users/toothpick/modules.nix";
umod = "nvim /home/toothpick/.nix-config/home/users/toothpick/modules.nix";
systemmodules = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
smod = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
nixclean = "sudo nix run /home/toothpick/.nix-config#cleanup-boot";
usermodules = "$EDITOR /home/$USER/.nix-config/home/users/$USER/modules.nix";
umod = "$EDITOR /home/$USER/.nix-config/home/users/$USER/modules.nix";
systemmodules = "$EDITOR /home/$USER/.nix-config/hosts/$HOST/modules.nix";
smod = "$EDITOR /home/$USER/.nix-config/hosts/$HOST/modules.nix";
nixclean = "sudo nix run /home/$USER/.nix-config#cleanup-boot";
nixdev = "nix develop ~/.nix-config -c $SHELL";
nixconfig = "cd /home/toothpick/.nix-config/";
nixconfig = "cd /home/$USER/.nix-config/";
ll = "ls -l";
nixupdate = "nh os switch -v -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
nixup = "nh os switch -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
flakeupdate = "nh os switch -u -v -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
flakeup = "nh os switch -u -H toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
nixupdate = "nh os switch -v -H $HOST && sudo nix run /home/$USER/.nix-config#cleanup-boot";
nixup = "nh os switch -H $HOST && sudo nix run /home/$USER/.nix-config#cleanup-boot";
flakeupdate = "nh os switch -u -v -H $HOST && sudo nix run /home/$USER/.nix-config#cleanup-boot";
flakeup = "nh os switch -u -H $HOST && sudo nix run /home/$USER/.nix-config#cleanup-boot";
};
history = {
size = 1000;
@@ -49,7 +49,7 @@
# Check if we're in a nix-shell or nix develop environment
if [[ -n "$IN_NIX_SHELL" ]]; then
PROMPT='%F{red}󰫱󰫲󰬃%f%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
PROMPT='%F{red}DEV%f%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
%F{143}$ '
else
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)

View File

@@ -2,23 +2,41 @@
default = pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = with pkgs; [
# Wayland-specific dependencies
wayland # Wayland client library
wayland-protocols # Wayland protocols (essential for building against Wayland)
pkg-config # Helps to manage libraries during compilation
# Build tools
cmake # Build system generator
gnumake # GNU Make
pkg-config # Manages library paths during compilation
perl # Scripting language, sometimes needed during builds
# Aquamarine: Hyprland's new compositor library
aquamarine # Aquamarine compositor library for Wayland
# Version control
git # Version control system
# Other utilities and tools
openssl # Required for some crates that involve networking or encryption
git # Version control system, useful for development
# Auto-patching (include if needed)
autoPatchelfHook # Automatically patches ELF binaries
# Scripting languages (include if needed)
# nodejs # JavaScript runtime environment
];
buildInputs = with pkgs; [
# Graphics and UI libraries
aquamarine # Aquamarine compositor library for Wayland
egl-wayland # EGLStream-based Wayland platform
wayland # Wayland client library
wayland-protocols # Wayland protocols for Wayland applications
# Cryptography
openssl # TLS/SSL library for networking and encryption
];
shellHook = ''
# Set LD_LIBRARY_PATH if needed (temporary fix)
# export LD_LIBRARY_PATH="${pkgs.openssl.out}/lib:$LD_LIBRARY_PATH"
# Set SHELL to zsh if available
export SHELL=$(which zsh)
# Optionally, start zsh directly if it's not the current shell
if [ "$SHELL" != "$(which zsh)" ]; then
exec $SHELL
fi