I’ve created the following default.nix file, but I’m not sure what to do with it. Can someone help me, or is this project just too old to be compiled with a modern version on NixOS?
On first look this project seems to be built with .NET Framework 4.8, which is Windows only AFAIK. I’ll look into it a bit more if it can be built with any newer .NET versions.
Edit: running with mono also might be possible, but I don’t have much experience with that.
By the way, if you just want to run the program instead of packaging, you can download the prebuild files from here and run LD_LIBRARY_PATH=/nix/store/path-to-libGL-in-the-store/lib mono MagicTile.exe You might be able to set LD_LIBRARY_PATH with a shell.nix file if you don’t want to manually use the libGL path.
I guess I don’t really need to package this up. I just want to run the program. Is there a way that I can get a shell script that just launches this for me? Even if that shell script just ends up calling nix-shell with the proper files and libraries in scope that would still be amazing. Preferably I’d like a script that automatically finds the store path, because I think that future system rebuilds might change the store path.I’d just want something where I can run ./magicTile.sh from the command line, and the program just launches.
You can use writeShellScriptBin to create that shell script and add it to your systemPackages. If you reference libGL by attribute ("${pkgs.libGL}/lib") then every time you rebuild it will create a new shell script pointing to the correct path.
Thank you for helping me with, but I seem to be getting some graphics issues here. I’ve used your default.nix and it seems to work correctly in the majority of cases. But some times things seems to work incorrectly. It’s mainly the spherical projection that screws up. It looks like some of the pixels are being drawn way to large. I’ve only screenshotted the relevant part of the program to highlight the error.
I just opened “Start here” and then “Rubik’s Cube” on the side panel
Would you be able to show me an example of this being done? I’m not sure how to do this, and also, I’m not sure if I could just have the compiled source hanging out in my /etc/nixos directory or if that would lead to issues.
Sure, there are a few ways to write the code depending on how you like your /etc/nixos/configuration.nix to be organized. I have a big let binding at the top of mine, so my way of writing this would be something like
{ config, lib, pkgs, ... }:
let
magictile-unwrapped = pkgs.fetchzip {
url = "http://www.roice3.org/magictile/downloads/MagicTile_mac.zip";
hash = ""; # fill this in later by running the build first and using the value it demands
};
magictile = pkgs.writeShellScriptBin "magictile" ''
# TODO: figure out what the right paths are; this is a guess
export LD_LIBRARY_PATH=${pkgs.libGL}/lib
exec ${pkgs.mono}/bin/mono ${magictile-unwrapped}/MagicTile.exe
'';
in
{
# among all the other stuff you have in configuration.nix...
environment.systemPackages = [
# ...
magictile
];
}
You don’t need to download the compiled program to anywhere in /etc; fetchzip will get it and keep it in your Nix store.
I’d prefer to have this in a separate file called something like “MagicTile.nix” and call that from my system configuration, if possible. Do you know how I can do that?
Sure, you can move any expression into another file and import ./that-file.nix where you would use it.
Or you can use modules, which are useful when you want to split out functionality that depends on other parts of your configuration. If you define environment.systemPackages in multiple modules, they will all be concatenated to define your final system.
Actually, there’s an issue with this is that the zip from Roice’s site actually has two subfolders, a __MACOSX metadata thing, and a the compiled binary in a MagicTile_6-20-18 folder. The fetchzip downloads the files properly, and then Nix complains that there are two sub-directories:
error: builder for '/nix/store/mnl1az7fzm1ybdm8dpmqnw9ldh0yw79q-source.drv' failed with exit code 1;
last 8 log lines:
>
> trying http://www.roice3.org/magictile/downloads/MagicTile_mac.zip
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 100 1499k 100 1499k 0 0 447k 0 0:00:03 0:00:03 --:--:-- 447k
> unpacking source archive /build/MagicTile_mac.zip
> error: zip file must contain a single file or directory.
> hint: Pass stripRoot=false; to fetchzip to assume flat list of files.
For full logs, run 'nix log /nix/store/mnl1az7fzm1ybdm8dpmqnw9ldh0yw79q-source.drv'.