Merge pull request #55 from cnsta/openesesel
cleanup script changes and fixing openssl
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Script to clean up old initrd and kernel files in /boot/EFI/nixos
|
# Script to clean up old initrd and kernel files in /boot/EFI/nixos
|
||||||
#
|
#
|
||||||
@@ -8,11 +8,23 @@
|
|||||||
# nix run .#cleanup-boot -- --dry-run
|
# nix run .#cleanup-boot -- --dry-run
|
||||||
# The '--' is required to pass arguments to the script.
|
# The '--' is required to pass arguments to the script.
|
||||||
#
|
#
|
||||||
# This script keeps the latest N kernel/initrd pairs (entries).
|
# This script keeps the latest N versions and allows you to specify how many
|
||||||
# Each entry consists of a kernel and an initrd file identified by the same version number.
|
# kernel/initrd files to keep per version.
|
||||||
|
|
||||||
# Default number of entries to keep
|
# Exit on any error, undefined variable, or pipeline failure
|
||||||
KEEP_ENTRIES=4
|
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 for cleanup actions
|
||||||
LOG_FILE="/var/log/cleanup-boot.log"
|
LOG_FILE="/var/log/cleanup-boot.log"
|
||||||
@@ -20,24 +32,21 @@ LOG_FILE="/var/log/cleanup-boot.log"
|
|||||||
# Dry run flag
|
# Dry run flag
|
||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
|
|
||||||
# Include incomplete entries flag
|
|
||||||
INCLUDE_INCOMPLETE=false
|
|
||||||
|
|
||||||
# Function to display usage information
|
# Function to display usage information
|
||||||
usage() {
|
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
|
||||||
echo "Note: When running with 'nix run', use '--' before script arguments."
|
echo "Note: When running with 'nix run', use '--' before script arguments."
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --dry-run Perform a trial run with no changes made."
|
echo " --dry-run Perform a trial run with no changes made."
|
||||||
echo " --keep N Keep the latest N kernel/initrd pairs (default: 4)."
|
echo " --keep N Keep the latest N versions (default: 4)."
|
||||||
echo " --include-incomplete Include incomplete entries in deletion."
|
echo " --keep-per-version M Keep the latest M files per version (default: keep all)."
|
||||||
echo " --help, -h Show this help message."
|
echo " --help, -h Show this help message."
|
||||||
echo
|
echo
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo " nix run .#cleanup-boot -- --dry-run"
|
echo " nix run .#cleanup-boot -- --dry-run"
|
||||||
echo " ./result --keep 5"
|
echo " ./result --keep 5 --keep-per-version 2"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,16 +57,22 @@ while [[ "$#" -gt 0 ]]; do
|
|||||||
DRY_RUN=true
|
DRY_RUN=true
|
||||||
;;
|
;;
|
||||||
--keep)
|
--keep)
|
||||||
if [[ -n "${2:-}" && "$2" =~ ^[0-9]+$ ]]; then
|
if [[ -n "${2:-}" && "$2" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
KEEP_ENTRIES="$2"
|
KEEP_VERSIONS="$2"
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
echo "Error: --keep requires a numeric argument."
|
echo "Error: --keep requires a positive integer."
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--include-incomplete)
|
--keep-per-version)
|
||||||
INCLUDE_INCOMPLETE=true
|
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)
|
--help | -h)
|
||||||
usage
|
usage
|
||||||
@@ -70,9 +85,6 @@ while [[ "$#" -gt 0 ]]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Exit on any error, undefined variable, or pipeline failure
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Check for root privileges
|
# Check for root privileges
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
echo "Error: Please run as root."
|
echo "Error: Please run as root."
|
||||||
@@ -87,123 +99,184 @@ fi
|
|||||||
|
|
||||||
# Function to log messages with timestamps
|
# Function to log messages with timestamps
|
||||||
log() {
|
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
|
# 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
|
# Parse filenames to group kernel and initrd files by their version number
|
||||||
for file in "${efi_files[@]}"; do
|
for file in "${efi_files[@]}"; do
|
||||||
basename=$(basename "$file")
|
basename=$(basename "$file")
|
||||||
# Extract the version number
|
|
||||||
if [[ "$basename" =~ ^(initrd|kernel)-(.*)-(.*)\.efi$ ]]; then
|
# Pattern 1: <hash>-linux-<version>-bzImage.efi (kernel)
|
||||||
type="${BASH_REMATCH[1]}"
|
if [[ "$basename" =~ ^(.*)-linux-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-bzImage\.efi$ ]]; then
|
||||||
version="${BASH_REMATCH[2]}"
|
version="${BASH_REMATCH[2]}"
|
||||||
# hash="${BASH_REMATCH[3]}" # Removed unused variable
|
type="kernel"
|
||||||
elif [[ "$basename" =~ ^(.*)-(.*)-(initrd|kernel)\.efi$ ]]; then
|
|
||||||
# hash="${BASH_REMATCH[1]}" # Removed unused variable
|
# 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]}"
|
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
|
else
|
||||||
log "Warning: Unrecognized filename format: $basename"
|
log "Warning: Unrecognized filename format: $basename"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
key="$version"
|
# Get file modification time
|
||||||
entries["$key,$type"]="$file"
|
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
|
# Append the file to the list of files per version and type
|
||||||
file_mtime=$(stat -c '%Y' "$file")
|
entry="$file_mtime|$file"
|
||||||
existing_mtime="${entries["$key,mtime"]:-}"
|
if [[ "$type" == "kernel" ]]; then
|
||||||
if [[ -z "$existing_mtime" ]] || [[ "$file_mtime" -lt "$existing_mtime" ]]; then
|
kernels_files_by_version["$version"]+="$entry"$'\n'
|
||||||
entries["$key,mtime"]="$file_mtime"
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Decide whether to include incomplete entries
|
# Collect all versions
|
||||||
declare -A valid_entries
|
all_versions=("${!versions_mtime[@]}")
|
||||||
|
|
||||||
if [ "$INCLUDE_INCOMPLETE" = true ]; then
|
# Sort versions by their latest modification time (newest first)
|
||||||
# Include all entries
|
mapfile -t sorted_versions < <(
|
||||||
for key in "${!entries[@]}"; do
|
for version in "${all_versions[@]}"; do
|
||||||
if [[ "$key" =~ ,mtime$ ]]; then
|
echo "${versions_mtime[$version]}:$version"
|
||||||
version="${key%,mtime}"
|
done | sort -rn -k1,1 | awk -F: '{print $2}'
|
||||||
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}'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove duplicates
|
version_count=${#sorted_versions[@]}
|
||||||
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
|
|
||||||
|
|
||||||
entry_count=${#unique_versions[@]}
|
log "Found $version_count versions."
|
||||||
|
|
||||||
log "Found $entry_count kernel/initrd pairs."
|
if [ "$version_count" -le "$KEEP_VERSIONS" ]; then
|
||||||
|
log "Fewer than or equal to $KEEP_VERSIONS versions found. No files will be deleted."
|
||||||
if [ "$entry_count" -le "$KEEP_ENTRIES" ]; then
|
|
||||||
log "Fewer than or equal to $KEEP_ENTRIES pairs found. No files will be deleted."
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine entries to delete
|
# Determine versions to delete
|
||||||
entries_to_delete=("${unique_versions[@]:$KEEP_ENTRIES}")
|
versions_to_delete=("${sorted_versions[@]:$KEEP_VERSIONS}")
|
||||||
|
|
||||||
|
# Initialize delete_files array
|
||||||
|
delete_files=()
|
||||||
|
|
||||||
# Log the files identified for deletion
|
# Log the files identified for deletion
|
||||||
log "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
|
# Process versions to delete
|
||||||
delete_files+=("$initrd_file")
|
for version in "${versions_to_delete[@]}"; do
|
||||||
log "$initrd_file"
|
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
|
fi
|
||||||
if [ -n "$kernel_file" ]; then
|
|
||||||
delete_files+=("$kernel_file")
|
|
||||||
log "$kernel_file"
|
|
||||||
fi
|
fi
|
||||||
done
|
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
|
# Confirm dry run mode
|
||||||
if [ "$DRY_RUN" = true ]; then
|
if [ "$DRY_RUN" = true ]; then
|
||||||
log "Dry run mode enabled. No files will be deleted."
|
log "Dry run mode enabled. No files will be deleted."
|
||||||
@@ -211,20 +284,22 @@ fi
|
|||||||
|
|
||||||
# Remove old files
|
# Remove old files
|
||||||
for file in "${delete_files[@]}"; do
|
for file in "${delete_files[@]}"; do
|
||||||
|
# Resolve absolute path
|
||||||
|
resolved_file=$(realpath "$file")
|
||||||
# Security check: Ensure the file is within /boot/EFI/nixos
|
# Security check: Ensure the file is within /boot/EFI/nixos
|
||||||
if [[ "$file" != /boot/EFI/nixos/* ]]; then
|
if [[ "$resolved_file" != /boot/EFI/nixos/* ]]; then
|
||||||
log "Warning: Attempted to delete file outside of /boot/EFI/nixos: $file"
|
log "Warning: Attempted to delete file outside of /boot/EFI/nixos: $resolved_file"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DRY_RUN" = false ]; then
|
if [ "$DRY_RUN" = false ]; then
|
||||||
if rm -f "$file"; then
|
if rm -f -- "$resolved_file"; then
|
||||||
log "Deleted: $file"
|
log "Deleted: $resolved_file"
|
||||||
else
|
else
|
||||||
log "Failed to delete: $file"
|
log "Failed to delete: $resolved_file"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log "Dry run - would delete: $file"
|
log "Dry run - would delete: $resolved_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
157
flake.lock
generated
157
flake.lock
generated
@@ -133,6 +133,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"crane_2": {
|
"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": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"lanzaboote",
|
"lanzaboote",
|
||||||
@@ -460,7 +481,25 @@
|
|||||||
},
|
},
|
||||||
"flake-utils_5": {
|
"flake-utils_5": {
|
||||||
"inputs": {
|
"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": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1710146030,
|
||||||
@@ -569,6 +608,27 @@
|
|||||||
"type": "github"
|
"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": {
|
"hercules-ci-effects": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": [
|
"flake-parts": [
|
||||||
@@ -725,8 +785,8 @@
|
|||||||
"hyprlang": "hyprlang",
|
"hyprlang": "hyprlang",
|
||||||
"hyprutils": "hyprutils",
|
"hyprutils": "hyprutils",
|
||||||
"hyprwayland-scanner": "hyprwayland-scanner",
|
"hyprwayland-scanner": "hyprwayland-scanner",
|
||||||
"nixpkgs": "nixpkgs_5",
|
"nixpkgs": "nixpkgs_6",
|
||||||
"systems": "systems_5",
|
"systems": "systems_6",
|
||||||
"xdph": "xdph"
|
"xdph": "xdph"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
@@ -988,12 +1048,12 @@
|
|||||||
},
|
},
|
||||||
"lanzaboote": {
|
"lanzaboote": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"crane": "crane_2",
|
"crane": "crane_3",
|
||||||
"flake-compat": "flake-compat_3",
|
"flake-compat": "flake-compat_3",
|
||||||
"flake-parts": "flake-parts_3",
|
"flake-parts": "flake-parts_3",
|
||||||
"nixpkgs": "nixpkgs_6",
|
"nixpkgs": "nixpkgs_7",
|
||||||
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
|
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
|
||||||
"rust-overlay": "rust-overlay_2"
|
"rust-overlay": "rust-overlay_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725379389,
|
"lastModified": 1725379389,
|
||||||
@@ -1047,7 +1107,7 @@
|
|||||||
},
|
},
|
||||||
"microfetch": {
|
"microfetch": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_7"
|
"nixpkgs": "nixpkgs_8"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1723918449,
|
"lastModified": 1723918449,
|
||||||
@@ -1262,6 +1322,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_5": {
|
"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": {
|
"locked": {
|
||||||
"lastModified": 1725983898,
|
"lastModified": 1725983898,
|
||||||
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
|
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
|
||||||
@@ -1277,7 +1353,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_6": {
|
"nixpkgs_7": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722264024,
|
"lastModified": 1722264024,
|
||||||
"narHash": "sha256-gomyYQrlOltr2/prDRikRDQoPz+J5Qq6SEJrqVC5x2c=",
|
"narHash": "sha256-gomyYQrlOltr2/prDRikRDQoPz+J5Qq6SEJrqVC5x2c=",
|
||||||
@@ -1293,7 +1369,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_7": {
|
"nixpkgs_8": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722719969,
|
"lastModified": 1722719969,
|
||||||
"narHash": "sha256-E47qbT/mRtBCSZra+9S9208sp/QnNeOAq7EhHX+eMNE=",
|
"narHash": "sha256-E47qbT/mRtBCSZra+9S9208sp/QnNeOAq7EhHX+eMNE=",
|
||||||
@@ -1308,7 +1384,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_8": {
|
"nixpkgs_9": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726062873,
|
"lastModified": 1726062873,
|
||||||
"narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=",
|
"narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=",
|
||||||
@@ -1364,6 +1440,7 @@
|
|||||||
"flake-utils": "flake-utils_3",
|
"flake-utils": "flake-utils_3",
|
||||||
"hardware": "hardware",
|
"hardware": "hardware",
|
||||||
"helix": "helix",
|
"helix": "helix",
|
||||||
|
"helix-flake": "helix-flake",
|
||||||
"hm": "hm",
|
"hm": "hm",
|
||||||
"hypridle": "hypridle",
|
"hypridle": "hypridle",
|
||||||
"hyprland": "hyprland",
|
"hyprland": "hyprland",
|
||||||
@@ -1374,9 +1451,9 @@
|
|||||||
"microfetch": "microfetch",
|
"microfetch": "microfetch",
|
||||||
"nix-gaming": "nix-gaming",
|
"nix-gaming": "nix-gaming",
|
||||||
"nixpak": "nixpak",
|
"nixpak": "nixpak",
|
||||||
"nixpkgs": "nixpkgs_8",
|
"nixpkgs": "nixpkgs_9",
|
||||||
"nixpkgs-small": "nixpkgs-small",
|
"nixpkgs-small": "nixpkgs-small",
|
||||||
"systems": "systems_6",
|
"systems": "systems_7",
|
||||||
"wezterm": "wezterm"
|
"wezterm": "wezterm"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1440,6 +1517,31 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay_2": {
|
"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": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"lanzaboote",
|
"lanzaboote",
|
||||||
@@ -1460,7 +1562,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay_3": {
|
"rust-overlay_4": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"wezterm",
|
"wezterm",
|
||||||
@@ -1543,16 +1645,16 @@
|
|||||||
},
|
},
|
||||||
"systems_5": {
|
"systems_5": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689347949,
|
"lastModified": 1681028828,
|
||||||
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
"owner": "nix-systems",
|
"owner": "nix-systems",
|
||||||
"repo": "default-linux",
|
"repo": "default",
|
||||||
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"owner": "nix-systems",
|
||||||
"repo": "default-linux",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1572,6 +1674,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_7": {
|
"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": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
@@ -1613,14 +1730,14 @@
|
|||||||
},
|
},
|
||||||
"wezterm": {
|
"wezterm": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils_5",
|
"flake-utils": "flake-utils_6",
|
||||||
"freetype2": "freetype2",
|
"freetype2": "freetype2",
|
||||||
"harfbuzz": "harfbuzz",
|
"harfbuzz": "harfbuzz",
|
||||||
"libpng": "libpng",
|
"libpng": "libpng",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"rust-overlay": "rust-overlay_3",
|
"rust-overlay": "rust-overlay_4",
|
||||||
"zlib": "zlib"
|
"zlib": "zlib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|||||||
@@ -96,6 +96,8 @@
|
|||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
helix.url = "github:SoraTenshi/helix/new-daily-driver";
|
helix.url = "github:SoraTenshi/helix/new-daily-driver";
|
||||||
|
helix-flake.url = "github:helix-editor/helix";
|
||||||
|
|
||||||
nix-gaming = {
|
nix-gaming = {
|
||||||
url = "github:fufexan/nix-gaming";
|
url = "github:fufexan/nix-gaming";
|
||||||
inputs = {
|
inputs = {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ in {
|
|||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.helix = {
|
programs.helix = {
|
||||||
enable = true;
|
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 = {
|
settings = {
|
||||||
theme = "gruvbox_custom";
|
theme = "gruvbox_custom";
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
# Check if we're in a nix-shell or nix develop environment
|
# Check if we're in a nix-shell or nix develop environment
|
||||||
if [[ -n "$IN_NIX_SHELL" ]]; then
|
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}$ '
|
%F{143}$ '
|
||||||
else
|
else
|
||||||
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
|
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
|
||||||
|
|||||||
@@ -7,18 +7,18 @@
|
|||||||
syntaxHighlighting.enable = true;
|
syntaxHighlighting.enable = true;
|
||||||
|
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
usermodules = "nvim /home/toothpick/.nix-config/home/users/toothpick/modules.nix";
|
usermodules = "$EDITOR /home/$USER/.nix-config/home/users/$USER/modules.nix";
|
||||||
umod = "nvim /home/toothpick/.nix-config/home/users/toothpick/modules.nix";
|
umod = "$EDITOR /home/$USER/.nix-config/home/users/$USER/modules.nix";
|
||||||
systemmodules = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
|
systemmodules = "$EDITOR /home/$USER/.nix-config/hosts/$HOST/modules.nix";
|
||||||
smod = "nvim /home/toothpick/.nix-config/hosts/toothpc/modules.nix";
|
smod = "$EDITOR /home/$USER/.nix-config/hosts/$HOST/modules.nix";
|
||||||
nixclean = "sudo nix run /home/toothpick/.nix-config#cleanup-boot";
|
nixclean = "sudo nix run /home/$USER/.nix-config#cleanup-boot";
|
||||||
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
||||||
nixconfig = "cd /home/toothpick/.nix-config/";
|
nixconfig = "cd /home/$USER/.nix-config/";
|
||||||
ll = "ls -l";
|
ll = "ls -l";
|
||||||
nixupdate = "nh os switch -v -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 toothpc && sudo nix run /home/toothpick/.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 toothpc && sudo nix run /home/toothpick/.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 toothpc && sudo nix run /home/toothpick/.nix-config#cleanup-boot";
|
flakeup = "nh os switch -u -H $HOST && sudo nix run /home/$USER/.nix-config#cleanup-boot";
|
||||||
};
|
};
|
||||||
history = {
|
history = {
|
||||||
size = 1000;
|
size = 1000;
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
# Check if we're in a nix-shell or nix develop environment
|
# Check if we're in a nix-shell or nix develop environment
|
||||||
if [[ -n "$IN_NIX_SHELL" ]]; then
|
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}$ '
|
%F{143}$ '
|
||||||
else
|
else
|
||||||
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
|
PROMPT='%F{143}%~%f $(git_prompt_info)$(virtualenv_prompt_info)
|
||||||
|
|||||||
@@ -2,23 +2,41 @@
|
|||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
|
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
|
||||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
# Wayland-specific dependencies
|
# Build tools
|
||||||
wayland # Wayland client library
|
cmake # Build system generator
|
||||||
wayland-protocols # Wayland protocols (essential for building against Wayland)
|
gnumake # GNU Make
|
||||||
pkg-config # Helps to manage libraries during compilation
|
pkg-config # Manages library paths during compilation
|
||||||
|
perl # Scripting language, sometimes needed during builds
|
||||||
|
|
||||||
# Aquamarine: Hyprland's new compositor library
|
# Version control
|
||||||
aquamarine # Aquamarine compositor library for Wayland
|
git # Version control system
|
||||||
|
|
||||||
# Other utilities and tools
|
# Auto-patching (include if needed)
|
||||||
openssl # Required for some crates that involve networking or encryption
|
autoPatchelfHook # Automatically patches ELF binaries
|
||||||
git # Version control system, useful for development
|
|
||||||
|
# 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 = ''
|
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
|
# Set SHELL to zsh if available
|
||||||
export SHELL=$(which zsh)
|
export SHELL=$(which zsh)
|
||||||
# Optionally, start zsh directly if it's not the current shell
|
|
||||||
if [ "$SHELL" != "$(which zsh)" ]; then
|
if [ "$SHELL" != "$(which zsh)" ]; then
|
||||||
exec $SHELL
|
exec $SHELL
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user