Compare commits
1 Commits
btrfs-role
...
add-steam-
| Author | SHA1 | Date | |
|---|---|---|---|
| 24a09a9922 |
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Build Live USB ISO from flake configuration
|
|
||||||
# Creates an uncompressed ISO suitable for Ventoy and other USB boot tools
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "Building Live USB ISO..."
|
|
||||||
nix build .#nixosConfigurations.live-usb.config.system.build.isoImage --show-trace
|
|
||||||
|
|
||||||
if [ -f "./result/iso/"*.iso ]; then
|
|
||||||
iso_file=$(ls ./result/iso/*.iso)
|
|
||||||
echo "✅ Build complete!"
|
|
||||||
echo "📁 ISO location: $iso_file"
|
|
||||||
echo "💾 Ready for Ventoy or dd to USB"
|
|
||||||
else
|
|
||||||
echo "❌ Build failed - no ISO file found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
16
flake.nix
16
flake.nix
@@ -74,22 +74,6 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Live USB ISO configuration
|
|
||||||
nixosConfigurations.live-usb = nixpkgs.lib.nixosSystem rec {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = baseModules ++ [
|
|
||||||
./machines/live-usb/configuration.nix
|
|
||||||
{
|
|
||||||
home-manager.users.nixos = { ... }: {
|
|
||||||
imports = [ ./home/home.nix ];
|
|
||||||
home.username = nixpkgs.lib.mkForce "nixos";
|
|
||||||
home.homeDirectory = nixpkgs.lib.mkForce "/home/nixos";
|
|
||||||
};
|
|
||||||
home-manager.extraSpecialArgs = { inherit system; };
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
homeConfigurations."johno" = inputs.home-manager.lib.homeManagerConfiguration {
|
homeConfigurations."johno" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
|
pkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
# Live USB ISO configuration for recovery and installation
|
|
||||||
{ pkgs, modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
# Use minimal installation CD as base
|
|
||||||
(modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
|
|
||||||
];
|
|
||||||
|
|
||||||
# Use roles structure for consistent configuration
|
|
||||||
roles = {
|
|
||||||
audio.enable = true;
|
|
||||||
bluetooth.enable = true;
|
|
||||||
desktop = {
|
|
||||||
enable = true;
|
|
||||||
kde = true;
|
|
||||||
x11 = true;
|
|
||||||
wayland = true;
|
|
||||||
sddm = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Allow unfree packages for broader hardware support
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
|
||||||
|
|
||||||
# Essential packages for system recovery and installation
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
# Text editors
|
|
||||||
neovim
|
|
||||||
nano
|
|
||||||
|
|
||||||
# System tools
|
|
||||||
git
|
|
||||||
curl
|
|
||||||
wget
|
|
||||||
htop
|
|
||||||
tree
|
|
||||||
lsof
|
|
||||||
strace
|
|
||||||
|
|
||||||
# Filesystem tools
|
|
||||||
btrfs-progs
|
|
||||||
e2fsprogs
|
|
||||||
xfsprogs
|
|
||||||
ntfs3g
|
|
||||||
dosfstools
|
|
||||||
|
|
||||||
# Network tools
|
|
||||||
networkmanager
|
|
||||||
wirelesstools
|
|
||||||
|
|
||||||
# Hardware tools
|
|
||||||
pciutils
|
|
||||||
usbutils
|
|
||||||
smartmontools
|
|
||||||
|
|
||||||
# Archive tools
|
|
||||||
unzip
|
|
||||||
p7zip
|
|
||||||
|
|
||||||
# Development tools (for quick fixes)
|
|
||||||
gcc
|
|
||||||
binutils
|
|
||||||
];
|
|
||||||
|
|
||||||
# Enable NetworkManager for easy wifi setup
|
|
||||||
networking.networkmanager.enable = true;
|
|
||||||
|
|
||||||
# Enable SSH daemon for remote access
|
|
||||||
services.openssh = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
PermitRootLogin = "yes";
|
|
||||||
PasswordAuthentication = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# ISO customization
|
|
||||||
isoImage = {
|
|
||||||
volumeID = "NIXOS-LIVE";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Enable some useful services
|
|
||||||
services.udisks2.enable = true; # For mounting USB drives
|
|
||||||
|
|
||||||
# Hardware support
|
|
||||||
hardware.enableAllFirmware = true;
|
|
||||||
hardware.enableRedistributableFirmware = true;
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||||
|
|
||||||
|
|
||||||
# Enable networking
|
# Enable networking
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -10,28 +10,16 @@
|
|||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "sdhci_pci" ];
|
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "sdhci_pci" ];
|
||||||
boot.initrd.kernelModules = [ ];
|
boot.initrd.kernelModules = [ ];
|
||||||
boot.initrd.luks.devices."luks-4126fbd4-bd09-4ece-af0d-6fff414c21b3".device = "/dev/disk/by-uuid/4126fbd4-bd09-4ece-af0d-6fff414c21b3";
|
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
roles.btrfs = {
|
fileSystems."/" =
|
||||||
enable = true;
|
{ device = "/dev/disk/by-uuid/bd396529-e2c4-47cb-b844-8d6ed841f81a";
|
||||||
filesystems."/dev/disk/by-uuid/223a44e5-91e2-4272-830e-129166042a1d" = {
|
fsType = "ext4";
|
||||||
mountpoints = {
|
|
||||||
"/" = {
|
|
||||||
compression = "zstd";
|
|
||||||
extraOptions = [ "noatime" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
scrub.enable = true;
|
|
||||||
deduplication = {
|
|
||||||
enable = true;
|
|
||||||
hashTableSizeMB = 32;
|
|
||||||
verbosity = "err";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
boot.initrd.luks.devices."luks-4126fbd4-bd09-4ece-af0d-6fff414c21b3".device = "/dev/disk/by-uuid/4126fbd4-bd09-4ece-af0d-6fff414c21b3";
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/disk/by-uuid/7A0B-CF88";
|
{ device = "/dev/disk/by-uuid/7A0B-CF88";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
# NixBook ext4 to btrfs Migration Guide
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
This guide converts your nixbook machine from ext4 to btrfs with zstd compression and beesd deduplication while preserving your LUKS encryption and all data.
|
|
||||||
|
|
||||||
## Current System Info
|
|
||||||
- **Hostname**: nix-book
|
|
||||||
- **Root filesystem**: ext4 on `/dev/disk/by-uuid/bd396529-e2c4-47cb-b844-8d6ed841f81a`
|
|
||||||
- **Encryption**: LUKS with two devices configured
|
|
||||||
- **Current usage**: 138GB used / 225GB total (65% full)
|
|
||||||
- **Free space**: 76GB available (sufficient for conversion)
|
|
||||||
|
|
||||||
## Pre-Migration Checklist
|
|
||||||
|
|
||||||
### 1. Create Full System Backup (CRITICAL)
|
|
||||||
```bash
|
|
||||||
# Boot from NixOS live USB
|
|
||||||
# Mount encrypted filesystem
|
|
||||||
cryptsetup luksOpen /dev/disk/by-uuid/4126fbd4-bd09-4ece-af0d-6fff414c21b3 luks-nixbook
|
|
||||||
mount /dev/mapper/luks-nixbook /mnt
|
|
||||||
|
|
||||||
# Create backup to external drive (adjust target as needed)
|
|
||||||
rsync -avxHAX --progress /mnt/ /path/to/backup/nixbook-backup/
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Verify Configuration Changes
|
|
||||||
The following files have been updated for btrfs:
|
|
||||||
- `machines/nix-book/configuration.nix` - Added beesd service
|
|
||||||
- `machines/nix-book/hardware-configuration.nix` - Changed fsType to btrfs with compression
|
|
||||||
|
|
||||||
## Migration Process
|
|
||||||
|
|
||||||
### Phase 1: Boot to Live Environment
|
|
||||||
1. **Create NixOS live USB**:
|
|
||||||
```bash
|
|
||||||
# Download latest NixOS ISO
|
|
||||||
# Flash to USB drive
|
|
||||||
dd if=nixos-minimal-xx.xx-x86_64-linux.iso of=/dev/sdX bs=4M status=progress
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Boot from live USB** and ensure you can access the encrypted drives
|
|
||||||
|
|
||||||
### Phase 2: Filesystem Conversion
|
|
||||||
3. **Unlock LUKS volumes**:
|
|
||||||
```bash
|
|
||||||
cryptsetup luksOpen /dev/disk/by-uuid/4126fbd4-bd09-4ece-af0d-6fff414c21b3 luks-nixbook
|
|
||||||
cryptsetup luksOpen /dev/disk/by-uuid/b614167b-9045-4234-a441-ac6f60a96d81 luks-nixbook2
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Check filesystem before conversion**:
|
|
||||||
```bash
|
|
||||||
fsck.ext4 -f /dev/mapper/luks-nixbook
|
|
||||||
```
|
|
||||||
|
|
||||||
5. **Convert ext4 to btrfs** (this preserves all data):
|
|
||||||
```bash
|
|
||||||
# Install btrfs-progs if not available
|
|
||||||
nix-shell -p btrfs-progs
|
|
||||||
|
|
||||||
# Convert the filesystem (takes 15-45 minutes depending on data)
|
|
||||||
btrfs-convert /dev/mapper/luks-nixbook
|
|
||||||
|
|
||||||
# Verify conversion succeeded
|
|
||||||
mount /dev/mapper/luks-nixbook /mnt
|
|
||||||
ls -la /mnt # Should show your normal filesystem
|
|
||||||
btrfs filesystem show /mnt
|
|
||||||
```
|
|
||||||
|
|
||||||
6. **Get new filesystem UUID** (may have changed):
|
|
||||||
```bash
|
|
||||||
blkid /dev/mapper/luks-nixbook
|
|
||||||
# Note the new UUID if it changed
|
|
||||||
```
|
|
||||||
|
|
||||||
### Phase 3: Configuration Update
|
|
||||||
7. **Mount and chroot into system**:
|
|
||||||
```bash
|
|
||||||
mount -o compress=zstd,noatime /dev/mapper/luks-nixbook /mnt
|
|
||||||
mount /dev/disk/by-uuid/7A0B-CF88 /mnt/boot
|
|
||||||
nixos-enter --root /mnt
|
|
||||||
```
|
|
||||||
|
|
||||||
8. **Update hardware-configuration.nix** if UUID changed:
|
|
||||||
```bash
|
|
||||||
# Edit /etc/nixos/hardware-configuration.nix if needed
|
|
||||||
# Update the UUID in fileSystems."/" section
|
|
||||||
```
|
|
||||||
|
|
||||||
9. **Rebuild system with btrfs configuration**:
|
|
||||||
```bash
|
|
||||||
cd /home/johno/nixos-configs
|
|
||||||
nixos-rebuild switch --flake .#nix-book
|
|
||||||
```
|
|
||||||
|
|
||||||
### Phase 4: Enable Compression and Deduplication
|
|
||||||
10. **Reboot into new btrfs system**:
|
|
||||||
```bash
|
|
||||||
exit # Exit chroot
|
|
||||||
umount -R /mnt
|
|
||||||
reboot
|
|
||||||
```
|
|
||||||
|
|
||||||
11. **Verify btrfs is working**:
|
|
||||||
```bash
|
|
||||||
mount | grep btrfs
|
|
||||||
btrfs filesystem usage /
|
|
||||||
```
|
|
||||||
|
|
||||||
12. **Enable and start beesd**:
|
|
||||||
```bash
|
|
||||||
systemctl status beesd-root
|
|
||||||
systemctl start beesd-root
|
|
||||||
systemctl enable beesd-root
|
|
||||||
```
|
|
||||||
|
|
||||||
13. **Force compression on existing files** (optional but recommended):
|
|
||||||
```bash
|
|
||||||
# This will compress existing files with zstd
|
|
||||||
btrfs filesystem defragment -r -czstd /
|
|
||||||
```
|
|
||||||
|
|
||||||
## Post-Migration Verification
|
|
||||||
|
|
||||||
### Check System Health
|
|
||||||
```bash
|
|
||||||
# Verify btrfs health
|
|
||||||
btrfs scrub start /
|
|
||||||
btrfs scrub status /
|
|
||||||
|
|
||||||
# Check compression effectiveness
|
|
||||||
compsize /
|
|
||||||
|
|
||||||
# Monitor beesd deduplication
|
|
||||||
journalctl -u beesd-root -f
|
|
||||||
|
|
||||||
# Check filesystem usage
|
|
||||||
btrfs filesystem usage /
|
|
||||||
df -h /
|
|
||||||
```
|
|
||||||
|
|
||||||
### Performance Monitoring
|
|
||||||
```bash
|
|
||||||
# Monitor beesd hash table
|
|
||||||
ls -lh /.beeshash
|
|
||||||
|
|
||||||
# Check compression ratio over time
|
|
||||||
compsize /home /nix /var
|
|
||||||
```
|
|
||||||
|
|
||||||
## Expected Benefits
|
|
||||||
|
|
||||||
### Space Savings
|
|
||||||
- **Compression**: 20-30% reduction in disk usage from zstd
|
|
||||||
- **Deduplication**: Additional 10-20% savings on duplicate files
|
|
||||||
- **Combined**: Potentially 30-40% total space savings
|
|
||||||
|
|
||||||
### Performance Impact
|
|
||||||
- **Compression**: Minimal CPU overhead, often improves I/O performance
|
|
||||||
- **Deduplication**: Background process, minimal impact during normal use
|
|
||||||
- **Overall**: Should be neutral to positive performance impact
|
|
||||||
|
|
||||||
## Rollback Plan (Emergency)
|
|
||||||
|
|
||||||
If something goes wrong:
|
|
||||||
|
|
||||||
1. **Boot from live USB**
|
|
||||||
2. **Restore from backup**:
|
|
||||||
```bash
|
|
||||||
cryptsetup luksOpen /dev/disk/by-uuid/4126fbd4-bd09-4ece-af0d-6fff414c21b3 luks-nixbook
|
|
||||||
mkfs.ext4 /dev/mapper/luks-nixbook
|
|
||||||
mount /dev/mapper/luks-nixbook /mnt
|
|
||||||
rsync -avxHAX --progress /path/to/backup/nixbook-backup/ /mnt/
|
|
||||||
```
|
|
||||||
3. **Restore original hardware-configuration.nix** with ext4 settings
|
|
||||||
4. **Rebuild and reboot**
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Common Issues
|
|
||||||
|
|
||||||
**"Device busy" during conversion**:
|
|
||||||
- Ensure no processes are accessing the filesystem
|
|
||||||
- Check with `lsof` and `fuser`
|
|
||||||
|
|
||||||
**UUID changed after conversion**:
|
|
||||||
- Update hardware-configuration.nix with new UUID
|
|
||||||
- Regenerate initrd: `nixos-rebuild switch`
|
|
||||||
|
|
||||||
**Beesd service fails to start**:
|
|
||||||
- Check disk space for hash table
|
|
||||||
- Verify filesystem is btrfs: `mount | grep btrfs`
|
|
||||||
- Check logs: `journalctl -u beesd-root`
|
|
||||||
|
|
||||||
**Boot issues after conversion**:
|
|
||||||
- Boot from live USB
|
|
||||||
- Check /boot partition is mounted correctly
|
|
||||||
- Verify LUKS UUIDs match in configuration
|
|
||||||
- Rebuild bootloader: `nixos-rebuild switch --install-bootloader`
|
|
||||||
|
|
||||||
## Maintenance
|
|
||||||
|
|
||||||
### Regular Tasks
|
|
||||||
```bash
|
|
||||||
# Monthly scrub (checks for corruption)
|
|
||||||
btrfs scrub start /
|
|
||||||
|
|
||||||
# Monitor compression effectiveness
|
|
||||||
compsize /
|
|
||||||
|
|
||||||
# Check beesd deduplication status
|
|
||||||
systemctl status beesd-root
|
|
||||||
```
|
|
||||||
|
|
||||||
### Space Management
|
|
||||||
```bash
|
|
||||||
# Balance filesystem (defragments and optimizes)
|
|
||||||
btrfs balance start -dusage=50 /
|
|
||||||
|
|
||||||
# Check for space issues
|
|
||||||
btrfs filesystem usage /
|
|
||||||
```
|
|
||||||
|
|
||||||
This migration preserves all your data while gaining the benefits of modern btrfs features including transparent compression and automatic deduplication.
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
{ lib, config, pkgs, ... }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.roles.btrfs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.roles.btrfs = {
|
|
||||||
enable = mkEnableOption "Enable btrfs filesystem management";
|
|
||||||
|
|
||||||
filesystems = mkOption {
|
|
||||||
type = types.attrsOf (types.submodule {
|
|
||||||
options = {
|
|
||||||
# Filesystem-level maintenance options
|
|
||||||
scrub = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Enable automatic scrubbing for this filesystem";
|
|
||||||
};
|
|
||||||
interval = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "weekly";
|
|
||||||
description = "Scrub interval (systemd timer format)";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
deduplication = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable beesd deduplication for this filesystem";
|
|
||||||
};
|
|
||||||
hashTableSizeMB = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 1024;
|
|
||||||
description = "Hash table size in MB (should be multiple of 16)";
|
|
||||||
};
|
|
||||||
verbosity = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "info";
|
|
||||||
description = "Logging verbosity level";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
balance = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable periodic balance operations";
|
|
||||||
};
|
|
||||||
interval = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "monthly";
|
|
||||||
description = "Balance interval (systemd timer format)";
|
|
||||||
};
|
|
||||||
dataUsage = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 50;
|
|
||||||
description = "Data usage threshold for balance";
|
|
||||||
};
|
|
||||||
metadataUsage = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 50;
|
|
||||||
description = "Metadata usage threshold for balance";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Mountpoint-based configuration
|
|
||||||
mountpoints = mkOption {
|
|
||||||
type = types.attrsOf (types.submodule {
|
|
||||||
options = {
|
|
||||||
subvolume = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
description = "Subvolume name. If null, uses default subvolume.";
|
|
||||||
};
|
|
||||||
compression = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "zstd";
|
|
||||||
description = "Compression algorithm (zstd, lzo, lz4, none)";
|
|
||||||
};
|
|
||||||
autodefrag = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable automatic defragmentation";
|
|
||||||
};
|
|
||||||
extraOptions = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
default = [];
|
|
||||||
description = "Additional mount options";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
default = {};
|
|
||||||
description = "Mountpoint configurations for this filesystem";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
default = {};
|
|
||||||
description = "Btrfs filesystems configuration";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
# Generate fileSystems configuration from mountpoints
|
|
||||||
fileSystems = mkMerge (flatten (mapAttrsToList (device: fsCfg:
|
|
||||||
mapAttrsToList (mountpoint: mountCfg:
|
|
||||||
{
|
|
||||||
${mountpoint} = {
|
|
||||||
device = device;
|
|
||||||
fsType = "btrfs";
|
|
||||||
options =
|
|
||||||
(optional (mountCfg.subvolume != null) "subvol=${mountCfg.subvolume}") ++
|
|
||||||
[ "compress=${mountCfg.compression}" ] ++
|
|
||||||
(optional mountCfg.autodefrag "autodefrag") ++
|
|
||||||
mountCfg.extraOptions;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
) fsCfg.mountpoints
|
|
||||||
) cfg.filesystems));
|
|
||||||
|
|
||||||
# Configure scrub service using NixOS built-in
|
|
||||||
services.btrfs.autoScrub = mkIf (any (fs: fs.scrub.enable) (attrValues cfg.filesystems)) {
|
|
||||||
enable = true;
|
|
||||||
interval = "weekly"; # TODO: Make this configurable per filesystem
|
|
||||||
fileSystems = attrNames (filterAttrs (_: fs: fs.scrub.enable) cfg.filesystems);
|
|
||||||
};
|
|
||||||
|
|
||||||
# Configure beesd for filesystems with deduplication enabled
|
|
||||||
services.beesd.filesystems = mapAttrs' (device: fsCfg:
|
|
||||||
nameValuePair (replaceStrings ["/"] ["_"] (replaceStrings ["-"] ["_"] device)) {
|
|
||||||
spec = device;
|
|
||||||
hashTableSizeMB = fsCfg.deduplication.hashTableSizeMB;
|
|
||||||
verbosity = fsCfg.deduplication.verbosity;
|
|
||||||
}
|
|
||||||
) (filterAttrs (_: fs: fs.deduplication.enable) cfg.filesystems);
|
|
||||||
|
|
||||||
# Custom balance services for filesystems with balance enabled
|
|
||||||
systemd.services = mkMerge (mapAttrsToList (device: fsCfg: mkIf fsCfg.balance.enable {
|
|
||||||
"btrfs-balance-${replaceStrings ["/"] ["-"] (replaceStrings ["-"] ["_"] device)}" = {
|
|
||||||
description = "Balance btrfs filesystem ${device}";
|
|
||||||
script = ''
|
|
||||||
${pkgs.btrfs-progs}/bin/btrfs balance start \
|
|
||||||
-dusage=${toString fsCfg.balance.dataUsage} \
|
|
||||||
-musage=${toString fsCfg.balance.metadataUsage} \
|
|
||||||
${device}
|
|
||||||
'';
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
Nice = 19;
|
|
||||||
IOSchedulingClass = "idle";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}) cfg.filesystems);
|
|
||||||
|
|
||||||
# Balance timers
|
|
||||||
systemd.timers = mkMerge (mapAttrsToList (device: fsCfg: mkIf fsCfg.balance.enable {
|
|
||||||
"btrfs-balance-${replaceStrings ["/"] ["-"] (replaceStrings ["-"] ["_"] device)}" = {
|
|
||||||
description = "Periodic balance for ${device}";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = fsCfg.balance.interval;
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}) cfg.filesystems);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ with lib;
|
|||||||
imports = [
|
imports = [
|
||||||
./audio
|
./audio
|
||||||
./bluetooth
|
./bluetooth
|
||||||
./btrfs
|
|
||||||
./desktop
|
./desktop
|
||||||
./kodi
|
./kodi
|
||||||
./nfs-mounts
|
./nfs-mounts
|
||||||
|
|||||||
@@ -20,5 +20,6 @@ with lib;
|
|||||||
./kde.nix
|
./kde.nix
|
||||||
./programs.nix
|
./programs.nix
|
||||||
./sddm.nix
|
./sddm.nix
|
||||||
|
./steam-sleep-inhibitor.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
116
roles/desktop/steam-sleep-inhibitor.nix
Normal file
116
roles/desktop/steam-sleep-inhibitor.nix
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.roles.desktop;
|
||||||
|
|
||||||
|
steamSleepInhibitor = pkgs.writeShellScript "steam-sleep-inhibitor" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Steam log path - adjust if different
|
||||||
|
STEAM_LOG="$HOME/.local/share/Steam/logs/streaming_log.txt"
|
||||||
|
FALLBACK_LOG="$HOME/.steam/steam/logs/streaming_log.txt"
|
||||||
|
|
||||||
|
# Find Steam log file
|
||||||
|
if [[ -f "$STEAM_LOG" ]]; then
|
||||||
|
LOG_FILE="$STEAM_LOG"
|
||||||
|
elif [[ -f "$FALLBACK_LOG" ]]; then
|
||||||
|
LOG_FILE="$FALLBACK_LOG"
|
||||||
|
else
|
||||||
|
# Monitor Steam process for streaming activity
|
||||||
|
LOG_FILE=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
INHIBITOR_PID=""
|
||||||
|
MONITORING=false
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if [[ -n "$INHIBITOR_PID" ]]; then
|
||||||
|
echo "Stopping sleep inhibitor (PID: $INHIBITOR_PID)"
|
||||||
|
kill "$INHIBITOR_PID" 2>/dev/null
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
start_inhibitor() {
|
||||||
|
if [[ -z "$INHIBITOR_PID" ]]; then
|
||||||
|
echo "Starting sleep inhibitor for Steam Remote Play session"
|
||||||
|
${pkgs.systemd}/bin/systemd-inhibit \
|
||||||
|
--what=sleep \
|
||||||
|
--who="Steam Remote Play" \
|
||||||
|
--why="Active streaming session detected" \
|
||||||
|
--mode=block \
|
||||||
|
sleep infinity &
|
||||||
|
INHIBITOR_PID=$!
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_inhibitor() {
|
||||||
|
if [[ -n "$INHIBITOR_PID" ]]; then
|
||||||
|
echo "Stopping sleep inhibitor - streaming session ended"
|
||||||
|
kill "$INHIBITOR_PID" 2>/dev/null
|
||||||
|
INHIBITOR_PID=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if Steam Remote Play is active by looking for streaming processes
|
||||||
|
check_streaming_active() {
|
||||||
|
# Check for Steam streaming processes
|
||||||
|
if pgrep -f "streaming_client" >/dev/null || \
|
||||||
|
pgrep -f "steamremoteplay" >/dev/null || \
|
||||||
|
${pkgs.procps}/bin/pgrep -f "Remote Play" >/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for active network connections on Steam streaming ports
|
||||||
|
if ${pkgs.nettools}/bin/netstat -an 2>/dev/null | grep -E ":(27036|27037)" | grep ESTABLISHED >/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT INT TERM
|
||||||
|
|
||||||
|
echo "Steam sleep inhibitor monitoring started"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if check_streaming_active; then
|
||||||
|
if [[ "$MONITORING" == "false" ]]; then
|
||||||
|
MONITORING=true
|
||||||
|
start_inhibitor
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ "$MONITORING" == "true" ]]; then
|
||||||
|
MONITORING=false
|
||||||
|
stop_inhibitor
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = mkIf (cfg.enable && cfg.kde && cfg.gaming) {
|
||||||
|
# Steam streaming sleep inhibitor service
|
||||||
|
systemd.user.services.steam-sleep-inhibitor = {
|
||||||
|
description = "Steam Remote Play Sleep Inhibitor";
|
||||||
|
wantedBy = [ "default.target" ];
|
||||||
|
after = [ "graphical-session.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${steamSleepInhibitor}";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "5";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Steam-specific environment variables to prevent sleep interference
|
||||||
|
environment.sessionVariables = {
|
||||||
|
SDL_VIDEO_ALLOW_SCREENSAVER = "1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -19,12 +19,5 @@ in
|
|||||||
nssmdns4 = true;
|
nssmdns4 = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware.printers.ensurePrinters = [{
|
|
||||||
name = "MFC-L8900CDW_series";
|
|
||||||
deviceUri = "dnssd://Brother%20MFC-L8900CDW%20series._ipp._tcp.local/?uuid=e3248000-80ce-11db-8000-b422006699d8";
|
|
||||||
model = "everywhere";
|
|
||||||
}];
|
|
||||||
hardware.printers.ensureDefaultPrinter = "MFC-L8900CDW_series";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user