small thunar and greetd changes and some refactoring

This commit is contained in:
cnst
2024-11-10 13:54:04 +01:00
parent dbba176430
commit df33d941cb
22 changed files with 77 additions and 202 deletions

View File

@@ -1,154 +0,0 @@
#!/usr/bin/env bash
# Script to clean up old initrd and kernel files in /boot/EFI/nixos
# Make sure it's added to flake.nix, then run:
# "nix build .#packages.x86_64-linux.cleanup-boot".
# Exit on any error, undefined variable, or pipeline failure
set -euo pipefail
# Default number of kernel and initrd files to keep
KEEP_KERNEL=4
KEEP_INITRD=6
# Log file for cleanup actions
LOG_FILE="/var/log/cleanup-boot.log"
# Dry run flag
DRY_RUN=false
# Function to display usage information
usage() {
echo "Usage: $0 [--dry-run] [--keep-kernel N] [--keep-initrd N] [--help]"
echo
echo "Options:"
echo " --dry-run Perform a trial run with no changes made."
echo " --keep-kernel N Keep the latest N kernel files (default: 4)."
echo " --keep-initrd N Keep the latest N initrd files (default: 6)."
echo " --help, -h Show this help message."
exit 1
}
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case "$1" in
--dry-run)
DRY_RUN=true
;;
--keep-kernel)
if [[ -n "${2:-}" && "$2" =~ ^[1-9][0-9]*$ ]]; then
KEEP_KERNEL="$2"
shift
else
echo "Error: --keep-kernel requires a positive integer."
usage
fi
;;
--keep-initrd)
if [[ -n "${2:-}" && "$2" =~ ^[1-9][0-9]*$ ]]; then
KEEP_INITRD="$2"
shift
else
echo "Error: --keep-initrd requires a positive integer."
usage
fi
;;
--help | -h)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
shift
done
# Check for root privileges
if [ "$EUID" -ne 0 ]; then
echo "Error: Please run as root."
exit 1
fi
# Check if log file is writable
if ! touch "$LOG_FILE" &>/dev/null; then
echo "Error: Cannot write to log file $LOG_FILE"
exit 1
fi
# Function to log messages with timestamps
log() {
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 $KEEP_KERNEL kernel files and $KEEP_INITRD initrd files."
# Collect all .efi files in /boot/EFI/nixos
mapfile -d '' -t efi_files < <(find /boot/EFI/nixos -type f -name '*.efi' -print0)
# Initialize arrays for kernel and initrd files
kernel_files=()
initrd_files=()
# Parse filenames and collect kernel and initrd files based on patterns
for file in "${efi_files[@]}"; do
basename=$(basename "$file")
# Pattern: <hash>-linux-<version>-bzImage.efi (kernel)
if [[ "$basename" =~ ^(.*)-linux-([0-9]+\.[0-9]+(\.[0-9]+)?)\-bzImage\.efi$ ]]; then
kernel_files+=("$file")
# Pattern: <hash>-initrd-linux-<version>-initrd.efi (initrd)
elif [[ "$basename" =~ ^(.*)-initrd-linux-([0-9]+\.[0-9]+(\.[0-9]+)?)\-initrd\.efi$ ]]; then
initrd_files+=("$file")
# Pattern: kernel-<version>-<hash>.efi (kernel)
elif [[ "$basename" =~ ^kernel-([0-9]+\.[0-9]+(\.[0-9]+)?)\-([a-zA-Z0-9\-]+)\.efi$ ]]; then
kernel_files+=("$file")
# Pattern: initrd-<version>-<hash>.efi (initrd)
elif [[ "$basename" =~ ^initrd-([0-9]+\.[0-9]+(\.[0-9]+)?)\-([a-zA-Z0-9\-]+)\.efi$ ]]; then
initrd_files+=("$file")
else
log "Warning: Unrecognized filename format: $basename"
continue
fi
done
# Function to process and delete old files
process_files() {
local -n files=$1 # Pass array by reference
local keep_count=$2
local file_type=$3
log "Processing $file_type files..."
if [ "${#files[@]}" -gt "$keep_count" ]; then
# Sort files by modification time (newest first)
sorted_files=$(for f in "${files[@]}"; do echo "$(stat -c '%Y' "$f"):$f"; done | sort -rn -k1,1)
# Collect files to delete (older than the top N)
mapfile -t files_to_delete < <(echo "$sorted_files" | tail -n +"$((keep_count + 1))" | cut -d: -f2)
for file in "${files_to_delete[@]}"; do
log "Deleting $file"
if [ "$DRY_RUN" = false ]; then
rm -f -- "$file"
else
log "Dry run - would delete: $file"
fi
done
else
log "No $file_type files to delete. Current count: ${#files[@]}"
fi
}
# Process kernel and initrd files
process_files kernel_files "$KEEP_KERNEL" "kernel"
process_files initrd_files "$KEEP_INITRD" "initrd"
log "Cleanup script completed."

View File

@@ -5,18 +5,18 @@ My NixOS daily driver. Built primarily for use with
prominent tools and apps: prominent tools and apps:
- [Chaotic's Nyx](https://www.nyx.chaotic.cx/) **CachyOS kernel and mesa-git - [Chaotic's Nyx](https://www.nyx.chaotic.cx/) **CachyOS kernel and mesa-git
things** things.**
- [nh](https://github.com/viperML/nh) **A pretty cool "nix helper"** - [nh](https://github.com/viperML/nh) **A pretty cool "nix helper".**
- [agenix](https://github.com/ryantm/agenix) **Age-based encryption** - [agenix](https://github.com/ryantm/agenix) **Age based encryption.**
- [kanata](https://github.com/jtroo/kanata) **Keyboard mapping, good stuff** - [kanata](https://github.com/jtroo/kanata) **Keyboard mapping, good stuff.**
- [waybar](https://github.com/Alexays/Waybar) **It's a wayland bar!** - [waybar](https://github.com/Alexays/Waybar) **It's a wayland bar!**
- [zen-browser](https://github.com/zen-browser/desktop) **Alpha stage, - [zen-browser](https://github.com/zen-browser/desktop) **Alpha stage, firefox
firefox-based browser** based browser.**
- [helix](https://github.com/helix-editor/helix) **Very quick editor, might - [helix](https://github.com/helix-editor/helix) **Very quick editor, might
switch to permanently!** switch permanently!**
- [tuirun](https://git.sr.ht/~canasta/tuirun) **Anyrun's applications plugin but - [tuirun](https://git.sr.ht/~canasta/tuirun) **Anyrun's applications plugin but
with tui. WIP, will add more documentation** with tui. WIP, will add more documentation.**
- [mako](https://github.com/emersion/mako) **Lightweight notifications** - [mako](https://github.com/emersion/mako) **Lightweight notifications.**
## Structure ## Structure

64
flake.lock generated
View File

@@ -28,11 +28,11 @@
"systems": "systems_2" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1730444665, "lastModified": 1731092955,
"narHash": "sha256-i3FxeHjsHw4AePx3AWVVywy92EEobx/ZER4ignWxNrE=", "narHash": "sha256-L1hLXf4IDZ0KoXbFiSNNZJ7IrReEr/J+CLt6Rl4Ea3M=",
"owner": "anyrun-org", "owner": "anyrun-org",
"repo": "anyrun", "repo": "anyrun",
"rev": "b3b4f2253d43af3311b3d3fc86973fc3e9559c33", "rev": "d2017f224b2bfd7e33573c7070e7c3e2960c7dcc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -154,11 +154,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1731047492, "lastModified": 1731220256,
"narHash": "sha256-F4h8YtTzPWv0/1Z6fc8fMSqKpn7YhOjlgp66cr15tEo=", "narHash": "sha256-7BWlJbGZ6rXtKOfgZYDQerygXco1YyYzXciuLN0UPP4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "da6332e801fbb0418f80f20cefa947c5fe5c18c9", "rev": "61c51d848301cefc1535856f9e68ad6e01a5c970",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -269,11 +269,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1726153070, "lastModified": 1730504689,
"narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "rev": "506278e768c2a08bec68eb62932193e341f55c90",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -532,11 +532,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1730969692, "lastModified": 1731172465,
"narHash": "sha256-4Ly9zkqnRB6qLjMeddfUyd4iRLvq+RDspBWABS8DGN4=", "narHash": "sha256-2O4cE+H3Q6AOiyY+qVXhXKjHBjdld+CUuGAd9rXJFRk=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland", "repo": "hyprland",
"rev": "e58e97b0a38b8ccc87a4304c9e4e2b37c9966875", "rev": "a8ff3a452c1c445d24bdd9e7e4fcd66c8ef2a147",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -640,11 +640,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730911842, "lastModified": 1731171284,
"narHash": "sha256-stAVRv13iACAIJ6mheJOwZXWD24YDupyshaUDovVNi4=", "narHash": "sha256-pwO3OCxIbLKm6NqpXeOGlO+CSOPQpcMCSJDXEctr7B8=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprlock", "repo": "hyprlock",
"rev": "4fc133c96fa1ad2968cad44f8e9e9e923cd0381a", "rev": "6c3c444136d6f87d3cd9610b12e45e4c2130ef3a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -728,11 +728,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730968903, "lastModified": 1731163338,
"narHash": "sha256-zFvzLXcSm0Ia4XI1SE4FQ9KE63hlGrRWhLtwMolWuR8=", "narHash": "sha256-Qflei0JBeqQ0c8jxA8e982xAxJvfMwfx4Aci2eJi84s=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprutils", "repo": "hyprutils",
"rev": "3ce0cde8709cdacbfba471f8e828433b58a561e9", "rev": "60d3dece30f98e8ad85131829c8529950630d6bc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -865,11 +865,11 @@
"umu": "umu" "umu": "umu"
}, },
"locked": { "locked": {
"lastModified": 1730770711, "lastModified": 1731202990,
"narHash": "sha256-UHm56cW/04efHY4NgboGFOXliGQCqRRY+l1HM7c8/Ms=", "narHash": "sha256-Ac3ff4w9+xePGX6TF90zEVyhdHJkhg58pUafvoAjVEY=",
"owner": "fufexan", "owner": "fufexan",
"repo": "nix-gaming", "repo": "nix-gaming",
"rev": "0c25376479d11073346ed22de8571805543ede71", "rev": "faf26ec552997488d75a0fdb07783c0c2edd3d5f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1139,11 +1139,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1730989300, "lastModified": 1731056261,
"narHash": "sha256-ZWSta9893f/uF5PoRFn/BSUAxF4dKW+TIbdA6rZoGBg=", "narHash": "sha256-TPeXChHVcaCBAoE349K7OZH4We5/2ys1GgG4IiwjwOs=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "1042a8c22c348491a4bade4f664430b03d6f5b5c", "rev": "dd9cd22514cb1001a0a2374b36a85eb75245f27b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1294,11 +1294,11 @@
"systems": "systems_6" "systems": "systems_6"
}, },
"locked": { "locked": {
"lastModified": 1730305454, "lastModified": 1731161138,
"narHash": "sha256-7Mn9t5KXf+0kAUjFSyvWORHS9Al+o6WEf95cfpy6vzg=", "narHash": "sha256-f4YDB4EG7iklRF8V/3JOmkMgdwe60KAL/lkep9euafs=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "5f682796104b4849063a12abfc54558c8ba62e25", "rev": "4ffa291623ca82014132fdbdef109dbda67cd267",
"revCount": 28, "revCount": 30,
"type": "git", "type": "git",
"url": "https://git.sr.ht/~canasta/tuirun" "url": "https://git.sr.ht/~canasta/tuirun"
}, },
@@ -1380,11 +1380,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730441165, "lastModified": 1731197688,
"narHash": "sha256-lXLgi09KvDfxuu2eyCFh8J/pjENoF6LKQWlJD5WKm3k=", "narHash": "sha256-CyUMgW3H72G4zKFjG0NsAwEt8LSSv2ym5qGSUJ6Sn/E=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "c31396e77f54b2d9f5bbcd5aab4b15245068e51c", "rev": "67b8c5c90f14ed77371426fdfff8e91f207c0ef9",
"revCount": 53, "revCount": 54,
"type": "git", "type": "git",
"url": "https://git.sr.ht/~canasta/zen-browser-flake" "url": "https://git.sr.ht/~canasta/zen-browser-flake"
}, },

View File

@@ -20,6 +20,7 @@
./home/programs/neovim ./home/programs/neovim
./home/programs/rofi ./home/programs/rofi
./home/programs/ssh ./home/programs/ssh
./home/programs/thunar
./home/programs/tuirun ./home/programs/tuirun
./home/programs/vscode ./home/programs/vscode
./home/programs/waybar ./home/programs/waybar

View File

@@ -30,7 +30,7 @@ in {
background = [ background = [
{ {
monitor = ""; monitor = "";
path = "~/media/images/l_int06_big.jpg"; path = "~/media/images/l_ash09_big.jpg";
} }
]; ];
input-field = [ input-field = [

View File

@@ -31,8 +31,6 @@ in {
home.packages = with pkgs; [ home.packages = with pkgs; [
# misc.gui # misc.gui
# virt-manager # virt-manager
xfce.thunar
file-roller # archiver
gnome-calculator gnome-calculator
keepassxc keepassxc
# networkmanagerapplet # tray icon for NetworkManager # networkmanagerapplet # tray icon for NetworkManager
@@ -63,8 +61,6 @@ in {
wireguard-tools wireguard-tools
wl-clipboard wl-clipboard
wpa_supplicant wpa_supplicant
xfce.thunar-archive-plugin
xfce.thunar-volman
unzip unzip
zip zip
gnutar gnutar

View File

@@ -0,0 +1,26 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.home.programs.thunar;
in {
options = {
home.programs.thunar.enable = mkEnableOption "Enables thunar file manager";
};
config = mkIf cfg.enable {
programs.thunar = {
enable = true;
plugins = with pkgs.xfce; [
thunar-archive-plugin
thunar-volman
];
};
programs.xfconf.enable = true;
services.tumbler.enable = true;
environment.systemPackages = [pkgs.file-roller];
};
}

View File

@@ -45,7 +45,7 @@ in {
}) })
{ {
default_session = { default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet -r --remember-session --asterisks"; command = "${pkgs.greetd.tuigreet}/bin/tuigreet --window-padding 1 --time --time-format '%R - %F' -r --remember-session --asterisks";
user = cfg.user; user = cfg.user;
}; };
} }

View File

@@ -74,6 +74,9 @@
ssh = { ssh = {
enable = true; enable = true;
}; };
thunar = {
enable = true;
};
tuirun = { tuirun = {
enable = true; enable = true;
}; };

View File

@@ -7,7 +7,7 @@
sharedImports = [ sharedImports = [
# ./etc # ./etc
"${self}/.scripts" "${self}/scripts"
self.nixosModules.home self.nixosModules.home
self.nixosModules.options self.nixosModules.options
]; ];

View File

@@ -65,6 +65,9 @@
ssh = { ssh = {
enable = true; enable = true;
}; };
thunar = {
enable = true;
};
tuirun = { tuirun = {
enable = true; enable = true;
}; };