Mount old versions of home on omen

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2023-10-18 14:30:17 +02:00
parent c7b774931d
commit 23c7002368
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E
5 changed files with 42 additions and 2 deletions

View file

@ -85,6 +85,22 @@
''; '';
}; };
systemd.services."mount-old-homes" = {
description = "Mount old versions of home dataset";
wantedBy = [ "local-fs.target" ];
after = [ "local-fs.target" ];
script = ''
${pkgs.rolling_datasets}/bin/mount_datasets "omen-ssd/ephemeral/home" "/home/.old"
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
TimeoutStartSec = "5m";
};
};
systemd.services."home-manager-main-pre.service" = { systemd.services."home-manager-main-pre.service" = {
description = "Home Manager environment prestart for main"; description = "Home Manager environment prestart for main";

View file

@ -0,0 +1,18 @@
# -*- mode: shell-script -*-
source @out@/share/functions/get_old_datasets
export "PATH=$PATH:@runtimePath@"
if [[ "$#" != 2 ]] ; then
echo "This script requires precisely 2 arguments!"
exit 1
fi
dataset="$1"
mountpoint="$2"
while IFS="\n" read gen
do
mountpoint -q "$mountpoint/$gen" || mount -o x-mount.mkdir -v -t zfs "$dataset/$gen" "$mountpoint/$gen"
done <<< "$(get_old_datasets "$dataset")"

View file

@ -2,6 +2,8 @@
source @out@/share/functions/get_old_datasets source @out@/share/functions/get_old_datasets
export "PATH=$PATH:@runtimePath@"
if [[ "$#" != 3 ]] ; then if [[ "$#" != 3 ]] ; then
echo "This script requires precisely 2 arguments!" echo "This script requires precisely 2 arguments!"
exit 1 exit 1

View file

@ -53,9 +53,13 @@
} '' } ''
mkdir -p $out/bin mkdir -p $out/bin
mkdir -p $out/share/functions mkdir -p $out/share/functions
export runtimeShell=${prev.runtimeShell} \
runtimePath=${prev.lib.makeBinPath (with prev; [ utillinux zfs ])}
for binary in ${./bin}/* ; do for binary in ${./bin}/* ; do
substituteAll "$binary" "$out/bin/$(basename "$binary")" output_binary="$out/bin/$(basename "$binary")"
substituteAll "$binary" "$output_binary"
chmod +x "$output_binary"
done done
for function in ${./functions}/* ; do for function in ${./functions}/* ; do

View file

@ -2,5 +2,5 @@
function get_old_datasets() function get_old_datasets()
{ {
dataset="$1" dataset="$1"
zfs list "$dataset" -t filesystem -r -H -o name | xargs -I {} ${final.runtimeShell} -c 'echo "$1" | rev | cut -f 1 -d "/" | rev' sh {} | grep -v "$dataset" zfs list "$dataset" -t filesystem -r -H -o name | xargs -I {} @runtimeShell@ -c 'echo "$1" | rev | cut -f 1 -d "/" | rev' sh {} | grep -v "$(basename "$dataset")"
} }