Add xdg settings, cache, cleanup script
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -4,5 +4,8 @@
|
||||
histFile = "/var/lib/zsh/history";
|
||||
};
|
||||
|
||||
environment.persistence."/persist".directories = [ "/var/lib/zsh" ];
|
||||
environment = {
|
||||
persistence."/persist".directories = [ "/var/lib/zsh" ];
|
||||
pathsToLink = [ "/share/zsh" ];
|
||||
};
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
./configs/nix-ld
|
||||
./configs/git
|
||||
./configs/gpg-agent
|
||||
./scripts/cleanup
|
||||
];
|
||||
|
||||
boot = {
|
||||
@@ -63,8 +64,13 @@
|
||||
};
|
||||
|
||||
nix = {
|
||||
settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
settings = {
|
||||
use-xdg-base-directories = true;
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
};
|
||||
|
||||
gc.automatic = true;
|
||||
optimise.automatic = true;
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
34
hosts/common/scripts/cleanup/cleanup.sh
Normal file
34
hosts/common/scripts/cleanup/cleanup.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
set -e
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root or with sudo privileges."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/mnt/btrfs/$i"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
|
||||
if [[ -e /mnt/btrfs && $(mountpoint -q /mnt/btrfs) ]]; then
|
||||
echo "/mnt/btrfs is already mounted. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /mnt/btrfs
|
||||
mount /dev/mapper/luks /mnt/btrfs
|
||||
|
||||
if [[ -e /mnt/btrfs/root.bak ]]; then
|
||||
for i in /mnt/btrfs/root.bak/*; do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
fi
|
||||
|
||||
umount /mnt/btrfs
|
||||
rmdir /mnt/btrfs
|
||||
|
||||
nix-collect-garbage -d
|
||||
nix-store --gc -v
|
5
hosts/common/scripts/cleanup/default.nix
Normal file
5
hosts/common/scripts/cleanup/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = [ (pkgs.writeShellScriptBin "nix-cleanup" (builtins.readFile ./cleanup.sh)) ];
|
||||
}
|
Reference in New Issue
Block a user