feat: impermanence prune script
This commit is contained in:
parent
37bf94ca5b
commit
7665a7f89b
|
@ -6,8 +6,58 @@
|
|||
}: let
|
||||
onlyHost =
|
||||
lib.mkIf (!config.boot.isContainer);
|
||||
prune = folder:
|
||||
pkgs.writers.writePython3Bin "impermanence-prune" {} ''
|
||||
import os
|
||||
import sys
|
||||
mounts = [${
|
||||
lib.concatStringsSep ", "
|
||||
((map (x:
|
||||
"\""
|
||||
+ (
|
||||
if x.home != null
|
||||
then x.home + "/"
|
||||
else ""
|
||||
)
|
||||
+ x.directory
|
||||
+ "\"")
|
||||
config.environment.persistence.${folder}.directories)
|
||||
++ (map (x:
|
||||
"\""
|
||||
+ (
|
||||
if x.home != null
|
||||
then x.home + "/"
|
||||
else ""
|
||||
)
|
||||
+ x.file
|
||||
+ "\"")
|
||||
config.environment.persistence.${folder}.files))
|
||||
}] # noqa: E501
|
||||
mounts = [os.path.normpath(x) for x in mounts]
|
||||
mounts.sort()
|
||||
real_mounts = mounts[:1]
|
||||
for i in mounts[1:]:
|
||||
if i.startswith(real_mounts[-1] + "/"):
|
||||
continue
|
||||
real_mounts.append(i)
|
||||
erg = set()
|
||||
for i in real_mounts:
|
||||
dir = os.path.dirname(i)
|
||||
try:
|
||||
content = [dir + "/" + x for x in os.listdir("${folder}" + dir)]
|
||||
for j in content:
|
||||
if not any([x.startswith(j) for x in real_mounts]):
|
||||
erg.add("${folder}" + j)
|
||||
except PermissionError:
|
||||
print(f"{dir} could not be accessed. Try running as root",
|
||||
file=sys.stderr)
|
||||
print("\n".join(erg))
|
||||
'';
|
||||
in {
|
||||
# to allow all users to access hm managed persistent folders
|
||||
lib.scripts.impermanence.pruneScripts =
|
||||
lib.mapAttrs (k: _: prune k)
|
||||
config.environment.persistence;
|
||||
programs.fuse.userAllowOther = true;
|
||||
services.openssh.hostKeys = lib.mkForce [
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
services = {
|
||||
xserver.xkb = {
|
||||
layout = "de";
|
||||
variant = "bone";
|
||||
};
|
||||
libinput = {
|
||||
touchpad = lib.mkForce {
|
||||
|
|
|
@ -2,5 +2,6 @@ _final: prev: {
|
|||
scripts = {
|
||||
usbguardw = prev.callPackage ./usbguardw.nix {};
|
||||
clone-term = prev.callPackage ./clone-term.nix {};
|
||||
impermanence-o = prev.callPackage ./impermanence-orphan.nix {};
|
||||
};
|
||||
}
|
||||
|
|
17
pkgs/scripts/impermanence-orphan.nix
Normal file
17
pkgs/scripts/impermanence-orphan.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{writers}:
|
||||
writers.writePython3Bin "find-orphaned" {} ''
|
||||
import sys
|
||||
import os
|
||||
if len(sys.argv) != 2:
|
||||
print("Please give a singular argument containing the folder to prune")
|
||||
exit(1)
|
||||
mountpoint = sys.argv[1]
|
||||
if !os.path.exists(mountpoint)):
|
||||
print("Argument has to exist")
|
||||
exit(1)
|
||||
with open("/proc/mounts", "r") as f:
|
||||
mounts = [line.split() for line in f.readlines()]
|
||||
toplevel =
|
||||
current = [mountpoint]
|
||||
print(os.listdir(mountpoint))
|
||||
''
|
|
@ -197,6 +197,16 @@ in {
|
|||
xwayland.force_zero_scaling = true;
|
||||
windowrulev2 = [
|
||||
"immediate, class:^(cs2)$"
|
||||
"workspace 2,class:^(firefox)$"
|
||||
"workspace 3,class:^(thunderbird)$"
|
||||
"workspace 4,class:^(bottles)$"
|
||||
"workspace 4,class:^(steam)$"
|
||||
"workspace 4,class:^(prismlauncher)$"
|
||||
"workspace 6,class:^(discord)$"
|
||||
"workspace 6,class:^(WebCord)$"
|
||||
"workspace 6,class:^(TeamSpeak 3)$"
|
||||
"workspace 7,class:^(signal)$"
|
||||
"workspace 7,class:^(TelegramDesktop)$"
|
||||
];
|
||||
}
|
||||
(mkIf (nixosConfig.node.name == "desktopnix") {
|
||||
|
@ -215,19 +225,6 @@ in {
|
|||
"GBM_BACKEND,nvidia-drm"
|
||||
"__GLX_VENDOR_LIBRARY_NAME,nvidia"
|
||||
];
|
||||
windowrulev2 = [
|
||||
"workspace 2,class:^(firefox)$"
|
||||
"workspace 3,class:^(thunderbird)$"
|
||||
"workspace 4,class:^(bottles)$"
|
||||
"workspace 4,class:^(steam)$"
|
||||
"workspace 4,class:^(prismlauncher)$"
|
||||
"workspace 6,class:^(discord)$"
|
||||
"workspace 6,class:^(WebCord)$"
|
||||
"workspace 6,class:^(TeamSpeak 3)$"
|
||||
"workspace 7,class:^(signal)$"
|
||||
"workspace 7,class:^(TelegramDesktop)$"
|
||||
];
|
||||
|
||||
workspace = [
|
||||
"1, monitor:DP-3, default:true"
|
||||
"2, monitor:DP-3"
|
||||
|
@ -248,6 +245,15 @@ in {
|
|||
"Unknown-1, disable"
|
||||
];
|
||||
workspace = [
|
||||
"1, monitor:eDP-1, default:true"
|
||||
"2, monitor:eDP-1"
|
||||
"3, monitor:eDP-1"
|
||||
"4, monitor:eDP-1"
|
||||
"5, monitor:eDP-1"
|
||||
"6, monitor:eDP-1"
|
||||
"7, monitor:eDP-1"
|
||||
"8, monitor:eDP-1"
|
||||
"9, monitor:eDP-1"
|
||||
];
|
||||
})
|
||||
];
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
".config/spotify"
|
||||
".cache/spotify"
|
||||
".local/share/cargo"
|
||||
".local/share/wallpapers"
|
||||
];
|
||||
};
|
||||
"/panzer/state".directories =
|
||||
|
|
Loading…
Reference in a new issue