Skip to content

Commit

Permalink
Chore: Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LovingMelody committed May 13, 2024
1 parent 7c5e11d commit dd13e3f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 56 deletions.
29 changes: 18 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,35 @@
};
};

outputs = { self, systems, ... }@inputs:
outputs =
{ self, systems, ... }@inputs:
with inputs;
let
eachSystem = f:
nixpkgs.lib.genAttrs (import systems) (system:
f (nixpkgs.legacyPackages.${system}.extend self.overlays.default));
treefmtEval =
eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in {
eachSystem =
f:
nixpkgs.lib.genAttrs (import systems) (
system: f (nixpkgs.legacyPackages.${system}.extend self.overlays.default)
);
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in
{
overlays.default = (import ./overlays.nix) inputs;
nixosModules.StarCitizen = (import ./modules/nixos/star-citizen) self;
formatter =
eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
packages = eachSystem (pkgs: {
inherit (pkgs)
star-citizen-helper lug-helper star-citizen dxvk-gplasync;
star-citizen-helper
lug-helper
star-citizen
dxvk-gplasync
;
});
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = (nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.checks)
checks =
(nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.checks)
// (nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.packages);
};
};
Expand Down
47 changes: 27 additions & 20 deletions modules/nixos/star-citizen/default.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
flake-self:
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
flake-packages = flake-self.packages.${pkgs.system};
cfg = config.nix-citizen.starCitizen;
smartPackage = pname:
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; {
"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";
package = mkOption {
description = "Package to use for star-citizen";
type = types.package;
default = smartPackage "star-citizen";
apply = star-citizen:
apply =
star-citizen:
star-citizen.override (old: {
preCommands = ''
${cfg.preCommands}
${if cfg.helperScript.enable then
"${cfg.helperScript.package}/bin/star-citizen-helper"
else
""}
${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;
Expand Down Expand Up @@ -87,23 +93,24 @@ in with lib; {
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";
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";
}];
loginLimits = [
{
domain = "*";
type = "soft";
item = "nofile";
value = "16777216";
}
];
};
environment.systemPackages = [ cfg.package ];
};
Expand Down
27 changes: 15 additions & 12 deletions overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ inputs: final: prev:
let
pins = import ./npins;
nix-gaming = inputs.nix-gaming.packages.${final.system};
in {
in
{
star-citizen-helper = prev.callPackage ./pkgs/star-citizen-helper { };
dxvk-gplasync = let
inherit (pins) dxvk-gplasync;
inherit (dxvk-gplasync) version;
in final.dxvk.overrideAttrs (old: {
name = "dxvk-gplasync";
inherit version;
patches = [
"${dxvk-gplasync}/patches/dxvk-gplasync-${version}.patch"
"${dxvk-gplasync}/patches/global-dxvk.conf.patch"
] ++ old.patches or [ ];
});
dxvk-gplasync =
let
inherit (pins) dxvk-gplasync;
inherit (dxvk-gplasync) version;
in
final.dxvk.overrideAttrs (old: {
name = "dxvk-gplasync";
inherit version;
patches = [
"${dxvk-gplasync}/patches/dxvk-gplasync-${version}.patch"
"${dxvk-gplasync}/patches/global-dxvk.conf.patch"
] ++ old.patches or [ ];
});
lug-helper = prev.callPackage ./pkgs/lug-helper { inherit pins; };
inherit (nix-gaming) star-citizen;
}
43 changes: 36 additions & 7 deletions pkgs/lug-helper/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
{ stdenv, lib, makeDesktopItem, makeWrapper, copyDesktopItems, bash, coreutils
, findutils, gnome, zenity ? gnome.zenity, fetchFromGitHub, ... }:
let version = "2.16";
in stdenv.mkDerivation rec {
{
stdenv,
lib,
makeDesktopItem,
makeWrapper,
copyDesktopItems,
bash,
coreutils,
findutils,
gnome,
zenity ? gnome.zenity,
fetchFromGitHub,
...
}:
let
version = "2.16";
in
stdenv.mkDerivation rec {
name = "lug-helper";
inherit version;
src = fetchFromGitHub {
Expand All @@ -11,8 +25,16 @@ in stdenv.mkDerivation rec {
hash = "sha256-qtg0nrtaoyRCg/mYh19ZfjnfTGHtP46pFeBrqsXHRoY=";
};

buildInputs = [ bash coreutils findutils zenity ];
nativeBuildInputs = [ copyDesktopItems makeWrapper ];
buildInputs = [
bash
coreutils
findutils
zenity
];
nativeBuildInputs = [
copyDesktopItems
makeWrapper
];
desktopItems = [
(makeDesktopItem {
name = "lug-helper";
Expand All @@ -34,7 +56,14 @@ in stdenv.mkDerivation rec {
cp -r lib/* $out/share/lug-helper/
cp lug-logo.png $out/share/pixmaps/lug-helper.png
wrapProgram $out/bin/lug-helper \
--prefix PATH : ${lib.makeBinPath [ bash coreutils findutils zenity ]}
--prefix PATH : ${
lib.makeBinPath [
bash
coreutils
findutils
zenity
]
}
'';
meta = with lib; {
Expand Down
22 changes: 18 additions & 4 deletions pkgs/star-citizen-helper/default.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
{ lib, makeDesktopItem, rustPlatform, pname ? "star-citizen-helper", gnome
, zenity ? gnome.zenity, pkg-config, openssl, makeWrapper, ... }:
{
lib,
makeDesktopItem,
rustPlatform,
pname ? "star-citizen-helper",
gnome,
zenity ? gnome.zenity,
pkg-config,
openssl,
makeWrapper,
...
}:
let
tomlConfig = builtins.fromTOML (builtins.readFile ./Cargo.toml);
inherit (tomlConfig.package) name version;
binPath = lib.makeBinPath [ zenity ];
in rustPlatform.buildRustPackage {
in
rustPlatform.buildRustPackage {
inherit name version;
src = ./.;

cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkg-config makeWrapper ];
nativeBuildInputs = [
pkg-config
makeWrapper
];
buildInputs = [ openssl ];

postInstall = ''
Expand Down
5 changes: 3 additions & 2 deletions treefmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _: {
# Terraform formatter
programs = {
yamlfmt.enable = true;
nixfmt.enable = true;
nixfmt-rfc-style.enable = true;
deno.enable = true;
deadnix = {
enable = true;
Expand All @@ -13,10 +13,11 @@ _: {
};
statix.enable = true;
rustfmt.enable = true;
beautysh.enable = true;
};
settings.formatter = {
deadnix.excludes = [ "npins/default.nix" ];
nixfmt.excludes = [ "npins/default.nix" ];
nixfmt-rfc-style.excludes = [ "npins/default.nix" ];
deno.excludes = [ "npins/default.nix" ];
statix.excludes = [ "npins/default.nix" ];
yamlfmt.excludes = [ "npins/sources.json" ];
Expand Down

0 comments on commit dd13e3f

Please sign in to comment.