improve browser module

This commit is contained in:
Ingolf Wagner 2023-11-06 10:50:00 +01:00
parent 7c0da89e38
commit 373b69c2b5
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -104,23 +104,118 @@ let
in
allBrowser ++ xclipBrowser;
#createBackupScript = name: home: backupHome:
# pkgs.writeShellScriptBin "${name}-backup" # sh
# ''
# sudo -u ${name} \
# ${tarBin} \
# --exclude=.cache \
# --exclude=.config/chromium/Default/Service\ Worker/CacheStorage \
# --exclude=.config/chromium/Default/IndexedDB \
# --exclude=".mozilla/firefox/[a-zA-Z0-9]+.default/storage" \
# --exclude=Downloads \
# --create \
# --verbos \
# --lzma \
# --file ${home}.tar.lzma \
# --directory ${home} \
# .
# cp ${home}.tar.lzma ${backupHome}.tar.lzma
# '';
createBackupScript = name: home: backupHome:
pkgs.writeShellScriptBin "${name}-backup" # sh
createBackupScriptTemplate {
sudo = name;
name = name;
source = home;
target = backupHome;
arguments = [
"--exclude=Downloads"
"--exclude=.cache"
"--exclude=.config/chromium/Default/IndexedDB"
"--exclude=\".config/chromium/Default/Service Worker/CacheStorage\""
"--exclude=\".config/google-chrome/Crash Reports\""
"--exclude=.config/google-chrome/Default/DawnCache"
"--exclude=\".config/google-chrome/Default/Local Storage\""
"--exclude=.config/google-chrome/Default/Storage"
"--exclude=.config/google-chrome/Default/optimization_guide_prediction_model_downloads"
"--exclude=\".mozilla/firefox/*.default/sessionstore-backups\""
"--exclude=\".mozilla/firefox/*.default/storage\""
"--exclude=.mozilla/firefox/*.default/storage-sync-v2.sqlite"
];
};
createBackupScriptTemplate = { sudo, name, source, target, arguments ? [ ] }:
pkgs.writers.writeBashBin "${name}-backup"
''
sudo -u ${name} \
sudo -u ${sudo} \
${tarBin} \
--exclude=.cache \
--exclude=Downloads \
${concatStringsSep " " arguments} \
--create \
--verbos \
--lzma \
--file ${home}.tar.lzma \
--directory ${home} \
--file ${source}.tar.lzma \
--directory ${source} \
.
cp ${home}.tar.lzma ${backupHome}.tar.lzma
cp ${source}.tar.lzma ${target}.tar.lzma
'';
# todo_this_is_how_I_want_to_use_tar = tar {
# sudo = "jobrad";
# # true => tar --directory ${source} .
# # false => tar $source
# strip_path = true;
# source = "/browser/jobrad";
# target = "/browser/jobrad.tar.lzma";
# lzma = true;
# # also possble this is a string
# exclude = [
# ".cache"
# ".config"
# ];
# exclude-backup = true;
# exclude-cache-all = true;
# extraArgs = {
# # key = string or key = list
# };
# };
allExcludes =
let
excludes = {
works = [
"--exclude=Downloads"
"--exclude=.cache"
"--exclude=.config/chromium/Default/IndexedDB"
"--exclude=.config/chromium/Default/Service\ Worker/CacheStorage"
"--exclude=.config/google-chrome/Crash\ Reports"
"--exclude=.config/google-chrome/Default/DawnCache"
"--exclude=.config/google-chrome/Default/Local\ Storage"
"--exclude=.config/google-chrome/Default/Storage"
"--exclude=.config/google-chrome/Default/optimization_guide_prediction_model_downloads"
"--exclude=.mozilla/firefox/*.default/sessionstore-backups"
"--exclude=.mozilla/firefox/*.default/storage"
"--exclude=.mozilla/firefox/*.default/storage-sync-v2.sqlite"
];
};
allScripts = mapAttrs
(name: exclude:
createBackupScriptTemplate {
sudo = "jobrad";
name = name;
source = "/browsers/jobrad";
target = "/browsers/jobrad-${name}";
arguments = exclude;
})
excludes;
in
pkgs.writers.writeBashBin "test-tar"
(concatStringsSep "\n" (builtins.attrValues allScripts));
allBackupScripts =
let
filteredConfigs =
@ -251,7 +346,7 @@ in
(name: config: {
home = config.home;
createHome = false;
initialPassword = "${name}-browser";
initialPassword = "${name} -browser";
shell = pkgs.bashInteractive;
isNormalUser = false;
isSystemUser = true;
@ -263,10 +358,15 @@ in
mainUser.extraGroups = builtins.attrNames cfg.configList;
};
environment.systemPackages = [ browserSelect (desktopFile browserSelect) ]
environment.systemPackages = [
browserSelect
(desktopFile browserSelect)
# allExcludes
]
++ browserExecutableList
++ (map (bin: desktopFile bin) browserExecutableList) ++ allBackupScripts
++ allCleanScripts ++ allKillScripts;
};
}