-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat/nix shell #48
base: main
Are you sure you want to change the base?
Feat/nix shell #48
Conversation
626df4f
to
f2388cb
Compare
# bao-project repositories. | ||
# To open an interactive nix-shell with the bao-project environment: | ||
# make nix-shell | ||
# To run a standalone commnand inside the nix-shell use: |
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.
Fix typo to command
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 will fix the typo.
# make nix-shell | ||
# To run a standalone commnand inside the nix-shell use: | ||
# make nix-shell-run cmd="command-to-run" | ||
# @param The command to run inside the nix-shell. |
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.
@param command-to-run The command to run inside the nix-shell.
I understood the description but it is in order to obey the doxygen comment style @param <variable_name> <description>
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 understand your comment, however, I just followed the description used in other rules on the makefile.
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.
We should also modify the README introduction to highlight we have this build environment two.
@ESCristiano I've updated the README introduction to mention the nix-shell facility. |
@josecm I've incorporated your suggestion and now nix can be used in a similar way as docker. I've also updated the PR description to reflect these changes. |
Signed-off-by: ESCristiano <[email protected]>
Signed-off-by: ESCristiano <[email protected]>
Signed-off-by: Jose Martins <[email protected]>
Signed-off-by: ESCristiano <[email protected]>
Signed-off-by: ESCristiano <[email protected]>
f9adfc2
to
74601fe
Compare
@nix-shell $(nix_dir)/shell.nix | ||
|
||
nix-shell-run: | ||
@nix-shell $(nix_dir)/shell.nix --run "$(cmd)" |
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 we have no documentation on this, I typically make variables that can be passed by the user upper case, so:
@nix-shell $(nix_dir)/shell.nix --run "$(cmd)" | |
@nix-shell $(nix_dir)/shell.nix --run "$(CMD)" |
nix-shell: | ||
@nix-shell $(nix_dir)/shell.nix | ||
|
||
nix-shell-run: | ||
@nix-shell $(nix_dir)/shell.nix --run "$(cmd)" |
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'd say first we could drop the nix
prefixes on the make targets because this makefile is standalone, specifying nix shell is redundant as this is a the nix makefile.
Also, it would be possible to have a single target and recipe that would behave differently if CMD
was specified by the user. In sum, something like:
nix-shell: | |
@nix-shell $(nix_dir)/shell.nix | |
nix-shell-run: | |
@nix-shell $(nix_dir)/shell.nix --run "$(cmd)" | |
ifneq ($(CMD),) | |
CMD:= --run $(CMD) | |
endif | |
shell: | |
@nix-shell $(nix_dir)/shell.nix $(CMD) |
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Bao Project and Contributors. All rights reserved | ||
|
||
root_dir?=$(realpath ..) |
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'd say the root dir by default should be:
root_dir?=$(realpath ..) | |
root_dir?=$(realpath ../../) |
Which, by our convention on how the ci repo should be included in the project's repos, should be the repo top-level directory and where all commands by default should run. And then, in the recipes:
nix-shell:
@cd $(root_dir) && nix-shell $(nix_dir)/shell.nix
nix-shell-run:
@cd $(root_dir) && nix-shell $(nix_dir)/shell.nix --run "$(cmd)"
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.
Since we have the nix only makefile, I think the modifications for this file should be removed.
non_build_targets+=nix-shell nix-shell-run | ||
|
||
define nix-shell-run | ||
cmd:=$1 | ||
endef |
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 don't think these are actually needed.
nix-shell-run: | ||
@nix-shell $(nix_dir)/shell.nix --run "$(cmd)" | ||
|
||
.PHONY: all |
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.
.PHONY: all | |
.PHONY: all nix-shell nix-shell-run |
eede022
to
f0fba61
Compare
PR Description
Add a nix-shell environment to contemplate all essential bao-project dependencies, allowing developers to effortlessly work across all bao-project repositories.
The user can utilize the bao-project nix-shell in three ways:
make -C ci/nix nix-shell-run cmd="your command"
For example, to run format check:
Supported Bao-Project Repositories
The ultimate goal is to provide support for all the bao-projects repositories. Currently, the nix-shell only handles dependencies for bao-docs. Support for the remaining repositories will be incorporated in the future.
Type of change
nix/shell.nix
nix/Makefile
Checklist: