mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-22 08:04:20 +01:00
Mount old versions of home on omen
Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
parent
c7b774931d
commit
23c7002368
|
@ -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";
|
||||||
|
|
18
overlays/rolling_datasets/bin/mount_datasets
Normal file
18
overlays/rolling_datasets/bin/mount_datasets
Normal 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")"
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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")"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue