-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
wren: init at 0.4.0 #189295
base: master
Are you sure you want to change the base?
wren: init at 0.4.0 #189295
Conversation
Co-authored-by: Nikolay Korotkiy <[email protected]>
Result of 1 package built:
|
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.
Hi !
Thanks for your contribution.
I've left some comments, left me know if this is clear enough.
, fetchpatch | ||
, python3 | ||
}: | ||
stdenv.mkDerivation rec { |
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 we should use the finalAttrs
pattern here.
The finalAttrs
pattern will let you remove the rec
keyword (see its implementation in Nix).
Why is this pattern preferred to rec
?
Let's take this simple code example:
mkDerivation rec {
foo = 1;
bar = foo + 1;
}
and then .overrideAttrs(old: { foo = 2; })
, you'll get { foo = 2; bar = 2; }
while with finalAttrs
pattern, it would work correctly because it's a real fixed point.
Let me share a couple of useful links regarding the finalAttrs
pattern:
- History: https://discourse.nixos.org/t/avoid-rec-expresions-in-nixpkgs/8293
- Documentation: https://nixos.org/manual/nixpkgs/unstable/#mkderivation-recursive-attributes
- Recent example of implementation: https://github.com/NixOS/nixpkgs/compare/17f96f7b978e61576cfe16136eb418f74fab9952..9e6ea843e473d34d4f379b8b0d8ef0425a06defe
Feel free to reach out if you need some assistance.
owner = "wren-lang"; | ||
repo = pname; | ||
rev = version; | ||
sha256 = "sha256-AUb17rV07r00SpcXAOb9PY8Ea2nxtgdZzHZdzfX5pOA="; |
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.
Prefer hash = ...
to sha256 = ...
Both currently work, but the former will make it easier if the algorithm ever needs to change.
Since there could be different hashing algorithms in use, this make sense.
# otherwise fails to build | ||
(fetchpatch { | ||
url = "https://patch-diff.githubusercontent.com/raw/wren-lang/wren-cli/pull/136.patch"; | ||
sha256 = "sha256-/c1vbc769U/WeLGZiEdnALaooOHQcpTybfbxz+KQYUM="; |
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.
Prefer hash = ...
to sha256 = ...
Both currently work, but the former will make it easier if the algorithm ever needs to change.
Since there could be different hashing algorithms in use, this make sense.
cli = | ||
callPackage ./cli.nix { }; | ||
in | ||
stdenv.mkDerivation rec { |
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 we should use the finalAttrs
pattern here.
The finalAttrs
pattern will let you remove the rec
keyword (see its implementation in Nix).
Why is this pattern preferred to rec
?
Let's take this simple code example:
mkDerivation rec {
foo = 1;
bar = foo + 1;
}
and then .overrideAttrs(old: { foo = 2; })
, you'll get { foo = 2; bar = 2; }
while with finalAttrs
pattern, it would work correctly because it's a real fixed point.
Let me share a couple of useful links regarding the finalAttrs
pattern:
- History: https://discourse.nixos.org/t/avoid-rec-expresions-in-nixpkgs/8293
- Documentation: https://nixos.org/manual/nixpkgs/unstable/#mkderivation-recursive-attributes
- Recent example of implementation: https://github.com/NixOS/nixpkgs/compare/17f96f7b978e61576cfe16136eb418f74fab9952..9e6ea843e473d34d4f379b8b0d8ef0425a06defe
Feel free to reach out if you need some assistance.
owner = "wren-lang"; | ||
repo = pname; | ||
rev = version; | ||
sha256 = "0w8n5lyn3wa1nmdyci0zi249w1qbq725cr1d9xsg067irq17v8k5"; |
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.
Prefer hash = ...
to sha256 = ...
Both currently work, but the former will make it easier if the algorithm ever needs to change.
Since there could be different hashing algorithms in use, this make sense.
|
||
src = fetchFromGitHub { | ||
owner = "wren-lang"; | ||
repo = pname; |
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.
repo = pname;
is nice for DRY but creates a binding that goes too far.
See further information about this here: nix-community/nixpkgs-lint#21
python3 util/test.py | ||
''; | ||
|
||
installPhase = '' |
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.
If you are overriding configurePhase
, buildPhase
, checkPhase
, installPhase
or any other phase, you should not forget about explicitly running pre and post-phase hooks like their original definitions do.
It is generally expected that an appropriate pre-phase hook (e.g. preBuild
) hook will run at the beginning of a phase (e.g. buildPhase
) and post-phase hook (e.g. postBuild
) will run at the end. Hooks are normally ran as a part of a phase so if you override a phase as a whole, you will need to add runHook hookName
calls (e.g. runHook preBuild
) manually.
Having phases run pre/post-phase hooks is important because many setup hooks insert their own code into them – omitting a hook might therefore prevent some setup hooks required for proper functionality of a package from running. Additionally, hooks are often inserted by developers into the package expression and by users when overriding a package using overrideAttrs
. Not running them can thus cause confusion why their code is not executed.
Examples
Before
installPhase = ''
your commands
'';
After
installPhase = ''
runHook preInstall
your commands
runHook postInstall
'';
Source: https://github.com/jtojnar/nixpkgs-hammering/blob/main/explanations/missing-phase-hooks.md
python3 util/test.py | ||
''; | ||
|
||
installPhase = '' |
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.
If you are overriding configurePhase
, buildPhase
, checkPhase
, installPhase
or any other phase, you should not forget about explicitly running pre and post-phase hooks like their original definitions do.
It is generally expected that an appropriate pre-phase hook (e.g. preBuild
) hook will run at the beginning of a phase (e.g. buildPhase
) and post-phase hook (e.g. postBuild
) will run at the end. Hooks are normally ran as a part of a phase so if you override a phase as a whole, you will need to add runHook hookName
calls (e.g. runHook preBuild
) manually.
Having phases run pre/post-phase hooks is important because many setup hooks insert their own code into them – omitting a hook might therefore prevent some setup hooks required for proper functionality of a package from running. Additionally, hooks are often inserted by developers into the package expression and by users when overriding a package using overrideAttrs
. Not running them can thus cause confusion why their code is not executed.
Examples
Before
installPhase = ''
your commands
'';
After
installPhase = ''
runHook preInstall
your commands
runHook postInstall
'';
Source: https://github.com/jtojnar/nixpkgs-hammering/blob/main/explanations/missing-phase-hooks.md
Description of changes
Wren is a small, fast, class-based concurrent scripting language #
Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax.
https://wren.io/
Packaging has been heavily adapted from the AUR package - https://aur.archlinux.org/packages/wren
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes