-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
factor-lang: Restructure package for easier extension #287852
base: master
Are you sure you want to change the base?
Conversation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/3438 |
81d9d58
to
3c888e6
Compare
b99ea67
to
3c9a4d2
Compare
I have also added a forgotten feature |
3c9a4d2
to
b806d09
Compare
Regarding the change in |
5c43520
to
7894f4d
Compare
The problem with codeowners is, that it doesn't properly work if you do not have merge 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.
lots of nits, but otherwise looking good
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
7894f4d
to
1e36ecc
Compare
1e36ecc
to
473372a
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/3696 |
473372a
to
e37e545
Compare
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
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.
Most build helpers would respect user-specified phases. For example, this is how buildGoModule
provides its buildPhase
:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/go/module.nix#L202
Are there solid reasons to prohibit users from specifying the buildPhase
and the installPhase
?
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
57361d5
to
f6fe543
Compare
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.
Some minor adjustments about arguments from attrs
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
f6fe543
to
be1b173
Compare
@ShamrockLee Thanks! I added the missing attributes. I must confess, it is not entirely clear to me when and with which arguments the inner function (mapping its arguments to |
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 haven't got an example to test the buildFactorApplication
build helper, but the framework seems much more complete after this refactoring. I'm looking forward to its merging!
appendToVar wrapperArgs --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" | ||
appendToVar wrapperArgs --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib |
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.
It's more often named makeWrapperArgs
. Making it a Bash array helps preserve command-line arguments containing spaces.
appendToVar wrapperArgs --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" | |
appendToVar wrapperArgs --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib | |
makeWrapperArgs+=(--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE") | |
makeWrapperArgs+=(--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib) |
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.
Your suggestion was my initial implementation. A previous reviewer suggested the (newer?) approach to use appendToVar
. Looking into its definition in pkgs/stdenv/generic/setup.sh
, it also uses arrays if applicable. So appendToVar
should be properly preserving command-line arguments as well.
You are right, although appendToVar
tries to use arrays to achieve the same goal, it does not seem to work as intended. Using compound assignment is the proper way to go.
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 had thought that appendToVar
only works on string-like Bash variables. Considering that, it might be a matter of design choices.
- If you want to enable users to specify
makeWrapperArgs
as an attribute even when__structuredAttrs
is not enabled, and you don't plan to give that non-structured derivation a way to add command-line arguments containing spaces,appendToVar
is the right way to go. - If you want to enable only the structured derivation to specify
makeWrapperArgs
and allow non-structured derivation to specify command-line arguments containing spaces, we could usemakeWrapperArgs+=()
.
As #318614 is merged, the first is the way forward. If it works, let's use appendToVar
instead.
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.
Although
appendToVar
tries to use arrays to achieve the same goal, it does not seem to work as intended.
What issues with appendToVar
have you encountered? It seems to work in nix-shell
:
nixpkgs_factor-lang on HEAD (41a2dde) [$]
❯ nix-shell --expr "(import ./. { }).hello.overrideAttrs { __structuredAttrs = true; }"
structuredAttrs is enabled
Using versionCheckHook
nixpkgs_factor-lang on HEAD (41a2dde) [$] via ❄️ impure
❯ echo "$__structuredAttrs"
1
nixpkgs_factor-lang on HEAD (41a2dde) [$] via ❄️ impure
❯ appendToVar foo hi
nixpkgs_factor-lang on HEAD (41a2dde) [$] via ❄️ impure
❯ declare -p foo
declare -a foo=([0]="hi")
nixpkgs_factor-lang on HEAD (41a2dde) [$] via ❄️ impure
❯ appendToVar foo Alice and Bob
nixpkgs_factor-lang on HEAD (41a2dde) [$] via ❄️ impure
❯ declare -p foo
declare -a foo=([0]="hi" [1]="Alice" [2]="and" [3]="Bob")
BTW, you may want to use _accumFlagsArray to harvest the flags collected by appendToVar
.
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 fixed that using __strcuturedAttrs
. Thanks.
pkgs/development/compilers/factor-lang/mk-factor-application.nix
Outdated
Show resolved
Hide resolved
All extra factor vocabularies reside in | ||
`pkgs/development/compilers/factor-lang/scope.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.
Does that mean
All extra factor vocabularies reside in | |
`pkgs/development/compilers/factor-lang/scope.nix`. | |
All extra Factor vocabularies are registered in `pkgs/development/compilers/factor-lang/scope.nix`. |
Should we move the file into pkgs/top-level
? How should people package a factor vocabulary?
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.
Yes it should likely go into pkgs/top-level
, but I am not sure about the rules that apply for files going there and how the mechanics work to integrate packages from there into the global set.
I don't understand your last comment. The section preceeding the sentence you remarked explains how vocabularies should be packaged. Vocabs are usually only data in a rigid directory structure, no compilation needed. They are not libraries that are compiled and referenced from the Factor runtime environment. Could that be a source of confusion? Should I spell this out?
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 have yet to gain prior experience with Factor and need to familiarize myself with it. When I started reviewing this PR, I searched the Internet for information. Please let me know if I need to include some of the concepts.
The article Creating a vocabulary for your first program from the Factor handbook states that a vocabulary could either sit inside the source tree of the program that uses it or stays outside the source tree. The article Working with code outside of the Factor source tree then suggests that an out-of-tree vocabulary could be injected either through the environment variable FATOR_ROOTS
(with a comma-separated PATH
-like structure) or by using the -roots
compiler flag.
In my experience, Nix packages inject dependencies in three ways:
- Include them in a list and pass them to an attribute. It is generally
buildInputs
andnativeBuildInputs
, but language-specific build helpers could provide their own (e.g., thedependencies
andbuild-system
ofbuildPythonPackage
). - Vendoring them through a single IFD. For example,
buildGoModule
makes a fixed-output derivationgoModules
containing all the downloaded Go modules listed ingo.mod
, and the hash of such FOD is specified throughvendorHash
.buildRustPackage
also uses a similar strategy. - Feed the dependency list to a command-line utility to generate Nix expressions containing all dependencies. This is what most of the
*2nix
projects do. It allows each dependency to be fetched as a separate FOD, but the package would come with a sizeable auto-generated code that would be hard to review manually.
mkFactorApplication
seems to take the first approach, but I have yet to figure out which attribute it uses to accept the dependencies.
Could you show us an example of how to package a Factor vocabulary as a derivation in the manual? For example, the application painter depends on a vocabulary bresenham. How do we include bresenham
when packaging painter
?
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.
Yes, it should likely go into
pkgs/top-level
, but I am not sure about the rules that apply for files going there and how the mechanics work to integrate packages from there into the global set.
It seems that no magic is happening there. We only need to move the file and change the path in the factor-lang-scope =
line in all-packages.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.
Factor is not very mature when it comes to inclusion of out-of-tree vocabularies. FACTOR_ROOT
and -roots
only for end-user consumption. High-jacking them for distribution did not prove viable in my earlier attempts. Thus, I opted for the first approach, which constructs a new runtime including all vocabularies in a single directory tree.
I will package painter and bresenham as an example.
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.
@ShamrockLee I finally came around to update the PR. I added the bresenham library as a show-case and added painter in the manual as an example (It is not mature enough to be packaged). I also solved the issue of "propagated" inputs. So, vocabularies (factor libraries) that need certain libraries or binaries in the runtime can propagate this to consuming applications. Depending on a vocabulary automatically depends on the necessary libraries and binaries as well.
675e893
to
9c65abb
Compare
9c65abb
to
41a2dde
Compare
@ShamrockLee Thanks for all your help and comments so far. I made the adaptations. |
8d414a8
to
2147711
Compare
2147711
to
00b237d
Compare
Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.