Skip to content
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

material-maker: init at 1.3 #331491

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

material-maker: init at 1.3 #331491

wants to merge 2 commits into from

Conversation

aurreland
Copy link

@aurreland aurreland commented Aug 1, 2024

Description of changes

Material Maker is a Tool based on Godot Engine that can be used to create textures procedurally and paint 3D models.

https://www.materialmaker.org/

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/package-godot-projects-to-nixpkgs/49923/15

@aurreland
Copy link
Author

Its running checks for darwin, I've not package it for darwin because i doesnt have a mac and it would be pointless as they could install it via a .dmg. Should i try to add darwin compatibity or maybe enable something so it doesnt bother about it ?

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

If it can be done, I don't see why we shouldn't package this for mac as well. We should refactor the current derivation first, though, then we'll look into doing that.

I'm currently in the process if reviewing this, so you can expect my suggestions shortly.

By the way, perhaps it's best if you mark this PR as draft, since it's not ready to be merged.

@aurreland aurreland marked this pull request as draft August 1, 2024 14:11
Comment on lines 132 to 137
meta = with lib; {
homepage = "https://www.materialmaker.org/";
description = "Tool based on Godot Engine that can be used to create textures procedurally and paint 3D models.";
license = licenses.mit;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ aurreland ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
meta = with lib; {
homepage = "https://www.materialmaker.org/";
description = "Tool based on Godot Engine that can be used to create textures procedurally and paint 3D models.";
license = licenses.mit;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ aurreland ];
meta = {
homepage = "https://www.materialmaker.org/";
description = "Tool based on Godot Engine that can be used to create textures procedurally and paint 3D models.";
license = lib.licenses.mit;
platforms = lib.platforms.x86_64-linux;
maintainers = with lib.maintainers; [ aurreland ];

See #208242

pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Show resolved Hide resolved
Comment on lines 26 to 32
pname = "material-maker";
version = "1.3";

src = if stdenv.isLinux then fetchurl {
url = "https://github.com/RodZill4/material-maker/releases/download/1.3/material_maker_1_3_linux.tar.gz";
hash = "sha256-Y8+ZwXy3zqnsxqqaZeVgFSxLzmUkq+rBzbq8tEDc8/g=";
} else throw "unsupported platform";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fetchzip instead of fetchurl since it auto-unpacks. We can also reuse the defined attributes like pname, version and versionUnderscore

Suggested change
pname = "material-maker";
version = "1.3";
src = if stdenv.isLinux then fetchurl {
url = "https://github.com/RodZill4/material-maker/releases/download/1.3/material_maker_1_3_linux.tar.gz";
hash = "sha256-Y8+ZwXy3zqnsxqqaZeVgFSxLzmUkq+rBzbq8tEDc8/g=";
} else throw "unsupported platform";
pname = "material-maker";
inherit version;
src =
if stdenv.isLinux then
fetchzip {
url = "https://github.com/RodZill4/${pname}/releases/download/${version}/material_maker_${versionUnderscore}_linux.tar.gz";
hash = "sha256-WEu5gVfnswB5zYzu3leOL+hKOBzJbn48gHQKshlfOh4=";
}
else
throw "unsupported platform";

pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/ma/material-maker/package.nix Outdated Show resolved Hide resolved
@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

As a tip, you can batch commit multiple suggestions from the Files Changed tab, so you don't have to do it for each of them.

See Incorporating feedback in your pull request - GitHub Docs

@aurreland
Copy link
Author

Thanks for the huge work eljamm and d-brasher, i will look into how we could add support for darwin.

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

Since we're using finalAttrs, you'll have to precede every variable name that was defined inside the derivation with that. So:

  • ${version} -> ${version} (stays version because we defined it in the let in block
  • ${pname} -> ${finalAttrs.pname}
  • ${meta.description} -> ${finalAttrs.meta.description}
  • ...

@aurreland
Copy link
Author

Good to know will change to this

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

Just as a plus, since we're inheriting version in the derivation, we can also do ${finalAttrs.version}, but that won't work for versionUnderscore since it wasn't inherited.

@aurreland
Copy link
Author

Should i pass it to ready now ?

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

Not yet, we still need to add darwin support.

@aurreland
Copy link
Author

How could we add support for darwin, because we are using binary do they work out of the box ? or should we try to remake the package to be compiled like lorien does ?

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

If the platform is Darwin, we just copy the source to the Applications folder, as far as I know, at least.

@aurreland
Copy link
Author

I will try tomorrow on an old mac i got, but i won't be able to do much till 24/08 as i am going on a vacation.

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

Well, in that case you can open this PR for review because I think this is good enough to be merged.

If we can figure out how to package and test this on mac, then we'll include it here tomorrow, else we can add that in a separate PR if this gets merged first.

@aurreland aurreland marked this pull request as ready for review August 1, 2024 16:12
Copy link
Contributor

@eljamm eljamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@d-brasher
Copy link
Contributor

I think it could be a good thing to squash the commits in order to have just
maintainers: add aurreland (mind the s!) and material-maker: init at 1.3

See https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#commit-conventions

@eljamm
Copy link
Contributor

eljamm commented Aug 1, 2024

I totally forgot about that 🤦

Thanks!

@d-brasher
Copy link
Contributor

It now appears to miss a nixfmt pass (probably a trailing whitespace somewhere)

(if it can be of help, to squash commits I usually use git rebase --interactive [latest commit on master] and select all the commits to squash, this would prevent any merge conflict)

Comment on lines 97 to 121
''
runHook preInstall
''
+ lib.optionalString stdenvNoCC.isLinux ''
install -D -m 755 $src/material_maker.x86_64 $out/opt/material-maker
install -D -m 644 $src/material_maker.pck $out/opt/material-maker.pck

for dir in library nodes environments meshes export; do
cp -R $src/$dir $out/opt
done

cp -R $src/examples $examples

mkdir -p $out/share/
cp -R $src/doc $out/share

install -D -m 644 $src/doc/_static/icon.png -t $out/share/icons/hicolor/256x256/apps/

mkdir -p $out/bin
ln -s $out/opt/material-maker $out/bin/material-maker
''
+ lib.optionalString (builtins.elem "doc" finalAttrs.meta.outputsToInstall && stdenvNoCC.isLinux) ''
ln -s $doc/share/doc $out/opt/doc
''
+
lib.optionalString (builtins.elem "examples" finalAttrs.meta.outputsToInstall && stdenvNoCC.isLinux)
''
ln -s $examples $out/opt/examples
''
+ lib.optionalString stdenvNoCC.isDarwin ''
mkdir -p $out/Applications
find ./ -type d -name "*.app" -exec cp -r {} /destination/directory $out/Applications \;
''
+ ''
runHook postInstall
'';
Copy link
Contributor

@eljamm eljamm Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, looping over getAllOutputNames is more readable.

Also, since the command that installs the icon also creates the $out/share directory, we can move cp -R $src/doc $out/share below that so we don't have to mkdir -p $out/share/

Suggested change
''
runHook preInstall
''
+ lib.optionalString stdenvNoCC.isLinux ''
install -D -m 755 $src/material_maker.x86_64 $out/opt/material-maker
install -D -m 644 $src/material_maker.pck $out/opt/material-maker.pck
for dir in library nodes environments meshes export; do
cp -R $src/$dir $out/opt
done
cp -R $src/examples $examples
mkdir -p $out/share/
cp -R $src/doc $out/share
install -D -m 644 $src/doc/_static/icon.png -t $out/share/icons/hicolor/256x256/apps/
mkdir -p $out/bin
ln -s $out/opt/material-maker $out/bin/material-maker
''
+ lib.optionalString (builtins.elem "doc" finalAttrs.meta.outputsToInstall && stdenvNoCC.isLinux) ''
ln -s $doc/share/doc $out/opt/doc
''
+
lib.optionalString (builtins.elem "examples" finalAttrs.meta.outputsToInstall && stdenvNoCC.isLinux)
''
ln -s $examples $out/opt/examples
''
+ lib.optionalString stdenvNoCC.isDarwin ''
mkdir -p $out/Applications
find ./ -type d -name "*.app" -exec cp -r {} /destination/directory $out/Applications \;
''
+ ''
runHook postInstall
'';
installPhase =
''
runHook preInstall
''
+ lib.optionalString stdenvNoCC.isLinux ''
install -D -m 755 $src/material_maker.x86_64 $out/opt/material-maker
install -D -m 644 $src/material_maker.pck $out/opt/material-maker.pck
for dir in library nodes environments meshes export; do
cp -R $src/$dir $out/opt
done
install -D -m 644 $src/doc/_static/icon.png -t $out/share/icons/hicolor/256x256/apps/
mkdir -p $out/bin
ln -s $out/opt/material-maker $out/bin/material-maker
cp -R $src/doc $out/share
cp -R $src/examples $examples
for output in $(getAllOutputNames); do
if [ "$output" == "doc" ]; then
ln -s $doc/share/doc $out/opt/doc
elif [ "$output" == "examples" ]; then
ln -s $examples $out/opt/examples
fi
done
''
+ lib.optionalString stdenvNoCC.isDarwin ''
mkdir -p $out/Applications
find ./ -type d -name "*.app" -exec cp -r {} /destination/directory $out/Applications \;
''
+ ''
runHook postInstall
'';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it but changed it so it queries outputsToInstall instead, i think this is wat it needs to follow, correct me if im wrong

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if the user wants to only install the out and not doc and examples they will override the meta.outputsToInstall because if you remove outputs it doesnt build anymore

@aurreland aurreland force-pushed the master branch 2 times, most recently from 27bfd22 to a1b6cfb Compare August 4, 2024 12:57
cp -r $src/doc $out/share
cp -r $src/examples $examples

for output in ${builtins.concatStringsSep " " finalAttrs.meta.outputsToInstall}; do
Copy link
Contributor

@eljamm eljamm Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for output in ${builtins.concatStringsSep " " finalAttrs.meta.outputsToInstall}; do
for output in $(getAllOutputNames); do

As I understand it, meta.outputsToInstall is used for the default outputs, which isn't a problem here since doc and examples are in the default already.

However, we will typically change outputs, so we need to match all cases from that. Also, if meta.outputsToInstall changes, the package will be rebuilt, and we don't want that to happen as changes to meta shouldn't cause a rebuild.

Example, try to build with:

nix-build -E 'with import ./. {}; (material-maker.overrideAttrs { outputs = ["out" "doc"]; })'
  • If outputsToInstall = finalAttrs.outputs;: No problem since overriding outputs will also override outputsToInstall and everything works. However, this doesn't sound correct to me because outputsToInstall is the default and shouldn't depend on outputs.

  • If we pin outputsToInstall = [ "out" "doc" "examples" ];: This doesn't work since we're looping over outputsToInstall which has "examples", but the overriden outputs does not, and so the destination $examples will not exist.

platforms = lib.platforms.darwin ++ (lib.intersectLists lib.platforms.linux lib.platforms.x86_64);
maintainers = with lib.maintainers; [ aurreland ];
mainProgram = "material-maker";
outputsToInstall = finalAttrs.outputs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to specify the outputs directly, here:

Suggested change
outputsToInstall = finalAttrs.outputs;
outputsToInstall = [
"out"
"doc"
"examples"
];

If outputs change, that shouldn't change the default outputs, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should move

cp -r $src/doc $out/share
cp -r $src/examples $examples

into the for loop ?

Copy link
Contributor

@eljamm eljamm Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kinda thinking the same as well, sure.

Copy link
Contributor

@eljamm eljamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @aurreland and @d-brasher for your amazing contributions.

This looks good to me 😁

@d-brasher
Copy link
Contributor

d-brasher commented Aug 4, 2024

Result of nixpkgs-review pr 331491 run on x86_64-linux 1

3 packages built:
  • material-maker
  • material-maker.doc
  • material-maker.examples

Also tested basic app functionality.

Copy link
Contributor

@d-brasher d-brasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too!

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1881

@aurreland
Copy link
Author

I think we can remove finalAttrs, I'll do it this evening if you don't see any problem.

@aurreland
Copy link
Author

Its currently not being used in the package. And I don't know if it's useful to have it in. It's difficult to find good docs about it.

@aurreland
Copy link
Author

And if we keep it, should we use less let in and more finalAttrs refs?

@d-brasher
Copy link
Contributor

This issue is the only thing I can find about let in vs finalAttrs.
It appears to be debated, but finalAttrs has the advantage to allow easy overrides.

You could indeed drop the use of let in and move everything inside mkDerivation using finalAttrs (imho it would be better), but I am by no means an expert on this.

If you choose to keep the let in as is, I think you can remove finalAttrs.

@aurreland
Copy link
Author

I'll look into moving everything into finalAttrs.

@aurreland
Copy link
Author

Does this looks good to you ? I'll squash when its finalized

@d-brasher
Copy link
Contributor

looks fine to me 👍

Co-Authored-By: d-brasher <175485311+d-brasher@users.noreply.github.com>
Co-Authored-By: Fedi Jamoussi <Fedi.Jamoussi@protonmail.ch>
@aurreland
Copy link
Author

We should be done this time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants