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

flake/dev: add nixvim-init command (under 'init' shell command) #2468

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions flake-modules/dev/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
command = ''${pkgs.python3.interpreter} ${./list-plugins.py} "$@"'';
help = "List plugins and get implementation infos";
}
{
name = "init";
command = lib.getExe (pkgs.callPackage ./init-script { });
help = "Initialize a new plugin in nixvim";
}
];
};
};
Expand Down
1 change: 1 addition & 0 deletions flake-modules/dev/init-script/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
183 changes: 183 additions & 0 deletions flake-modules/dev/init-script/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions flake-modules/dev/init-script/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "nixvim-init"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = "4.5.20"
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest using clap = { version = "4.5.20", features = ["derive"] }, it's quite a bit more ergonomic

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok thanks ! Actually, I don't even think that we will need clap at all.
Good to know though.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I don't even think that we will need clap at all.

I think we'll probably end wanting some decent argument parsing and help-text at some point...

Even if we have a mostly interactive UX it'd still be nice to be able to do things via CLI args.

13 changes: 13 additions & 0 deletions flake-modules/dev/init-script/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
pkgs,
}:
pkgs.rustPlatform.buildRustPackage {
pname = "nixvim-init";
version = "nightly";

src = ./.;
Copy link
Member

Choose a reason for hiding this comment

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

Generally, src = ./. is a bad idea because default.nix itself will also be considered a "source" of the derivation.

This means if default.nix is modified, the derivation needs to be rebuilt. Even if no source actually changed and the change to the nix file wouldn't actually need a rebuild.

Usually, you'd do something like src = ./src. I think you could also use a fileset or filtered source to filter out nix files, but those options seem a little overkill.

That said, this is a minor issue and we're already doing this in most of our other derivations, so it shouldn't block the PR if you'd rather keep it as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, very good to know.
Considering the simplicity of this application, I don't think that we should overthink it.
Neither the rust code itself or the default.nix will be modified too often.
Also, I expect the build time to be ridiculously short.

Copy link
Member

Choose a reason for hiding this comment

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

I still prefer having sources and nix files separate, (I don't think it has any downsides?), but I won't press on the issue.


cargoHash = "sha256-Y4Y5nNfYhfj80+DeCwjee0nRBctO1M9dJ0DwhGfkdF0=";

meta.mainProgram = "nixvim-init";
}
3 changes: 3 additions & 0 deletions flake-modules/dev/init-script/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
Copy link
Contributor

Choose a reason for hiding this comment

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

oooh we doin rust now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a huge noob, but I just want to do a simple nix-init clone for nixvim.

Copy link
Member

Choose a reason for hiding this comment

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

Not opposed to learning a bit of rust for this, just conscious I already have to improve my python to properly be capable of maintaining our other in-tree scripts... 😅

}