8000 add support for buildNimPackage by lnk3 · Pull Request #862 · nix-community/nix-init · GitHub
[go: up one dir, main page]

Skip to content

add support for buildNimPackage - #862

Open
lnk3 wants to merge 1 commit into
nix-community:mainfrom
lnk3:build-nim-package
Open

lnk3 wants to merge 1 commit into
nix-community:mainfrom
lnk3:build-nim-package

Conversation

@lnk3
@lnk3 lnk3 commented Aug 24, 2026 •
Copy link
Copy Markdown

I followed the direction of #809

I added a test using https://github.com/dom96/choosenim, which I now realize is not maintained.
It shouldn't really matter, please let me know if you want me to change it.

I wasn't sure if I did explicit_strict_deps in the correct way, I looked in mod.rs and it seemed disabled by default:
https://github.com/lnk3/nix-init/blob/885cf34a90121fa436d6791d6799a0b4f1135f02/src/codegen/mod.rs#L105-L107
But I read somewhere it is better to have it and the docs seem to suggest so.

Other than that implementation is simple I'll add a few notes so code review goes easier.

Comment thread src/codegen/nim.rs
Comment on lines +53 to +59
fn find_nimble_file(src_dir: &Path) -> Option<String> {
std::fs::read_dir(src_dir)
.ok()?
.filter_map(Result::ok)
.find(|entry| entry.path().extension().is_some_and(|ext| ext == "nimble"))
.map(|entry| entry.file_name().to_string_lossy().into_owned())
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is to find detect the nimble file since it doesn't have a predefined name like config.nimble

There is a nimbleFile parameter for the nixpkgs builder function which is not mandatory but nice to have and trivial to precompute for the maintainer.

Comment thread src/codegen/nim.rs
Comment on lines +45 to +51
fn get_lock_path(out_dir: Option<&Path>) -> String {
out_dir
.map(|d| d.join("lock.json"))
.unwrap_or_else(|| PathBuf::from("lock.json"))
.display()
.to_string()
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If you use nix-init in a nixpkgs checkout it precomputed the out_dir to something like pkgs/by-name/xx/xxxxxxxx/, so I wanted to use it to help the maintainer generate the lockfile in the correct place.

The comment will result in a simple command the nix-init user can just copy and run

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.

1 participant

0