about summary refs log tree commit diff
path: root/pkgs/games/default.nix
blob: 555d6b6e8ed4194e7d438a36e1d723b60ee99968 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
{ config ? null, pkgs ? import <nixpkgs> {} }:

let
  configFilePath = let
    xdgConfig = builtins.getEnv "XDG_CONFIG_HOME";
    fallback = "${builtins.getEnv "HOME"}/.config";
    basedir = if xdgConfig == "" then fallback else xdgConfig;
  in "${basedir}/nixgames.nix";

  configFile = if !builtins.pathExists configFilePath then throw ''
    The config file "${configFilePath}" doesn't exist! Be sure to create it and
    put your HumbleBundle email address and password in it, like this:

    {
      humblebundle.email = "fancyuser@example.com";
      humblebundle.password = "my_super_secret_password";
    }
  '' else configFilePath;

  baseModule = { lib, ... }: {
    options = {
      packages = lib.mkOption {
        type = lib.types.attrsOf lib.types.unspecified;
        default = {};
        description = "Available collections of games.";
      };
    };

    config._module.args.pkgs = let
      mkBuildSupport = super: let
        self = import ./build-support {
          inherit (super) config;
          callPackage = lib.callPackageWith (super // self);
        };
      in self;
    in pkgs // (mkBuildSupport pkgs) // {
      pkgsi686Linux = pkgs.pkgsi686Linux
                   // (mkBuildSupport pkgs.pkgsi686Linux);
    };
  };

in (pkgs.lib.evalModules {
  modules = [
    (if config == null then configFilePath else config)
    baseModule ./humblebundle ./steam ./itch
  ];
}).config.packages