Merge pull request #103546 from mnacamura/cdda-small-fix
This commit is contained in:
commit
e355946df1
|
@ -34,6 +34,41 @@ cataclysm-dda.override {
|
|||
}
|
||||
```
|
||||
|
||||
## Important note for overriding packages
|
||||
|
||||
After applying `overrideAttrs`, you need to fix `passthru.pkgs` and
|
||||
`passthru.withMods` attributes either manually or by using `attachPkgs`:
|
||||
|
||||
```nix
|
||||
let
|
||||
# You enabled parallel building.
|
||||
myCDDA = cataclysm-dda-git.overrideAttrs (_: {
|
||||
enableParallelBuilding = true;
|
||||
});
|
||||
|
||||
# Unfortunately, this refers to the package before overriding and
|
||||
# parallel building is still disabled.
|
||||
badExample = myCDDA.withMods (_: []);
|
||||
|
||||
inherit (cataclysmDDA) attachPkgs pkgs wrapCDDA;
|
||||
|
||||
# You can fix it by hand
|
||||
goodExample1 = myCDDA.overrideAttrs (old: {
|
||||
passthru = old.passthru // {
|
||||
pkgs = pkgs.override { build = goodExample1; };
|
||||
withMods = wrapCDDA goodExample1;
|
||||
};
|
||||
});
|
||||
|
||||
# or by using a helper function `attachPkgs`.
|
||||
goodExample2 = attachPkgs pkgs myCDDA;
|
||||
in
|
||||
|
||||
# badExample # parallel building disabled
|
||||
# goodExample1.withMods (_: []) # parallel building enabled
|
||||
goodExample2.withMods (_: []) # parallel building enabled
|
||||
```
|
||||
|
||||
## Customizing with mods
|
||||
|
||||
To install Cataclysm DDA with mods of your choice, you can use `withMods`
|
||||
|
|
|
@ -33,7 +33,8 @@ let
|
|||
buildMod
|
||||
buildSoundPack
|
||||
buildTileSet
|
||||
wrapCDDA;
|
||||
wrapCDDA
|
||||
attachPkgs;
|
||||
|
||||
inherit pkgs;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA
|
||||
{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA, attachPkgs
|
||||
, tiles ? true, Cocoa
|
||||
, debug ? false
|
||||
, useXdgDir ? false
|
||||
|
@ -26,11 +26,6 @@ let
|
|||
"VERSION=git-${version}-${lib.substring 0 8 src.rev}"
|
||||
];
|
||||
|
||||
passthru = common.passthru // {
|
||||
pkgs = pkgs.override { build = self; };
|
||||
withMods = wrapCDDA self;
|
||||
};
|
||||
|
||||
meta = common.meta // {
|
||||
maintainers = with lib.maintainers;
|
||||
common.meta.maintainers ++ [ rardiol ];
|
||||
|
@ -38,4 +33,4 @@ let
|
|||
});
|
||||
in
|
||||
|
||||
self
|
||||
attachPkgs pkgs self
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ callPackage }:
|
||||
|
||||
{
|
||||
rec {
|
||||
buildMod = callPackage ./builder.nix {
|
||||
type = "mod";
|
||||
};
|
||||
|
@ -14,4 +14,33 @@
|
|||
};
|
||||
|
||||
wrapCDDA = callPackage ./wrapper.nix {};
|
||||
|
||||
# Required to fix `pkgs` and `withMods` attrs after applying `overrideAttrs`.
|
||||
#
|
||||
# Example:
|
||||
# let
|
||||
# myBuild = cataclysmDDA.jenkins.latest.tiles.overrideAttrs (_: {
|
||||
# x = "hello";
|
||||
# });
|
||||
#
|
||||
# # This refers to the derivation before overriding! So, `badExample.x` is not accessible.
|
||||
# badExample = myBuild.withMods (_: []);
|
||||
#
|
||||
# # `myBuild` is correctly referred by `withMods` and `goodExample.x` is accessible.
|
||||
# goodExample = let
|
||||
# inherit (cataclysmDDA) attachPkgs pkgs;
|
||||
# in
|
||||
# (attachPkgs pkgs myBuild).withMods (_: []);
|
||||
# in
|
||||
# goodExample.x # returns "hello"
|
||||
attachPkgs = pkgs: super:
|
||||
let
|
||||
self = super.overrideAttrs (old: {
|
||||
passthru = old.passthru // {
|
||||
pkgs = pkgs.override { build = self; };
|
||||
withMods = wrapCDDA self;
|
||||
};
|
||||
});
|
||||
in
|
||||
self;
|
||||
}
|
||||
|
|
|
@ -13,15 +13,17 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
pkgs' = lib.mapAttrs (_: mod: lib.filterAttrs availableForBuild mod) pkgs;
|
||||
pkgs' = lib.mapAttrs (_: mods: lib.filterAttrs isAvailable mods) pkgs;
|
||||
|
||||
availableForBuild = _: mod:
|
||||
isAvailable = _: mod:
|
||||
if isNull build then
|
||||
true
|
||||
else if build.isTiles then
|
||||
mod.forTiles
|
||||
mod.forTiles or false
|
||||
else if build.isCurses then
|
||||
mod.forCurses or false
|
||||
else
|
||||
mod.forCurses;
|
||||
false;
|
||||
in
|
||||
|
||||
lib.makeExtensible (_: pkgs')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA
|
||||
{ lib, callPackage, CoreFoundation, fetchFromGitHub, pkgs, wrapCDDA, attachPkgs
|
||||
, tiles ? true, Cocoa
|
||||
, debug ? false
|
||||
, useXdgDir ? false
|
||||
|
@ -19,11 +19,6 @@ let
|
|||
sha256 = "qhHtsm5cM0ct/7qXev0SiLInO2jqs2odxhWndLfRDIE=";
|
||||
};
|
||||
|
||||
passthru = common.passthru // {
|
||||
pkgs = pkgs.override { build = self; };
|
||||
withMods = wrapCDDA self;
|
||||
};
|
||||
|
||||
meta = common.meta // {
|
||||
maintainers = with lib.maintainers;
|
||||
common.meta.maintainers ++ [ skeidel ];
|
||||
|
@ -31,4 +26,4 @@ let
|
|||
});
|
||||
in
|
||||
|
||||
self
|
||||
attachPkgs pkgs self
|
||||
|
|
Loading…
Reference in New Issue