Page MenuHomePhabricator

[Nix] Factor out dev env variable logic to another file
ClosedPublic

Authored by jon on Aug 22 2022, 5:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 14, 12:16 PM
Unknown Object (File)
Tue, Jun 4, 1:12 AM
Unknown Object (File)
May 15 2024, 9:48 AM
Unknown Object (File)
Apr 21 2024, 3:18 PM
Unknown Object (File)
Apr 21 2024, 3:18 PM
Unknown Object (File)
Apr 21 2024, 3:18 PM
Unknown Object (File)
Apr 21 2024, 3:11 PM
Unknown Object (File)
Mar 6 2024, 11:44 PM
Subscribers

Details

Reviewers
abosh
varun
ashoat
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rCOMM45c89bdc1827: [Nix] Factor out dev env variable logic to another file
Summary

Move development environment variable logic to a separate file.

This is to move more shell logic into files which can be checked with CI tools
for shell code.

https://linear.app/comm/issue/ENG-1681

Test Plan
# Ensure you're not in a nix shell
[[ -n "$IN_NIX_SHELL" ]] && exit

nix develop

echo "$MYSQL_UNIX_PORT"
# points to something like "$HOME/.local/share/MariaDB/mysql.sock
  • Shellcheck CI

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Aug 22 2022, 5:26 PM

Looks good.

nix/dev-shell.nix
103 ↗(On Diff #15843)

So the .. usually won't work at the beginning of the ${...} with ShellCheck, but since this is Nix, Nix will fill in the path of ../scripts/source_development_defaults.sh before shellHook is linted by ShellCheck, which is why it's ok?

This revision is now accepted and ready to land.Aug 22 2022, 6:33 PM

Please link the stack

nix/dev-shell.nix
109–115 ↗(On Diff #15843)

D4875 seemingly adds this code, but it looks different there. Where's the diff that converts it in between? Please specify the stack on Phabricator (@abosh can help)

jon added inline comments.
nix/dev-shell.nix
103 ↗(On Diff #15843)

correct, this is nix. So it will be source "/nix/store/<hash>-source_development_defaults.sh". when it runs.

$ nix eval .#devShell.shellHook
"# Set development environment variable defaults\nsource \"/nix/store/9b3x1bjcwjy0rz5rcdi5a8vgygxmdl33-source_development_defaults.sh\"\n\n# Provide decent bash prompt\nsource \"/nix/store/27ibqm60iqy0q8ksyxk83xr344wfv730-better-prompt/bin/better-prompt\"\n\necho \"Welcome to Comm dev environment! :)\"\n"

The escaped output looks pretty bad, but you can see that there's just nix store paths.

shellHook is linted by ShellCheck,

shellHook isn't linted by shellCheck. writeShellApplication is a builder which will do this, but shellHook just gets evaluated.

109–115 ↗(On Diff #15843)

The mariadb code here was added in https://phab.comm.dev/D4750. D4875 just extends the model to ensure mariadb is available every nix develop

Please specify the stack on Phabricator

This revision was done on master. Should I still specify D4750?

(nix-shell) [08:34:15] jon@jon-desktop /home/jon/comm/comm (jonringer/move-shellhook-env-vars)
$ git log --oneline --decorate | head -n 2
80476a736 (HEAD -> jonringer/move-shellhook-env-vars) [Nix] Factor out dev env variable logic to another file
adf0b2a90 (tag: phabricator/base/15841, origin/master, origin/HEAD, master) [services] Tunnelbroker - Add FCM crate to Cargo dependencies
This revision now requires review to proceed.Aug 23 2022, 8:48 AM

Sorry, I really confused myself there

This revision is now accepted and ready to land.Aug 23 2022, 8:50 AM

Sorry, I really confused myself there

All good :)