Skip to content

Commit

Permalink
lix-game: actually support overrideScope
Browse files Browse the repository at this point in the history
Didn't understand the docs correctly for makeScope/newScope, and somehow
managed to never test the example I wrote in the README, I guess?
  • Loading branch information
Rhys-T committed Oct 8, 2024
1 parent ace5ca6 commit 1389000
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Upstream is just called [Lix](https://www.lixgame.com/). I had originally writte

The game consists of several derivations that are somewhat interdependent (the game engine, the assets, the music, and the wrapper that puts it all together, as well as a standalone multiplayer server). To simplify the code and put all the configuration in one place, I've implemented it as a package set, or scope. To change the settings, instead of the base `lix-game` package, install something like this:
```nix
(lix-game-packages.overrideScope {
(lix-game-packages.overrideScope (self: super: {
# Default values are shown here
# Workarounds for SimonN/LixD#431 - see below
Expand All @@ -38,7 +38,7 @@ The game consists of several derivations that are somewhat interdependent (the g
# self-explanatory
includeMusic = true;
}).game
})).game
```

#### SimonN/LixD#431 - Magic pink won't become transparent on macOS
Expand Down
34 changes: 16 additions & 18 deletions pkgs/lix-game/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{ newScope, maintainers, stdenvNoCC }: let
{ lib, newScope, maintainers, stdenvNoCC }: let
inherit (stdenvNoCC) isDarwin;
callPackage = newScope self;
self = {
game = callPackage ./wrapper.nix {};
game-unwrapped = callPackage ./game.nix {};
assets = callPackage ./assets.nix {};
music = callPackage ./music.nix {};
server = callPackage ./server.nix {};

common = callPackage ./common.nix { inherit maintainers; };
highResTitleScreen = callPackage ./highResTitleScreen.nix {};

convertImagesToTrueColor = isDarwin;
disableNativeImageLoader = callPackage ({convertImagesToTrueColor}: isDarwin && !convertImagesToTrueColor) {};
useHighResTitleScreen = false;
includeMusic = true;
};
in self
in lib.makeScope newScope (self: let inherit (self) callPackage; in {
game = callPackage ./wrapper.nix {};
game-unwrapped = callPackage ./game.nix {};
assets = callPackage ./assets.nix {};
music = callPackage ./music.nix {};
server = callPackage ./server.nix {};

common = callPackage ./common.nix { inherit maintainers; };
highResTitleScreen = callPackage ./highResTitleScreen.nix {};

convertImagesToTrueColor = isDarwin;
disableNativeImageLoader = callPackage ({convertImagesToTrueColor}: isDarwin && !convertImagesToTrueColor) {};
useHighResTitleScreen = false;
includeMusic = true;
})

0 comments on commit 1389000

Please sign in to comment.