pimsync: ensure local storage directories exist (#8359)
pimsync: ensure local storage directories exist Unfortunately pipsync will throw an error if it trys to write into a nonexistant local storage directory. This patch ensures that all local storage directories are present for accounts with pimsync enabled. * pimsync: use tmpfiles to create storage dirs * pimsync: fix tests * pimsync: only use tmpfiles on linux * pimsync: format * pimsync: use mkdir to create storage dirs if systemd is not available
This commit is contained in:
parent
167452eb4c
commit
cdf6d7d594
2 changed files with 23 additions and 0 deletions
|
|
@ -112,6 +112,15 @@
|
|||
];
|
||||
|
||||
accountSettings = calendarConfig ++ contactConfig;
|
||||
|
||||
localStorageDir = name: acc: lib.attrsets.getAttrFromPath [ "local" "path" ] acc;
|
||||
|
||||
calendarLocalStorageDirs = lib.mapAttrsToList localStorageDir calendarAccounts;
|
||||
contactLocalStorageDirs = lib.mapAttrsToList localStorageDir contactAccounts;
|
||||
localStorageDirs = calendarLocalStorageDirs ++ contactLocalStorageDirs;
|
||||
|
||||
mkTmpFileRule = (dir: ''d ${dir} 0755 ${config.home.username} ${config.home.username} - -'');
|
||||
tmpFileRules = map mkTmpFileRule localStorageDirs;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
meta.maintainers = [ lib.maintainers.antonmosich ];
|
||||
|
|
@ -144,6 +153,18 @@
|
|||
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
systemd.user.tmpfiles.rules = lib.optionals pkgs.stdenv.hostPlatform.isLinux tmpFileRules;
|
||||
|
||||
home.activation.createDavDirectories = lib.mkIf (!pkgs.stdenv.hostPlatform.isLinux) (
|
||||
let
|
||||
directoriesList = localStorageDirs;
|
||||
mkdir = (dir: ''[[ -L "${dir}" ]] || run mkdir -p $VERBOSE_ARG "${dir}"'');
|
||||
in
|
||||
lib.hm.dag.entryAfter [ "linkGeneration" ] (
|
||||
lib.strings.concatMapStringsSep "\n" mkdir directoriesList
|
||||
)
|
||||
);
|
||||
|
||||
xdg.configFile."pimsync/pimsync.conf".text = lib.hm.generators.toSCFG { } (
|
||||
accountSettings ++ cfg.settings
|
||||
);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
];
|
||||
};
|
||||
|
||||
test.stubs.systemd.outPath = null;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/pimsync/pimsync.conf
|
||||
assertFileContent home-files/.config/pimsync/pimsync.conf ${./basic.scfg}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue