New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dwarf-fortress: Refactor, round 2: let the user pick which version of the lazy pack to install #43470
Conversation
cd "$install_dir/share/dwarftherapist" | ||
update_path memory_layouts | ||
|
||
QT_QPA_PLATFORM_PLUGIN_PATH="@qt_plugin_path@" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to fix this? Seems to be the same as #37864.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it’s pretty much unavoidable. You could use wrapProgram though (it will generate a file that looks pretty close to this anyway).
--subst-var-by stdenv_shell ${stdenv.shell} \ | ||
--subst-var-by install $out \ | ||
--subst-var-by therapist ${dwarf-therapist} \ | ||
--subst-var-by qt_plugin_path "${pkgs.qt5.qtbase}/lib/qt-5.11/plugins/platforms" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be hardcoding the version, need to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
dfhack is currently broken with this, I don't think we're updating the MD5 correctly anymore. God this package is complicated... |
I wanted to say thanks. I love Dwarf Fortress. But could not solve the puzzle fully, what all packages do, and how to make tilesets/LNP work. Please, can you add comprehensive descriptions to packages? So people can understand what are those and how it works together. |
Yeah, it could use some examples. The docs are a little (accidentally) misleading in some places. Here's basically how to install the lazy pack with FPS enabled and a theme, assuming your reference to the unstable (unstable.dwarf-fortress-packages.dwarf-fortress-full.override {
theme = "cla";
enableFPS = true;
}) |
|
||
dwarf-fortress-full = callPackage ./lazy-pack.nix { }; | ||
|
||
dfhack = callPackage ./dfhack { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little concerned about having too many versions of each package here. Does dfhack not support older versions of dwarf fortress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. If you check their release page, they dropped 0.44.11 support in the 0.44.12-alpha1
release. The base game sometimes changes too much for them to retain backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at their release history, they always break backwards compatibility when Dwarf Fortress changes. Oi...
value = | ||
let | ||
# I can't believe this syntax works. Spikes of Nix code indeed... | ||
dwarf-fortress = callPackage ./game.nix { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to put these in the callPackage wrapper.nix {...}. It should only be needed there. I think the same thing can be done for dfhack as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've inlined those JSON files.
Maybe my knowledge of Nix is incomplete, but I think we might be stuck with the let ... in
syntax here, because of the dependencies between packages?
@@ -59,7 +75,6 @@ let | |||
|
|||
legends-browser = callPackage ./legends-browser {}; | |||
|
|||
twbt = callPackage ./twbt {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping this would be version independent. Is that not how it works currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Check out mifki/df-twbt:patches.hpp; there is a large if/elif defined(DF_$VERSION) chain. That version code is originally set in mifki's Makefile.
cd "$install_dir/share/dwarftherapist" | ||
update_path memory_layouts | ||
|
||
QT_QPA_PLATFORM_PLUGIN_PATH="@qt_plugin_path@" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it’s pretty much unavoidable. You could use wrapProgram though (it will generate a file that looks pretty close to this anyway).
# therefore uses many relative paths. | ||
wrapProgram $out/bin/dwarftherapist \ | ||
--run "cd $out/share/dwarftherapist" | ||
buildCommand = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. buildCommand will override symlinkJoin behavior. Is there a reason to use this instead of postBuild?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running in nix-shell, it seemed like the "unsymlink" code was trying to to stomp over a different package's init directory, and it complained about not being able able to delete init.txt
due to permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, here's the log when we use postBuild
rebased against latest master. The symlink alias (dwarftherapist/DwarfTherapist) now fails.
I should also note that I'm trying to use it in a container.
building '/nix/store/5r6wa7f8hlymgbf2ms90c9ljmsxy5dph-dwarf-therapist-40.1.1.drv'...
chmod: changing permissions of '/nix/store/q8pqivs0xh34vgil8hmh2xkzpwk18k0c-dwarf-therapist-40.1.1/bin/dwarftherapist': Operation not permitted
builder for '/nix/store/5r6wa7f8hlymgbf2ms90c9ljmsxy5dph-dwarf-therapist-40.1.1.drv' failed with exit code 1
cannot build derivation '/nix/store/w1ld9xwxchf7zwydi9zd1wzf7b88pv7k-dwarf-fortress-full.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/id7vygj7inr00zlwzzvynbj8z182nsa2-system-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5g52k9mq297c8allssnknxhmrzn4ma8f-nixos-system-df-18.03.132750.91b286c8935.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/bj4kbigg0x3cfy7kxy59axkn6ssgl3v4-etc-df.conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/r315hpn7122l851h15715vlvhak5lf4p-unit-container-df.service.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/pqkkn9h8qbaawqbla0yg5wadx0r67rpp-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/v88s4vvcggplz3d6ik50v3z5qhbm3xsx-nixos-system-battlespire-18.03.132750.91b286c8935.drv': 1 dependencies couldn't be built
error: build of '/nix/store/v88s4vvcggplz3d6ik50v3z5qhbm3xsx-nixos-system-battlespire-18.03.132750.91b286c8935.drv' failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to use stdenv.mkDerivation
. Is there a reason why symlinkJoin was necessary for the wrapper? It seems to work fine using stdenv.mkDerivation
and preferLocalBuild
like the DF wrapper.
}; | ||
in | ||
|
||
stdenv.mkDerivation rec { | ||
name = "dwarf-fortress-${dwarf-fortress.dfVersion}"; | ||
|
||
compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress.dfVersion); true) pkgs; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there may still be a use for this. Need to hear from other maintainers first on need for it though.
Still a few more changes necessary, good feedback so far. Apart from the code review comments, here's some other stuff I need to do:
Code review comments:
|
b234377
to
558fbb1
Compare
It looks like dfhack isn't working correctly because the wrapper's postBuild is never running. Any reason for this? |
Missed that error this whole time... the MD5 fixup wasn't running in the correct environment. |
Removing the [WIP] tag; most of the important changes are there now. This fixes the fact that you could potentially end up with an incompatible Dwarf Fortress/dfhack/Dwarf Therapist/unfuck combination before. |
@@ -1,4 +1,4 @@ | |||
{lib, fetchFromGitHub}: | |||
{lib, fetchFromGitHub, ...}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, was there previously. Can remove it.
Edit: NVM, I added it. Will still remove it. :-)
dfVersion = "0.44.12"; | ||
version = "${dfVersion}-r1"; | ||
dfhack-releases = { | ||
"0.43.05" = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on what criteria are releases included here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have less versions listed here, because it makes the build matrix one has to test rather big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewbauer added them in #43085. I agree, some of these versions are rather old.
Motivation for this change
Dwarf Fortress unfuck, dfhack, and TWBT are tied to specific Dwarf Fortress versions, which makes the package harder to maintain and useless for people who want to run an older (or newer) version of the lazy pack. Let the user decide the Dwarf Fortress version, and we'll choose the versions of unfuck, dfhack, and TWBT for them based on the latest available for those versions.
Also, improve the launch behavior of Dwarf Therapist by creating a symlink to
memory_layouts
in the user's home directory, similar to how Dwarf Fortress already behaves.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)