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 anyone? Might make the compiler easier to build/work on #60490

Open
wtholliday opened this issue Aug 10, 2022 · 4 comments
Open

Nix anyone? Might make the compiler easier to build/work on #60490

wtholliday opened this issue Aug 10, 2022 · 4 comments
Labels
feature A feature request or implementation

Comments

@wtholliday
Copy link

wtholliday commented Aug 10, 2022

Is your feature request related to a problem? Please describe.

I'm just having trouble building the compiler and setting up a dev environment. I think nix may be able to help make this process easier :)

Building with ./swift/utils/build-toolchain com.whatever

Describe the solution you'd like

I'm playing around with this shell.nix file on ubuntu:

{
    pkgs ? import <nixpkgs> {}
}:
pkgs.mkShell {
    name="dev";
    buildInputs = [
       pkgs.clang
       pkgs.cmake
       pkgs.ninja
    ];
    shellHook = ''
        echo "Go!"
    '';
}

Immediately run into Swift expecting there to be a source directory for ninja. Why not use the ninja that's installed on the system?

[./utils/build-script] ERROR: can't find source directory for ninja (tried /home/parallels/ninja)

Describe alternatives you've considered

Well, I can probably get it to build (and I have before), but the build seems rather brittle and gets confused by other things I happen to have installed (such as another version of llvm). I didn't want to mess up things on my mac just to get swift building, so I switched to an ubuntu vm. Also tried a second mac but that was running a beta OS and I quickly hit issues there. Having an easily reproducible build would be nice :)

Additional Context

There is a (broken) nix package for Swift here: https://github.com/NixOS/nixpkgs/blob/nixos-22.05/pkgs/development/compilers/swift/default.nix#L396. It applies various patches to make things work. It's not really suitable for creating a development environment to work on the compiler, AFAICT, but it may offer some insight into how to make things easier.

@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation and removed new feature labels Apr 19, 2023
@expelledboy
Copy link

FYI there have been some contributions since this was opened: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/swift/default.nix

@Sammcb
Copy link

Sammcb commented Apr 28, 2024

A flake would also be something I would love to see. Currently, the nixpkgs Swift version is lagging behind (5.8 instead of 5.10). Seeing more first class support for Nix would wonderful so we can use Nix to reliably build current-version Swift projects!

@softinio
Copy link

A flake would also be something I would love to see. Currently, the nixpkgs Swift version is lagging behind (5.8 instead of 5.10). Seeing more first class support for Nix would wonderful so we can use Nix to reliably build current-version Swift projects!

FYI:

https://flakehub.com/flake/DeterminateSystems/apple-sdks.nix

@Sammcb
Copy link

Sammcb commented Apr 30, 2024

@softinio thanks for sharing this option! A flake specifically for Swift for use across macOS and Linux would be something I personally would love to see 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation
Projects
None yet
Development

No branches or pull requests

5 participants