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

update nix and add dev shell #769

Conversation

Alizter
Copy link
Contributor

@Alizter Alizter commented Oct 17, 2023

We update the lock on the nix flake and also add a dev shell. This means you can do nix build to build the project and nix develop to drop into a development environment with cmake and clang.

We update the lock on the nix flake and also add a dev shell. This means
you can do `nix build` to build the project and `nix develop` to drop
into a development environment with cmake and clang.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@ArthurSonzogni
Copy link
Owner

Thank you!

I need to spend some time to understand nix again. Thanks for your patience.

@Alizter
Copy link
Contributor Author

Alizter commented Oct 19, 2023

No worries! Let me know if you have any questions.

let pkgs = import nixpkgs { inherit system; }; in
let llvm = pkgs.llvmPackages_latest; in
{
packages = rec {
Copy link
Owner

Choose a reason for hiding this comment

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

Question: I observed the construct with:

packages = rec {
  default = ...
  ftxui = default
}

worked better than:

packages.ftxui = ...

I don't understand why. Would you have an explanation?

Copy link
Contributor Author

@Alizter Alizter Oct 23, 2023

Choose a reason for hiding this comment

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

Hi, good question! When you go to a project and do a literal nix build then nix tries to build the "default" package in the flake. The previous setup called this ftxui which is not really useful since there is basically only one package to build here. I therefore renamed the existing packages.ftxui to packages.default, allowing nix build to work without any extra arguments.

In order to not break anybody else's workflow, I added packages.ftxui back in as an alias of packages.default. In Nix, if you are defining a set where one element refers to another at the time of definition, you will need it to be a recursive definition, hence the rec flag.

If you are happy with the rename, you can remove packages.ftxui and the rec flag. (You might have to also update any documentation you have for building the flake).

Also, notice that the default devShell is called devShells.default which allows you to do a simple nix develop in the repo in order to setup a dev environment. This is different from building the project as it also setups the development tools. In this case clang and cmake.

Hopefully that clears some things up!

@ArthurSonzogni ArthurSonzogni merged commit d548a18 into ArthurSonzogni:main Oct 23, 2023
6 checks passed
@ArthurSonzogni
Copy link
Owner

Thanks!

@Alizter Alizter deleted the ps/branch/update_nix_and_add_dev_shell branch October 23, 2023 12:26
ArthurSonzogni added a commit that referenced this pull request Dec 26, 2024
We update the lock on the nix flake and also add a dev shell. This means
you can do `nix build` to build the project and `nix develop` to drop
into a development environment with cmake and clang.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants