summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/per-user.nix
blob: 1b8d092bba89d7816dd0a68b7d69a9375f042772 (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
36
37
38
{ config, lib, pkgs, ... }:

with import <stockholm/lib>;

let
  cfg = config.krebs.per-user;

  out = {
    options.krebs.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 {
          name = "per-user.${name}";
          paths = packages;
        };
      });
      profiles = ["/etc/per-user/$LOGNAME"];
    };
  };

in out