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

virtualization/amazon-init: log multiple nix channels, fix nix path. #76585

Merged

Conversation

mkaito
Copy link
Contributor

@mkaito mkaito commented Dec 27, 2019

Motivation for this change

The missing \n in the printf format string prevented multiple channels from
being logged.

The missing nixpkgs= in the NIX_PATH prevented nixos-rebuild from working
if the system configuration has any reference to nixpkgs.

Things done

Add missing \n.

Fix NIX_PATH.

Additionally:

  • Use process substitution instead of piping printf to avoid creating a subshell.
  • Set an empty IFS to avoid word splitting.
  • Add the -r flag to read to avoid mangling backslashes.
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@mkaito
Copy link
Contributor Author

mkaito commented Dec 27, 2019

I've built an AMI from this, spun up an EC2 instance with userdata as such:

### channel1
### channel2
{
  foo = bar;
}

And it works as expected.

@mkaito
Copy link
Contributor Author

mkaito commented Dec 28, 2019

Guess I was too tired last night. This change only affects the log output about what channels are being added. It's still probably good to fix it.

The missing `\n` in the printf format string prevented multiple channels from
being logged.

The missing `nixpkgs=` in the `NIX_PATH` prevented `nixos-rebuild` from working
if the system configuration has any reference to `nixpkgs`.

Additionally:

* Use process substitution instead of piping printf to avoid creating a subshell.
* Set an empty `IFS` to avoid word splitting.
* Add the `-r` flag to `read` to avoid mangling backslashes.
@mkaito mkaito force-pushed the mkaito/amazon-userdata-multiple-channels branch from 1e81e72 to 76ad649 Compare December 28, 2019 17:00
@mkaito mkaito changed the title virtualization/amazon-init: allow multiple nix channels. virtualization/amazon-init: log multiple nix channels, fix nix path. Dec 28, 2019
Copy link
Contributor

@tomberek tomberek left a comment

Choose a reason for hiding this comment

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

Also ran into this issue. Fix looks good

@mkaito
Copy link
Contributor Author

mkaito commented Dec 29, 2019

I've added git to the PATH of this unit for my servers, since some things seem to really want it, notably stackToNix derivations. I'm not sure that would be welcome here. What do you think?

@grahamc
Copy link
Member

grahamc commented Jan 23, 2020

I think having git available in these images would be useful, especially since "cloud-init" based provisioning is likely to need to fetch more expressions. Thanks for the PR.

@grahamc grahamc merged commit ebb644a into NixOS:master Jan 23, 2020
@grahamc
Copy link
Member

grahamc commented Jan 23, 2020

and I'm sorry for the wait :)

@mkaito
Copy link
Contributor Author

mkaito commented Jan 23, 2020 via email

@grahamc
Copy link
Member

grahamc commented Jan 23, 2020

No worries -- these improvements were improvements which stand on their own :)

@yorickvP yorickvP deleted the mkaito/amazon-userdata-multiple-channels branch January 23, 2020 12:38
@yorickvP
Copy link
Contributor

#78363

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.

None yet

4 participants