feat: improved impermanence setup

This commit is contained in:
Patrick Großmann 2023-06-01 16:49:01 +09:00
parent a699526446
commit bfd9c30373
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
8 changed files with 77 additions and 33 deletions

View file

@ -6,7 +6,7 @@
age.identityPaths = ["/persist/etc/ssh/ssh_host_ed25519_key"];
# to allow all users to access hm managed persistent folders
programs.fuse.userAllowOther = true;
environment.persistence."/persist" = {
environment.persistence."/state" = {
hideMounts = true;
files = [

View file

@ -12,8 +12,15 @@
USB_EXCLUDE_PHONE = 1;
};
};
# enabel users in the video group to control backlight
udev.extraRules = ''
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video $sys$devpath/brightness", RUN+="${pkgs.coreutils}/bin/chmod g+w $sys$devpath/brightness"
'';
};
# enable systemd to save and restore backlight state
environment.persistence."/state" = {
directories = [
"/var/lib/systemd/backlight"
];
};
}

View file

@ -20,6 +20,13 @@
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/state" = {
device = "rpool/local/state";
neededForBoot = true;
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/BC47-8FB9";
fsType = "vfat";

View file

@ -7,6 +7,7 @@
./git.nix
./gpg
./util.nix
./impermanence.nix
];
# TODO unify stateversions
home.stateVersion = "23.05";

View file

@ -1,35 +1,33 @@
{config, ...}: {
home.persistence."/persist/home/${config.home.username}" = {
{
config,
lib,
pkgs,
...
}:
with lib.lists; {
home.persistence."/state/home/${config.home.username}" = {
allowOther = true;
files = [
".ssh/known_hosts"
];
directories = [
"repos"
"Downloads"
".local/share/atuin"
# firefox muss halt
".mozilla"
# nvim kinda nervig
".local/share/nvim/lazy"
".local/state/nvim"
".cache/nvim"
".local/share/direnv"
{
directory = ".local/share/Steam";
method = "symlink";
}
{
directory = ".steam";
method = "symlink";
}
"./Nextcloud"
".config/Nextcloud"
];
directories =
optionals config.programs.atuin.enable [
".local/share/atuin"
]
++ optionals config.programs.firefox.enable [
".mozilla"
]
++ optionals config.programs.neovim.enable [
".local/share/nvim"
".local/state/nvim"
".cache/nvim"
]
++ optionals config.programs.direnv.enable [
".local/share/direnv"
]
++ optionals (builtins.elem pkgs.nextcloud-client config.home.packages) [
"./Nextcloud"
".config/Nextcloud"
];
};
}

View file

@ -29,7 +29,6 @@
home-manager.users.patrick.imports = [
hyprland.homeManagerModules.default
impermanence.home-manager.impermanence
../common/impermanence.nix
./patrick.nix
../common
];

View file

@ -1,4 +1,8 @@
{pkgs, ...}: {
{
pkgs,
config,
...
}: {
imports = [
../common/programs/kitty.nix
../common/graphical/hyprland.nix
@ -22,6 +26,7 @@
feh
acpilight
galaxy-buds-client
netflix
];
sessionVariables = {
# Firefox touch support
@ -29,6 +34,29 @@
# Firefox Hardware render
"MOZ_WEBRENDER" = 1;
};
persistence."/state/home/${config.home.username}" = let
# some programs( such as steam do not work with bindmounts
# additionally symlinks are a lot faster than bindmounts
# ~ 2x faster in my tests
makeSymLinks = x:
builtins.map (x: {
directory = x;
method = "symlink";
})
x;
in {
directories =
[
"repos"
"Downloads"
]
++ makeSymLinks [
".local/share/Steam"
".steam"
".local/share//Daedalic Entertainment GmbH/The Pillars of the Earth/"
];
};
};
programs.firefox = {

View file

@ -1,6 +1,7 @@
{
pkgs,
config,
impermanence,
...
}: {
rekey.secrets.root.file = ../../secrets/root.passwd.age;
@ -13,6 +14,9 @@
passwordFile = config.rekey.secrets.root.path;
};
home-manager.users.root = {
imports = [../common];
imports = [
../common
impermanence.home-manager.impermanence
];
};
}