summaryrefslogtreecommitdiff
path: root/custom/dotfiles.nix
blob: 275177d9368386e69afa6f87766d46d5a5aadcac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{ fetchgit
, lib
, findutils
, coreutils
}:

let
  dotfiles = fetchgit (rec {
    name = "dotfiles-${rev}";
    url = git://git.yggdrasil.li/dotfiles;
    rev = "920df251756c5de589f3a012778b714c32aac76b";
    sha256 = "6b279a53fe055104b86c5acd373f6e2cc3fd78934c64686bcf309068ed099b4d";
  });
  setupUser = name : {
    name = name.dir;
    value = ''
      cd ${dotfiles}
      ${findutils}/bin/find . -type d -print0 | ${findutils}/bin/xargs -0 -I '{}' -- ${coreutils}/bin/install -o ${name.owner} -g ${name.group} -d "${name.dir}/{}"
      ${findutils}/bin/find . -type f -print0 | ${findutils}/bin/xargs -0 -I '{}' -- ln -s -f "${dotfiles}/{}" "${name.dir}/{}"
      ${findutils}/bin/find . -type f -print0 | ${findutils}/bin/xargs -0 -I '{}' -- chown -h "${name.owner}:${name.group}" "${name.dir}/{}"
    '';
  };
in
  names : lib.listToAttrs (builtins.map setupUser names)