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

fix(nix): Set nix setup #18

Merged
merged 4 commits into from
Jun 9, 2024
Merged

Conversation

amatrelan
Copy link
Contributor

@amatrelan amatrelan commented Jun 9, 2024

  • Workflow to build nix on commits and pushes
  • Take nyaa version from Cargo.toml to simpler version management

was some problem with action but now seems to work.

- Workflow to build nix on commits and pushes
- Take nyaa `version` from `Cargo.toml` to simpler version management
default.nix Show resolved Hide resolved
@@ -0,0 +1,14 @@
name: "Test build nix"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This workflow simply runs nix build so if there comes a error it can be caught

@@ -1,14 +1,12 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.rustPlatform.buildRustPackage rec {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rec is needed when you reference same scope variable multiple times, in here it's not needed

default.nix Show resolved Hide resolved
Comment on lines +4 to +9
version =
(builtins.fromTOML (
builtins.readFile ./Cargo.toml
))
.package
.version;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You seemed to put it manually but it can be done like this too so it takes from Cargo.toml version variable

Comment on lines -6 to -11
# src = fetchFromGitHub {
# owner = "Beastwick18";
# repo = "nyaa";
# rev = "v${version}";
# hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
# };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section is needed only in nixpkgs when you publish it there, so in https://github.com/NixOS/nixpkgs

(I wasn't clear enough in previous issue discussion).

@amatrelan
Copy link
Contributor Author

So basically if you publish your package to nixpkgs then most of these nix files can be removed if you don't use it yourself for development.

Flakes are new declaration "model" for nix and they can be used directly in other flakes.

For example my system configuration is made with flake so I can use in imports directly this repository now that it has flake.nix file and don't need to do any custom things for it. But if you publish to nixpkgs then I could use it from nixpkgs.nyaa so that flake and other are not needed anymore.

But I recommend to keep flake setup still in this repository so people can use "latest and greatest" nyaa even if it's not updated to nixpkgs, if they use flakes.

@Beastwick18
Copy link
Owner

Changes look good to me 😄

Thanks for helping with the nix configuration, I think I understand it much better now. Next version should be done soon once I'm done with documentation. After that, I'll get everything ready for adding to nixpkgs.

Now there should be less accidental bricking of the nix build too 😅

@Beastwick18
Copy link
Owner

Looks like the action works just fine, I'll go ahead and merge it

Thanks again :)

@Beastwick18 Beastwick18 merged commit d5d7bf5 into Beastwick18:main Jun 9, 2024
4 checks passed
@Beastwick18
Copy link
Owner

Ok something I might have to do though is add caching. Seems to take about 8 min to complete. I was hoping after the first action it might've cached itself.

magic-nix-cache-action seems suitable so I'll try that out first.

@amatrelan
Copy link
Contributor Author

Yeah that was weirdly slow. Here nix.dev caching is good example, and seems to be exactly same what you pointed out.

nix.dev is good website when getting hang of nix development.

@amatrelan amatrelan deleted the nix_changes branch June 9, 2024 14:40
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