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

treewide: *Flags convert to list from str #194256

Merged
merged 2 commits into from
Oct 12, 2022
Merged

Conversation

Artturin
Copy link
Member

@Artturin Artturin commented Oct 3, 2022

*Flags implies a list

slightly relevant:

stdenv: start deprecating non-list configureFlags #173172

the makeInstalledTests function in nixos/tests/installed-tests/default.nix isn't available outside of nixpkgs so
it's not a breaking change

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 22.11 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
buildInputs = [ zlib ];

cmakeFlags = lib.optional stdenv.hostPlatform.isStatic [
cmakeFlags = lib.optionals stdenv.hostPlatform.isStatic [
Copy link
Member

Choose a reason for hiding this comment

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

on the other hand this was wrong before and should definitely be changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

splitting in to a separate pr because i got some ideas

Copy link
Member Author

Choose a reason for hiding this comment

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

did it in this pr

@piegamesde
Copy link
Member

I'd appreciate some detailed description of the changes including their motivation, preferably in the PR description as well as in the commit messages.


Is this change a potentially breaking one? ("API" wise, ignoring mistakes in execution)

@@ -67,7 +67,7 @@ let
'' +
''
machine.succeed(
"gnome-desktop-testing-runner ${testRunnerFlags} -d '${tested.installedTests}/share'"
"gnome-desktop-testing-runner ${toString testRunnerFlags} -d '${tested.installedTests}/share'"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps use lib.escapeShellArgs then?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's already escaped in the execute function of the tester

f"{timeout_str} sh -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"

Copy link
Member

@jtojnar jtojnar Oct 6, 2022

Choose a reason for hiding this comment

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

That just ensures that the whole command is passed as a single argument to sh. But if we accept list of arguments, I would expect them to properly handle arbitrary values, unlike a argument string, where the user is expected to ensure individual arguments are properly escaped (compare Python’s subprocess.run with and without shell=True). Though annoyingly, e.g. makeFlags attribute currently does not follow this and values containing spaces will just break.

Copy link
Member Author

Choose a reason for hiding this comment

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

switched

@@ -12,7 +12,7 @@
} @ args :

let
mvnFlags = "-Dmaven.repo.local=$M2_REPO ${if doTest then "" else "-Dmaven.test.skip.exec=true"} ${extraMvnFlags}";
mvnFlags = builtins.toString [ "-Dmaven.repo.local=$M2_REPO" "${if doTest then "" else "-Dmaven.test.skip.exec=true"}" "${extraMvnFlags}" ];
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like:

Suggested change
mvnFlags = builtins.toString [ "-Dmaven.repo.local=$M2_REPO" "${if doTest then "" else "-Dmaven.test.skip.exec=true"}" "${extraMvnFlags}" ];
mvnFlags = builtins.toString ([
"-Dmaven.repo.local=$M2_REPO"
(lib.optionalString (!doTest) "-Dmaven.test.skip.exec=true")
] ++ extraMvnFlags);

Copy link
Member Author

Choose a reason for hiding this comment

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

extraMvnFlags is a string but github search shows only one non-nixpkgs usage of it so it should be fine to change it to a list
https://github.com/search?p=6&q=extraMvnFlags&type=Code
https://github.com/taktoa/nix-packages/blob/master/packages/kframework/default.nix
@taktoa

*Flags implies a list

slightly relevant:
> stdenv: start deprecating non-list configureFlags NixOS#173172

the makeInstalledTests function in `nixos/tests/installed-tests/default.nix` isn't available outside of nixpkgs so
it's not a breaking change
the argument to optional should not be list
@Artturin Artturin merged commit e66d2fd into NixOS:staging Oct 12, 2022
@Artturin Artturin deleted the treewides2 branch October 12, 2022 21:08
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.

5 participants