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 Nix shell #1565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thomas-zahner
Copy link
Member

So I've installed Nix OS a week ago. Because of this I created this Nix shell. This way it should be possible to reliably build and develop lychee on any Nix system. I've taken the Custom Rust version example from Nix's documentation and simply added pkg-config and openssl. I'm not proficient at Nix so I'm not sure if this follows best practices. But I know it works on my system and since it's Nix it should basically work on any system :)

@niklaskorz what do you think about this.

@mre
Copy link
Member

mre commented Nov 12, 2024

From my side, this looks good.

@niklaskorz
Copy link

niklaskorz commented Nov 13, 2024

Sorry that we didn't get to go through it during RustLab anymore. A few possible improvements:

  1. Instead of setting rust-overlay, nixpkgs and other parameters as variables using let, make shell.nix a function, taking rust-overlay and pkgs as parameters that default to the values currently set in the variables. This makes them easier to override.
    {
      rust-overlay ? import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"),
      pkgs = import <nixpkgs> { overlays = [ rust-overlay ]; },
      rustVersion ? "latest", # using a specific version: "1.62.0"
      rust ? pkgs.rust-bin.stable.${rustVersion}.default.override {
        extensions = [
          "rust-src" # for rust-analyzer
          "rust-analyzer" # usable by IDEs like zed-editor
        ];
      },
    }:
    pkgs.mkShell {
      # ...
    }
  2. fetchTarball should be combined with a pinned version and hash to make the result reproducible, e.g.
    rust-overlay ? import (fetchTarball {
      url = "https://github.com/oxalica/rust-overlay/archive/23c4b3ba5f806fcf25d5a3b6b54fa0d07854c032.tar.gz";
      sha256 = "1iy52ms10dcp90r046ida0albxy0qkfk5yhc2ijp4r02hyd63rfr";
    }),
  3. You may want to consider using some kind of dependency management tool to pin nixpkgs to a specific commit and to make it easier to update rust-overlay without having to manually update the commit and hash. This can be achieved through npins or through the experimental flakes feature. For the beginning it's fine to skip this step though!

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.

3 participants