git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #5316 from prikhi/add-profile-sync-daemon

Add the Profile Sync Daemon Package & NixOS Module

commit9095a4bddd9b48dffeaa56708179184469cef777 authorwmertens <Wout.Mertens@gmail.com> dateSat 13 Dec 2014, 16:03 (12 years ago) parent707ee5e0df1c05
4 files changed+174
nixos/modules/module-list.nix+1 nixos/modules/services/desktops/profile-sync-daemon.nix+139 pkgs/tools/misc/profile-sync-daemon/default.nix+32 pkgs/top-level/all-packages.nix+2
nixos/modules/module-list.nix+1
@@ -137,6 +137,7 @@
137137 ./services/desktops/gnome3/seahorse.nix
138138 ./services/desktops/gnome3/sushi.nix
139139 ./services/desktops/gnome3/tracker.nix
140+ ./services/desktops/profile-sync-daemon.nix
140141 ./services/desktops/telepathy.nix
141142 ./services/games/ghost-one.nix
142143 ./services/games/minecraft-server.nix
nixos/modules/services/desktops/profile-sync-daemon.nixnew file+139
@@ -0,0 +1,139 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.psd;
7+
8+ configFile = ''
9+ ${if cfg.users != [ ] then ''
10+ USERS="${concatStringsSep " " cfg.users}"
11+ '' else ""}
12+
13+ ${if cfg.browsers != [ ] then ''
14+ BROWSERS="${concatStringsSep " " cfg.browsers}"
15+ '' else ""}
16+
17+ ${optionalString (cfg.volatile != "") "VOLATILE=${cfg.volatile}"}
18+ ${optionalString (cfg.daemonFile != "") "DAEMON_FILE=${cfg.daemonFile}"}
19+ '';
20+in {
21+ options.services.psd = with types; {
22+ enable = mkOption {
23+ type = bool;
24+ default = false;
25+ description = ''
26+ Whether to enable the Profile Sync daemon.
27+ '';
28+ };
29+
30+ users = mkOption {
31+ type = listOf str;
32+ default = [ ];
33+ example = [ "demo" ];
34+ description = ''
35+ A list of users whose browser profiles should be sync'd to tmpfs.
36+ '';
37+ };
38+
39+ browsers = mkOption {
40+ type = listOf str;
41+ default = [ ];
42+ example = [ "chromium" "firefox" ];
43+ description = ''
44+ A list of browsers to sync. Available choices are:
45+
46+ chromium chromium-dev conkeror.mozdev.org epiphany firefox
47+ firefox-trunk google-chrome google-chrome-beta google-chrome-unstable
48+ heftig-aurora icecat luakit midori opera opera-developer opera-beta
49+ qupzilla palemoon rekonq seamonkey
50+
51+ An empty list will enable all browsers.
52+ '';
53+ };
54+
55+ resyncTimer = mkOption {
56+ type = str;
57+ default = "1h";
58+ example = "1h 30min";
59+ description = ''
60+ The amount of time to wait before syncing browser profiles back to the
61+ disk.
62+
63+ Takes a systemd.unit time span. The time unit defaults to seconds if
64+ omitted.
65+ '';
66+ };
67+
68+ volatile = mkOption {
69+ type = str;
70+ default = "/run/psd-profiles";
71+ description = ''
72+ The directory where browser profiles should reside(this should be
73+ mounted as a tmpfs). Do not include a trailing backslash.
74+ '';
75+ };
76+
77+ daemonFile = mkOption {
78+ type = str;
79+ default = "/run/psd";
80+ description = ''
81+ Where the pid and backup configuration files will be stored.
82+ '';
83+ };
84+ };
85+
86+ config = mkIf cfg.enable {
87+
88+ systemd = {
89+ services = {
90+ psd = {
91+ description = "Profile Sync daemon";
92+ wants = [ "psd-resync.service" "local-fs.target" ];
93+ wantedBy = [ "multi-user.target" ];
94+ preStart = "mkdir -p ${cfg.volatile}";
95+
96+ path = with pkgs; [ glibc rsync gawk ];
97+
98+ unitConfig = {
99+ RequiresMountsFor = [ "/home/" ];
100+ };
101+
102+ serviceConfig = {
103+ Type = "oneshot";
104+ RemainAfterExit = "yes";
105+ ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon sync";
106+
107+ ExecStop = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon unsync";
108+ };
109+ };
110+
111+ psd-resync = {
112+ description = "Timed profile resync";
113+ after = [ "psd.service" ];
114+ wants = [ "psd-resync.timer" ];
115+ partOf = [ "psd.service" ];
116+
117+ path = with pkgs; [ glibc rsync gawk ];
118+
119+ serviceConfig = {
120+ Type = "oneshot";
121+ ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon resync";
122+ };
123+ };
124+ };
125+
126+ timers.psd-resync = {
127+ description = "Timer for profile sync daemon - 1 Hour";
128+ partOf = [ "psd-resync.service" "psd.service" ];
129+
130+ timerConfig = {
131+ OnUnitActiveSec = "${cfg.resyncTimer}";
132+ };
133+ };
134+ };
135+
136+ environment.etc."psd.conf".text = configFile;
137+
138+ };
139+}
pkgs/tools/misc/profile-sync-daemon/default.nixnew file+32
@@ -0,0 +1,32 @@
1+{ stdenv, fetchurl, rsync, glibc, gawk }:
2+
3+stdenv.mkDerivation rec {
4+ version = "v5.53";
5+ name = "profile-sync-daemon-${version}";
6+
7+ src = fetchurl {
8+ url = "http://github.com/graysky2/profile-sync-daemon/archive/${version}.tar.gz";
9+ sha256 = "0m7h9l7dndqgb5k3grpc00f6dpg73p6h4q5sgkf8bvyzvcbdafwx";
10+ };
11+
12+ installPhase = "PREFIX=\"\" DESTDIR=$out make install-systemd-all";
13+
14+ preferLocalBuild = true;
15+
16+ meta = with stdenv.lib; {
17+ description = "Syncs browser profile dirs to RAM";
18+ longDescription = ''
19+ Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your
20+ browser's profile in tmpfs and to periodically sync it back to your
21+ physical disc (HDD/SSD). This is accomplished via a symlinking step and
22+ an innovative use of rsync to maintain back-up and synchronization
23+ between the two. One of the major design goals of psd is a completely
24+ transparent user experience.
25+ '';
26+ homepage = https://github.com/graysky2/profile-sync-daemon;
27+ downloadPage = https://github.com/graysky2/profile-sync-daemon/releases;
28+ license = licenses.mit;
29+ maintainers = [ maintainers.prikhi ];
30+ platforms = platforms.linux;
31+ };
32+}
pkgs/top-level/all-packages.nix+2
@@ -2171,6 +2171,8 @@ let
21712171
21722172 prey-bash-client = callPackage ../tools/security/prey { };
21732173
2174+ profile-sync-daemon = callPackage ../tools/misc/profile-sync-daemon { };
2175+
21742176 projectm = callPackage ../applications/audio/projectm { };
21752177
21762178 proot = callPackage ../tools/system/proot { };