summaryrefslogtreecommitdiffstats
path: root/tv/3modules/per-user.nix
blob: 8d21a01d9250a995b2f6287c0232b845da8f6038 (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
27
28
29
30
31
32
33
34
35
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.tv.per-user;

  out = {
    options.tv.per-user = api;
    config = imp;
  };

  api = mkOption {
    type = with types; attrsOf (submodule {
      options = {
        packages = mkOption {
          type = listOf path;
          default = [];
        };
      };
    });
    default = {};
  };

  imp = {
    environment = {
      etc = flip mapAttrs' cfg (name: { packages, ... }: {
        name = "per-user/${name}";
        value.source = pkgs.symlinkJoin "per-user.${name}" packages;
      });
      profiles = ["/etc/per-user/$LOGNAME"];
    };
  };

in out