A layer on top of the NixOS module system to make some tasks simpler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.nix 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. { config, lib, pkgs, ...}: with lib;
  2. let
  3. cfg = config.phoebe.backup;
  4. user = "backup";
  5. in
  6. {
  7. imports = [
  8. ./postgresql.nix
  9. ./rsync.nix
  10. ./script.nix
  11. ];
  12. #### Interface
  13. options.phoebe.backup = {
  14. user = {
  15. enable = mkEnableOption "Backup user and group.";
  16. name = mkOption {
  17. type = types.str;
  18. default = user;
  19. description = "User to perform backups as.";
  20. };
  21. group = mkOption {
  22. type = types.str;
  23. default = user;
  24. description = "Group for the backup user.";
  25. };
  26. };
  27. directory = mkOption {
  28. type = types.path;
  29. default = "/var/backup";
  30. description = ''
  31. Base directory where backups will be stored. Each host to
  32. back up will get a directory under this base directory.
  33. '';
  34. };
  35. };
  36. #### Implementation
  37. config = mkIf cfg.user.enable {
  38. users.users."${cfg.user.name}" = {
  39. description = "Backup user.";
  40. home = cfg.directory;
  41. createHome = true;
  42. group = cfg.user.group;
  43. isSystemUser = true;
  44. };
  45. users.groups."${cfg.user.group}" = {};
  46. };
  47. }