Skip to content

Commit

Permalink
Rebase PR
Browse files Browse the repository at this point in the history
  • Loading branch information
DamitusThyYeetus123 committed Dec 31, 2024
1 parent 2979f66 commit c9d88fa
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,43 @@ in {
"${mode} '${file.target}' - - - - ${file.source}"
) (filter (f: f.enable && f.source != null) (attrValues files));
}) (filterAttrs (_: u: (u.enable && u.files != {})) cfg.users);
systemd.services = mapAttrs' (name: {files, ...}: {
name = "hjem-monitor-" + name;
value = {
wants = ["systemd-tmpfiles-setup.service" "nix-daemon.socket"];
after = ["nix-daemon.socket"];
wantedBy = ["multi-user.target"];
description = "Monitoring for Hjem files";
scriptArgs = "${toString (map (
file: file.target
) (filter (f: f.enable && f.source != null) (attrValues files)))}";
enableStrictShellChecks = true;
script = ''
#! ${pkgs.runtimeShell} -e
code=0
err=""
normal=""
if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test "$ncolors" -ge 8; then
err="$(tput bold)$(tput setaf 3)"
normal="$(tput sgr0)"
fi
fi
for var in "$@"
do
if [ ! -L "$var" ] ; then
echo "''${err}$var is not managed by Hjem due to a file conflict, please move or remove the current file.''${normal}"
code=1
fi
done
exit $code
'';
serviceConfig = {
Type = "exec";
};
};
}) (filterAttrs (_: u: u.files != {}) config.homes);
}

(mkIf (cfg.users != {}) {
Expand Down

0 comments on commit c9d88fa

Please sign in to comment.