fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Luc ChabassierAdd lib argument to homeManagerConfiguration (#2753)5ac84ebe

master
1.4 KiB66 linesraw
1{ configuration
2, pkgs
3, lib ? pkgs.lib
4
5  # Whether to check that each option has a matching declaration.
6, check ? true
7  # Extra arguments passed to specialArgs.
8, extraSpecialArgs ? { }
9}:
10
11with lib;
12
13let
14
15  collectFailed = cfg:
16    map (x: x.message) (filter (x: !x.assertion) cfg.assertions);
17
18  showWarnings = res:
19    let
20      f = w: x: builtins.trace "warning: ${w}" x;
21    in
22      fold f res res.config.warnings;
23
24  extendedLib = import ./lib/stdlib-extended.nix lib;
25
26  hmModules =
27    import ./modules.nix {
28      inherit check pkgs;
29      lib = extendedLib;
30    };
31
32  rawModule = extendedLib.evalModules {
33    modules = [ configuration ] ++ hmModules;
34    specialArgs = {
35      modulesPath = builtins.toString ./.;
36    } // extraSpecialArgs;
37  };
38
39  module = showWarnings (
40    let
41      failed = collectFailed rawModule.config;
42      failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
43    in
44      if failed == []
45      then rawModule
46      else throw "\nFailed assertions:\n${failedStr}"
47  );
48
49in
50
51{
52  inherit (module) options config;
53
54  activationPackage = module.config.home.activationPackage;
55
56  # For backwards compatibility. Please use activationPackage instead.
57  activation-script = module.config.home.activationPackage;
58
59  newsDisplay = rawModule.config.news.display;
60  newsEntries =
61    sort (a: b: a.time > b.time) (
62      filter (a: a.condition) rawModule.config.news.entries
63    );
64
65  inherit (module._module.args) pkgs;
66}