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

Add flake support #78

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

DontEatOreo
Copy link
Contributor

Closes #76

Context: #77 (comment)

About these lines:

src = pkgs.fetchFromGitHub {
  owner = "FedericoBruzzone";
  repo = "tgt";
  rev = "470b6052dd66ff55f6039bbf940902f503fb67e2";
  sha256 = "sha256-VO1KdAgx0hLYEegyotBO8eLPbA33KKEoanZRLqQCiHI=";
};

The reason I'm pinning to a specific commit is that:

  1. We're using cargoHash, which produces an exact hash of all the dependencies (plus other factors, e.g., pname), so any changes to the Cargo.lock will result in a completely different hash and be unable to build the flake.
  2. The flake.nix relies on a patch to fix build.rs in order to work properly on Nix
  3. I can only guarantee the functioning of the program and the successful build of that program for that commit right now, so leaving it as src = ./.; would just mean it breaks in the future and breaks the reproducible "promise"

I do not plan on adding support for a devShell as I don't know how to write Rust code or have any meaningful knowledge in Rust; thus, I can't guarantee a proper devShell experience

Although I would imagine anyone familiar with Nix who wants to develop this project would most likely have the know-how to add devShell support themselves better than I could.

Currently, it builds and runs on x86_64-linux and aarch64-darwin. I don't own an aarch64-linux or x86_64-darwin machine, but theoretically, they shouldn't have any issues either.

@FedericoBruzzone
Copy link
Owner

Wow! Thanks for your PR!

  1. We're using cargoHash, which produces an exact hash of all the dependencies (plus other factors, e.g., pname), so any changes to the Cargo.lock will result in a completely different hash and be unable to build the flake.

That's Ok!

  1. The flake.nix relies on a patch to fix build.rs in order to work properly on Nix

That's Ok, but I will try to release a new version with some bug fix. In that case, can I ping you in order you do a new small PR to remove the patch?

  1. I can only guarantee the functioning of the program and the successful build of that program for that commit right now, so leaving it as src = ./.; would just mean it breaks in the future and breaks the reproducible "promise"

Since I am not yet a nix user, what we should do to improve this mechanism?

Although I would imagine anyone familiar with Nix who wants to develop this project would most likely have the know-how to add devShell support themselves better than I could.

Can you open an Issue to track it?

Now, I was wondering how can tgt runs if ~/.tgt/config is empty. Can you provide me an answer :'D ?

@DontEatOreo
Copy link
Contributor Author

That's Ok, but I will try to release a new version with some bug fix. In that case, can I ping you in order you do a new small PR to remove the patch?

Yes! I will be glad to remove the patch

Since I am not yet a nix user, what we should do to improve this mechanism?

Sadly, you can't do much about this. You can ping me, when you want the flake updated though. Usually, unless something fundamentally changed (like the new system dependencies or changes to how the program is built), the only thing that will need to be changed for flake.nix to be up to date will be to bump the rev and hash

One automate solution could be for GitHub (using CI/CD) to try to update the hash and rev and make a new commit for the flake if just updating the rev and hash is enough for that new commit

Can you open an Issue to track it?

I could, but I see it as kind of useless. Pretty much 99% of the consumers/users of this flake will be adding it to their own flake via inputs and then straight into their system packages or just running nix run github:FedericoBruzzone/tgt

Now, I was wondering how can tgt runs if ~/.tgt/config is empty. Can you provide me an answer :'D ?

Well, you can't! I simply create the ~/.tgt/config path manually (after building tgt) and copied the files from ./config. Currently I'm not using any modules for this flake.nix, so I can't tamper with the "outside world"

@FedericoBruzzone
Copy link
Owner

Yes! I will be glad to remove the patch

Again, thank you so much!

I could, but I see it as kind of useless. Pretty much 99% of the consumers/users of this flake will be adding it to their own flake via inputs and then straight into their system packages or just running nix run github:FedericoBruzzone/tgt

Ok, then no problem :D

Well, you can't! I simply create the ~/.tgt/config path manually (after building tgt) and copied the files from ./config. Currently I'm not using any modules for this flake.nix, so I can't tamper with the "outside world"

Ok, perfect. So I think that we should add to the README this information, what you think about that?

@FedericoBruzzone
Copy link
Owner

Thanks for your contribution!

@FedericoBruzzone FedericoBruzzone merged commit b78b0ec into FedericoBruzzone:main Oct 28, 2024
@DontEatOreo DontEatOreo deleted the add-flake-support branch October 28, 2024 14:27
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.

[feature]: add flake.nix to package project in Nix
2 participants