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

Nix package manager support #83

Open
interroobang opened this issue Mar 15, 2023 · 5 comments
Open

Nix package manager support #83

interroobang opened this issue Mar 15, 2023 · 5 comments

Comments

@interroobang
Copy link

Hi there!
Is there any plan about nix support?
Thanks in advance.

@interroobang interroobang changed the title nix support Nix package manager support Mar 15, 2023
@obmarg
Copy link
Collaborator

obmarg commented Mar 15, 2023

Hi @interroobang

I don't think we've got any specific plans to do things with nix. I've not used nix for a while, but I would have thought crux would just work if you were using nix? Is there some specific functionality we'd need to add to make that the case?

@interroobang
Copy link
Author

interroobang commented Mar 15, 2023

Thanks for reply. There is bunch of framework and tools. Also platforms to support. I really love that ffi approach you build, I just don't want to install and define them one by one.

If there could be an universal configuration, installation file for needs, it will be good. Just nix first come to in my mind :)

Thanks again this work and project. It's very promising in my opinion.

I could close issue if you want.

@obmarg
Copy link
Collaborator

obmarg commented Mar 15, 2023

Ah, I see. So are you imagining nix as a way of scaffolding out a project or managing that scaffolding as you maintain the project?

@interroobang
Copy link
Author

interroobang commented Mar 15, 2023

Ah, I see. So are you imagining nix as a way of scaffolding out a project or managing that scaffolding as you maintain the project?

Let me share something.

{
  description = "Nix flake for CRUX Hello World";

  # Flake inputs
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs"
    rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix
  };

  # Flake outputs
  outputs = { self, nixpkgs, rust-overlay }:
    let
      # Overlays enable you to customize the Nixpkgs attribute set
      overlays = [
        # Makes a `rust-bin` attribute available in Nixpkgs
        (import rust-overlay)
        # Provides a `rustToolchain` attribute for Nixpkgs that we can use to
        # create a Rust environment
        (self: super: {
          rustToolchain = super.rust-bin.stable.latest.default;
        })
      ];

      # Systems supported
      allSystems = [
        "x86_64-linux" # 64-bit Intel/AMD Linux
        "aarch64-linux" # 64-bit ARM Linux
        "x86_64-darwin" # 64-bit Intel macOS
        "aarch64-darwin" # 64-bit ARM macOS
        "aarch64-apple-darwin"
        "aarch64-apple-ios"
        "aarch64-apple-ios-sim"
        "aarch64-linux-android"
        "wasm32-unknown-unknown"
        "x86_64-apple-ios"
      ];

      # Helper to provide system-specific attributes
      forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
        pkgs = import nixpkgs { inherit overlays system; };
      });
    in
    {
      # Development environment output
      devShells = forAllSystems ({ pkgs }: {
        default = pkgs.mkShell {
          # The Nix packages provided in the environment
          packages = (with pkgs; [
            # The package provided by our custom overlay. Includes cargo, Clippy, cargo-fmt,
            # rustdoc, rustfmt, and other tools.
            rustToolchain
            rustup
            nodejs-18_x
            nodePackages_latest.pnpm
            trunk
            deno
          ]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ libiconv ]);
        };
      });
    };
}

Just a copy of a configuration that I found for being an example.
I tried and it works.

For trial, just copy the code, fill into flake.nix file on project root and type nix develop

I just don't want to install and configure all tools one by one, as I said before. By the way, I will try to make a flake file for all dependencies for all targets....

Thanks for reply.

Thanks for the crux project and your effort's.

Edit: Please init git repo in working directory and add flake.nix file to local repo.

@ahirner
Copy link

ahirner commented Jul 5, 2023

Thanks for the flake.nix @interroobang.

I just don't want to install and configure all tools one by one

Is your intent to only build the core for crux or also a "shell" around it with nix? If the aim is an end-to-end solution, I think one could create some great flake.nix templates, e.g. with https://github.com/tadfisher/android-nixpkgs.

Disclaimer: just got into crux and evaluating a few options for the best e2e developer experience.

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

No branches or pull requests

3 participants