Skip to content

Commit

Permalink
Fix: backwards incompat change
Browse files Browse the repository at this point in the history
  • Loading branch information
LovingMelody committed Jan 5, 2025
1 parent 3470acf commit 3441eb9
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 130 deletions.
11 changes: 3 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,18 @@
inputs@{ flake-parts, self, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
./modules
inputs.flake-parts.flakeModules.easyOverlay
inputs.flake-parts.flakeModules.modules
inputs.treefmt-nix.flakeModule
];
systems = [ "x86_64-linux" ];
flake = {

githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
checks =
(inputs.nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.checks)
// (inputs.nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.packages);
};
modules = {
nixos = {
StarCitizen = import ./modules/nixos/star-citizen;
};
};
};
perSystem =
{
Expand All @@ -62,8 +57,8 @@
pins = import ./npins;
in
{
xwayland = pkgs.xwayland.overrideAttrs (p: {
patches = (p.patches or [ ]) ++ [ ./patches/ge-xwayland-pointer-warp-fix.patch ];
xwayland = pkgs.xwayland.overrideAttrs (_p: {
patches = [ ./patches/ge-xwayland-pointer-warp-fix.patch ];
});
star-citizen-helper = pkgs.callPackage ./pkgs/star-citizen-helper { };

Expand Down
4 changes: 4 additions & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ ... }:
{
imports = [ ./nixos/star-citizen/default.nix ];
}
249 changes: 127 additions & 122 deletions modules/nixos/star-citizen/default.nix
Original file line number Diff line number Diff line change
@@ -1,129 +1,134 @@
{ self, ... }:
{
self,
config,
lib,
pkgs,
...
}:
let
flake-packages = self.packages.${pkgs.system};
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; };
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;
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 ""}
flake.nixosModules.StarCitizen =
{
config,
lib,
pkgs,
...
}:
let
flake-packages = self.packages.${pkgs.system};
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;
};
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;
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
'';
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))
};
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))
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 {
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";
}
];
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;
};
};
environment.systemPackages = [ cfg.package ];
nixpkgs.overlays = lib.optional cfg.includeOverlay self.overlays.default;
};
}

0 comments on commit 3441eb9

Please sign in to comment.