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

Add flag set-env-var to MixEnvironment, and rename old ones #11494

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

Conversation

bryanhonof
Copy link
Member

@bryanhonof bryanhonof commented Sep 12, 2024

Motivation

Closes: #11495
Closes: #10338

Context

#11490 (comment)

Ref: #11490

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from c7fae12 to 379c043 Compare September 12, 2024 16:34
@bryanhonof bryanhonof changed the title Add flag set-var to MixEnvironment, and rename old ones Add flag set-var to MixEnvironment, and rename old ones Sep 12, 2024
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 379c043 to 98e69fd Compare September 12, 2024 21:52
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Sep 12, 2024
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 98e69fd to 0d52f4b Compare September 12, 2024 23:12
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

I like that this makes the flag names more consistent, but I'm concerned about the user impact, since many users have opted in to the nix-command feature flag. Perhaps the old names could be kept?

Another issue is that the effect of --set-env-var FOO followed by --unset-env-var FOO may be unexpected. These should be either mutually inclusive, or handled in the order they occur, e.g. by using a map<string, optional<string>> to represent both setting and unsetting/keeping in a single map value. Using nullopt for both unsetting and keeping might be a little weird, so you could also do map<string, variant<bool, string>> instead.

This definitely needs new tests cases to

  • test the new flag
  • test the interactions.

@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 0d52f4b to c05fe9b Compare September 19, 2024 10:46
@bryanhonof
Copy link
Member Author

bryanhonof commented Sep 19, 2024

I have another question following yours.
What if the user does the following?

$ nix run --set-env-var FOO '' --unset-env-var FOO --set-env-var FOO '' ...

Since we're talking about storing it all in a map, the second appearance of --set-env-var FOO will just be ignored altogether, right?
I don't believe it'd be correct to add "weight" to certain flags, so they do survive something like this, maybe throw a warning to the user they've added a duplicate flag?

@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from c05fe9b to 289f2ea Compare September 19, 2024 13:44
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 288552b to 29ce075 Compare September 19, 2024 16:46
@bryanhonof
Copy link
Member Author

I gave the tests a go, let me know what you think.

@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 29ce075 to a20894e Compare September 19, 2024 16:58
@bryanhonof
Copy link
Member Author

Apparently, also fixes one more shellcheck case from #10795.

@bryanhonof bryanhonof changed the title Add flag set-var to MixEnvironment, and rename old ones Add flag set-env-var to MixEnvironment, and rename old ones Sep 19, 2024
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch 4 times, most recently from 58ac477 to 16f1163 Compare September 20, 2024 11:58
infinisil added a commit to NixOS/SC-election-2024 that referenced this pull request Sep 20, 2024
Some of these are a bit after the specified time period, but I also believe some of these items are difficult to gauge how much "impact" they had.

Helped organize, host, and run, the Summer of Nix Lecture Series 2022

- https://www.youtube.com/playlist?list=PLt4-_lkyRrOMWyp5G-m_d1wtTcbBaOxZk
- NixOS/infra#213

Helped organize, and host infra for, the Summer of Nix Lecture Series 2023

- https://www.youtube.com/playlist?list=PLt4-_lkyRrOPcBuz_tjm6ZQb-6rJjU3cf
- NixOS/infra#240

Helped organize, host, and was responsible for livestreaming infra during, NixCon Paris 2022

- https://www.youtube.com/playlist?list=PLgknCdxP89ReD6gxl755B6G_CI65z4J2e

Maintenance of some nixpkgs packages

- NixOS/nixpkgs#340223 (contribution after 2024-05-01)
- NixOS/nixpkgs#290084
- NixOS/nixpkgs#170089

Organized, and assembled a team for the FOSDEM 2023 Nix/NixOS Devroom

- https://discourse.nixos.org/t/fosdem-2023-nix-and-nixos-devroom/23133

Organizer & sole maintainer of the Config Management Camp Nix track

- https://discourse.nixos.org/t/config-management-camp-2023-ghent/23455
- https://discourse.nixos.org/t/config-management-camp-2024-ghent/33852
- https://discourse.nixos.org/t/cfgmgmtcamp-2025-is-looking-for-nix-presentations/51658 (contribution after 2024-05-01)

Public speaking & spreading awareness of Nix/NixOS

- https://youtu.be/gUjvnZ9ZwMs?si=nDiZTCpQj53wwq8P
- https://www.youtube.com/watch?v=hNcYPH5Q_pA&t=862s

The occasional dabble into the Nix C++ code base

- NixOS/nix#11494 (contribution after 2024-05-01)
- NixOS/nix#11490 (contribution after 2024-05-01)
- NixOS/nix#11489 (contribution after 2024-05-01)
- NixOS/nix#11349 (contribution after 2024-05-01)
- NixOS/nix#11241 (contribution after 2024-05-01)
- NixOS/nix#9557
- NixOS/nix#8788
- NixOS/nix#8212
- NixOS/nix#5147

General evangelism

Pretty much every event I attend, I'm talking about Nix, showing off Nix/NixOS, and just trying to get people to see how awesome this tool is.
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch 2 times, most recently from 5cb31b2 to 277dceb Compare September 26, 2024 22:08
@bryanhonof bryanhonof force-pushed the bryanhonof.feat-mixenvironment-set-env branch from 277dceb to 35599b8 Compare September 29, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
with-tests Issues related to testing. PRs with tests have some priority
Projects
Status: ⚖ To discuss
Development

Successfully merging this pull request may close these issues.

Give flags related to MixEnvironment better names Add option to "nix shell" command to set env variables
2 participants