skel.nix 1.56 KB
Newer Older
Christopher League's avatar
Christopher League committed
1
{pkgs, lib, ...}:
Christopher League's avatar
Christopher League committed
2
3
4
5
6
7
let
  # Could make this into a derivation if I need to patch any
  # paths into the config files.
  skel = ./skel;

  rsync-args = "--copy-links --chmod u+w --verbose --recursive ${skel}/ $HOME";
Christopher League's avatar
Christopher League committed
8
9
10
11
12

  atom-pkgs = ["atom-html-preview"
               "lorem"
               "build" "busy-signal" # build requires busy-signal
              ];
Christopher League's avatar
Christopher League committed
13
14
15
in
{
  home-manager.users.student = {
16
17
18
19
20
21
22
23
24
25
    home.packages = [(
      pkgs.writeShellScriptBin "liucs-desktop-reset" ''
        echo 'This script will restore some of your desktop'
        echo 'settings to their original (or prescribed) state.'
        echo 'In particular, it affects the desktop panels,'
        echo 'background, the Atom editor, and Firefox.'
        echo
        echo 'Press enter to proceed or control-C to cancel.'
        read answer
        rsync ${rsync-args}
Christopher League's avatar
Christopher League committed
26
        ${lib.concatMapStringsSep "\n" (p: "apm install ${p}") atom-pkgs}
27
28
29
30
31
32
33
34
35
36
37
        echo
        echo 'Configuration files reset, we will now log out'
        echo 'and back in for changes to take effect.'
        echo '(Or press control-C to cancel log out)'
        for ((i=5; i>0; i--)); do
          echo -n "$i... "
          sleep 1
        done
        xfce4-session-logout --logout
      ''
    )];
Christopher League's avatar
Christopher League committed
38
39
40
    home.activation.copySkelConfigs = {
      before = [];
      after = [];
Christopher League's avatar
Christopher League committed
41
      data = ''
Christopher League's avatar
Christopher League committed
42
43
        $DRY_RUN_CMD rsync --ignore-existing ${rsync-args}
        for pkg in ${lib.concatStringsSep " " atom-pkgs}; do
Christopher League's avatar
Christopher League committed
44
45
46
47
          if [[ ! -d ~/.atom/packages/$pkg ]]; then
            $DRY_RUN_CMD apm install $pkg
          fi
        done
Christopher League's avatar
Christopher League committed
48
      '';
Christopher League's avatar
Christopher League committed
49
50
51
    };
  };
}