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 in
allBrowser ++ xclipBrowser; allBrowser ++ xclipBrowser;
createBackupScript = name: home: backupHome: #createBackupScript = name: home: backupHome:
pkgs.writeShellScriptBin "${name}-backup" # sh # pkgs.writeShellScriptBin "${name}-backup" # sh
'' # ''
sudo -u ${name} \ # sudo -u ${name} \
${tarBin} \ # ${tarBin} \
--exclude=.cache \ # --exclude=.cache \
--exclude=Downloads \ # --exclude=.config/chromium/Default/Service\ Worker/CacheStorage \
--create \ # --exclude=.config/chromium/Default/IndexedDB \
--verbos \ # --exclude=".mozilla/firefox/[a-zA-Z0-9]+.default/storage" \
--lzma \ # --exclude=Downloads \
--file ${home}.tar.lzma \ # --create \
--directory ${home} \ # --verbos \
. # --lzma \
# --file ${home}.tar.lzma \
# --directory ${home} \
# .
# cp ${home}.tar.lzma ${backupHome}.tar.lzma
# '';
cp ${home}.tar.lzma ${backupHome}.tar.lzma createBackupScript = name: home: backupHome:
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 ${sudo} \
${tarBin} \
${concatStringsSep " " arguments} \
--create \
--verbos \
--lzma \
--file ${source}.tar.lzma \
--directory ${source} \
.
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 = allBackupScripts =
let let
filteredConfigs = filteredConfigs =
@ -251,7 +346,7 @@ in
(name: config: { (name: config: {
home = config.home; home = config.home;
createHome = false; createHome = false;
initialPassword = "${name}-browser"; initialPassword = "${name} -browser";
shell = pkgs.bashInteractive; shell = pkgs.bashInteractive;
isNormalUser = false; isNormalUser = false;
isSystemUser = true; isSystemUser = true;
@ -263,10 +358,15 @@ in
mainUser.extraGroups = builtins.attrNames cfg.configList; mainUser.extraGroups = builtins.attrNames cfg.configList;
}; };
environment.systemPackages = [ browserSelect (desktopFile browserSelect) ] environment.systemPackages = [
++ browserExecutableList browserSelect
++ (map (bin: desktopFile bin) browserExecutableList) ++ allBackupScripts (desktopFile browserSelect)
++ allCleanScripts ++ allKillScripts; # allExcludes
]
++ browserExecutableList
++ (map (bin: desktopFile bin) browserExecutableList) ++ allBackupScripts
++ allCleanScripts ++ allKillScripts;
}; };
} }