summaryrefslogtreecommitdiff
path: root/custom/dotfiles.nix
blob: 305794da29828380af583512b424eead3a5b7ab2 (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
25
26
{ fetchgit
, lib
, findutils
, coreutils
}:

let
  # dotfiles =  fetchgit (rec {
  #   name = "dotfiles-${rev}";
  #   url = git://git.yggdrasil.li/dotfiles;
  #   rev = "ece2c194432de29699c457c98e7b7db7ff2733c8";
  #   sha256 = "c98beb620d02ab7d6671976b2a85fef2c2c7d7047794ac599c984e9fc65da6e2";
  # });
  dotfiles = ../dotfiles;
  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 \( -not -path './.config/systemd/*' \) -print0 | ${findutils}/bin/xargs -0 -I '{}' -- ln -s -f "${dotfiles}/{}" "${name.dir}/{}"
      ${findutils}/bin/find . -type f \( -path './.config/systemd/*' \) -print0 | ${findutils}/bin/xargs -0 -I '{}' -- cp -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)