nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

nixos/bees: use the upstream service file

Instead of duplicating the options from the upstream service file and letting
them get out of sync, use the file directly and only configure the needed
overrides. In particular, the upstream improvements include the mounts not
being globally visible any more, so they can't be used for bypassing nosuid and
the like, and the custom cleanup script that performed the unmount becomes
unnecessary.

+19 -32
+19 -32
nixos/modules/services/misc/bees.nix
··· 97 97 ''; 98 98 }; 99 99 }; 100 - config = { 100 + config = lib.mkIf (cfg.filesystems != { }) { 101 + systemd.packages = [ pkgs.bees ]; 101 102 systemd.services = lib.mapAttrs' ( 102 103 name: fs: 103 104 lib.nameValuePair "beesd@${name}" { 104 - description = "Block-level BTRFS deduplication for %i"; 105 - after = [ "sysinit.target" ]; 106 - 107 - serviceConfig = 108 - let 109 - configOpts = [ 110 - fs.spec 111 - "verbosity=${toString fs.verbosity}" 112 - "idxSizeMB=${toString fs.hashTableSizeMB}" 113 - "workDir=${fs.workDir}" 105 + overrideStrategy = "asDropin"; 106 + serviceConfig = { 107 + ExecStart = 108 + let 109 + configOpts = [ 110 + fs.spec 111 + "verbosity=${toString fs.verbosity}" 112 + "idxSizeMB=${toString fs.hashTableSizeMB}" 113 + "workDir=${fs.workDir}" 114 + ]; 115 + configOptsStr = lib.escapeShellArgs configOpts; 116 + in 117 + [ 118 + "" 119 + "${pkgs.bees}/bin/bees-service-wrapper run ${configOptsStr} -- --no-timestamps ${lib.escapeShellArgs fs.extraOptions}" 114 120 ]; 115 - configOptsStr = lib.escapeShellArgs configOpts; 116 - in 117 - { 118 - # Values from https://github.com/Zygo/bees/blob/v0.6.5/scripts/beesd@.service.in 119 - ExecStart = "${pkgs.bees}/bin/bees-service-wrapper run ${configOptsStr} -- --no-timestamps ${lib.escapeShellArgs fs.extraOptions}"; 120 - ExecStopPost = "${pkgs.bees}/bin/bees-service-wrapper cleanup ${configOptsStr}"; 121 - CPUAccounting = true; 122 - CPUSchedulingPolicy = "batch"; 123 - CPUWeight = 12; 124 - IOSchedulingClass = "idle"; 125 - IOSchedulingPriority = 7; 126 - IOWeight = 10; 127 - KillMode = "control-group"; 128 - KillSignal = "SIGTERM"; 129 - MemoryAccounting = true; 130 - Nice = 19; 131 - Restart = "on-abnormal"; 132 - StartupCPUWeight = 25; 133 - StartupIOWeight = 25; 134 - SyslogIdentifier = "beesd"; # would otherwise be "bees-service-wrapper" 135 - }; 121 + SyslogIdentifier = "beesd"; # would otherwise be "bees-service-wrapper" 122 + }; 136 123 unitConfig.RequiresMountsFor = lib.mkIf (lib.hasPrefix "/" fs.spec) fs.spec; 137 124 wantedBy = [ "multi-user.target" ]; 138 125 }