-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefault.nix
153 lines (150 loc) · 5.27 KB
/
default.nix
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{ self, ... }:
{
flake.nixosModules.StarCitizen =
{
config,
lib,
pkgs,
...
}:
let
flake-packages = self.packages.${pkgs.stdenv.hostPlatform};
cfg = config.nix-citizen.starCitizen;
smartPackage =
pname:
if (builtins.hasAttr pname pkgs) then
pkgs.${pname}
else
builtins.trace
"Warning: pkgs does not include ${pname} (missing overlay?) using nix-citizen's package"
flake-packages.${pname};
in
with lib;
{
options.nix-citizen.starCitizen = {
enable = mkEnableOption "Enable star-citizen";
# If you manually define your nixpkgs set, this wont work but it wont error
includeOverlay = mkEnableOption "Enable nix-citizen overlay" // {
default = true;
};
patchXwayland = mkEnableOption ''
Enable xwayland overlay with a patch intended to help fix cursor issues
'';
package = mkOption {
description = "Package to use for star-citizen";
type = types.package;
default = smartPackage "star-citizen";
apply =
star-citizen:
star-citizen.override (old: {
useUmu = cfg.umu.enable;
umu = pkgs.umu-launcher.override (prev: {
extraLibraries =
pkgs:
let
prevLibs = if prev ? extraLibraries then prev.extraLibraries pkgs else [ ];
additionalLibs =
with config.hardware.graphics;
if pkgs.stdenv.hostPlatform.is64bit then
[ package ] ++ extraPackages
else
[ package32 ] ++ extraPackages32;
in
prevLibs ++ additionalLibs;
});
preCommands = ''
${cfg.preCommands}
${if cfg.helperScript.enable then "${cfg.helperScript.package}/bin/star-citizen-helper" else ""}
${if cfg.gplAsync.enable then "DXVK_ASYNC=1" else ""}
'';
inherit (cfg) postCommands location;
dxvk = if cfg.gplAsync.enable then cfg.gplAsync.package else old.dxvk;
});
};
umu = {
enable = mkEnableOption "Enable umu launcher";
proton = mkOption {
type = types.str;
default = "GE-Proton";
description = "Proton Version";
};
};
gplAsync = {
enable = mkEnableOption "Enable dxvk-gplasync configs";
package = mkOption {
description = "Package for DXVK GPL Async";
default = smartPackage "dxvk-gplasync";
type = types.package;
};
};
location = mkOption {
default = "$HOME/Games/star-citizen";
type = types.str;
description = "Path to install star-citizen";
};
preCommands = mkOption {
default = "";
type = types.str;
description = "Additional commands to be run before star-citizen is run";
example = ''
export DXVK_HUD=compiler
export MANGO_HUD=1
'';
};
postCommands = mkOption {
default = "";
type = types.str;
description = "Additional commands to be run after star-citizen is run";
};
helperScript = {
enable = mkOption {
default = false;
type = types.bool;
};
package = mkOption {
description = "Package to use for star-citizen-helper";
type = types.package;
default = smartPackage "star-citizen-helper";
};
};
setLimits = mkOption {
type = types.bool;
default = true;
description = ''
Configures your system to meet some of the requirements to run star-citizen
Set `vm.max_map_count` default to `16777216` (sysctl(8))
Set `fs.file-max` default to `524288` (sysctl(8))
Also sets `security.pam.loginLimits` to increase hard (limits.conf(5))
Changes outlined in https://github.com/starcitizen-lug/knowledge-base/wiki/Manual-Installation#prerequisites
'';
};
};
config = mkIf cfg.enable {
assertions = [
(mkIf cfg.gplAsync.enable {
assertion = lib.strings.versionAtLeast (smartPackage "dxvk").version (smartPackage "dxvk-gplasync")
.version;
message = "The version of dxvk-gplasync is less than the current version of DXVK, needed patches are missing";
})
];
boot.kernel.sysctl = mkIf cfg.setLimits {
"vm.max_map_count" = mkOverride 999 16777216;
"fs.file-max" = mkOverride 999 524288;
};
security.pam = mkIf cfg.setLimits {
loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "16777216";
}
];
};
environment.systemPackages = [ cfg.package ];
nixpkgs.overlays =
lib.optional cfg.includeOverlay self.overlays.default
++ lib.optional cfg.patchXwayland self.overlays.patchedXwayland;
};
};
}