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 develop on nix-darwin #1292

Closed
2gn opened this issue Dec 8, 2022 · 8 comments
Closed

nix develop on nix-darwin #1292

2gn opened this issue Dec 8, 2022 · 8 comments

Comments

@2gn
Copy link

2gn commented Dec 8, 2022

To make nix develop work on nix-darwin, the following packages are required to be installed.

pkg-config
fontconfig
openssl
zlib
libiconv
darwin.apple_sdk.frameworks.CoreGraphics
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.Foundation

and, the following error will be returned if those packages (CoreServices in this case) are not included:

error: builder for '/nix/store/0j03wzzh3h5vgipcgklds0p8ddm0h2y4-rustlings.drv' failed with exit code 101;
       last 10 log lines:
       >    Compiling toml v0.5.9
       >    Compiling rustlings v5.2.1 (/private/tmp/nix-build-rustlings.drv-0/source)
       > error: linking with `/nix/store/a2wp9sqmh03zx7hkq7jvgvyi1vy7cicz-clang-wrapper-11.1.0/bin/cc` failed: exit status: 1
       >   |
       >   = note: "/nix/store/a2wp9sqmh03zx7hkq7jvgvyi1vy7cicz-clang-wrapper-11.1.0/bin/cc" "-m64" "-arch" "x86_64" "/private/tmp/nix-build-rustlings.drv-0/rustcc418vp/symbols.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.0.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.1.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.10.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.11.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.12.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.13.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.14.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.15.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.2.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.3.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.4.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.5.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.6.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.7.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.8.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.rustlings.35c6351d-cgu.9.rcgu.o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e.2e1cam21meweavtn.rcgu.o" "-L" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps" "-L" "/private/tmp/nix-build-rustlings.drv-0/source/target/release/deps" "-L" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libtoml-39ec19f4086a142c.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libserde_json-a2ecdcc9be6a6394.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libryu-85ac43b0ab2b576d.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libitoa-2e37a94619a2b395.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libindicatif-a48acd386f7c57ec.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/liblazy_static-3c2c2550ff9c159b.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libnumber_prefix-b8c75d434b4951fa.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libglob-08a825abb73f1113.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libserde-d346e66c3de445b3.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libnotify-cbac5193660978a9.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libwalkdir-386c9186068a6197.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libsame_file-7ad09e8704edeec6.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libfsevent-2dba45f30528fdff.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libfsevent_sys-3bb8faf99de427aa.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libfiletime-297cbb9882b59bba.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libcfg_if-a6b707aaece8e921.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libbitflags-8cfa2d7a88ebb79c.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libconsole-6d1a73d192b1ea08.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libterminal_size-3979235b15af44b0.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/liblibc-3782d5376e6d26fc.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libregex-0e107e121dee914e.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libaho_corasick-5b10bd1ac0bd7b2d.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libmemchr-f979f22461fb3745.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libregex_syntax-6960cf7d8afc8ed6.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libunicode_width-482b6aa755b937c6.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libonce_cell-301fd74db79bd54c.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libargh-f6b34f799fe51979.rlib" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/libargh_shared-fa3b0dc28151b948.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libstd-69395417f3e1755f.rlib""/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-4cfe30a82dc98045.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libobject-3c481bfd30a1d3fb.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-a4d2affc87bfb9bb.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-901f26d7e550b706.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libgimli-4d8793761d48a3f0.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-0992154178d1769d.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-87c8e39c3e7d5eb3.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-29dbb969809059bf.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-4a3798b64666fb63.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libadler-1f5152f067755e42.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-0d05e2eb698caa79.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libunwind-d026e58c5d4b1a5e.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-be61dc1e44679922.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/liblibc-1f5115519b1955cb.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/liballoc-df9c2c62a3eb3433.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-93b52ecae16c128a.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libcore-8edafb11271422bf.rlib" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-9442fbd2ac03574e.rlib" "-framework" "CoreServices" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/nix/store/kgmq8fxzxzhb72nlj3yz3i9rpnsllbhg-rustc-1.64.0/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/private/tmp/nix-build-rustlings.drv-0/source/target/x86_64-apple-darwin/release/deps/rustlings-a5c6b68c5700a59e" "-Wl,-dead_strip" "-nodefaultlibs"
       >   = note: ld: framework not found CoreServices
       >           clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
       >
       >
       > error: could not compile `rustlings` due to previous error
       For full logs, run 'nix log /nix/store/0j03wzzh3h5vgipcgklds0p8ddm0h2y4-rustlings.drv'.
error: 1 dependencies of derivation '/nix/store/61spam0k7b525a7ixdadsa7wcsh4aaxh-nix-shell-env.drv' failed to build

but I'm new to nix and I don't have any idea how I can let nix install these packages only on darwin. So, I'd like someone to hopefully implement this (for future nix-darwin users).

@2gn
Copy link
Author

2gn commented Dec 8, 2022

the error could not be fixed by adding the packages, maybe there are some *other problems.

@2gn 2gn closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2022
@luxus
Copy link

luxus commented Dec 9, 2022

did you got it working?

@2gn
Copy link
Author

2gn commented Dec 9, 2022

did you got it working?

No, not yet I’m afraid.

@luxus
Copy link

luxus commented Dec 9, 2022

its a general problem, if you found a solution, i would love to see a update here.

@dbarrosop
Copy link
Contributor

I opened a PR with a fix, if you could test it and comment on the PR I'd appreciate it (it worked on my machine™)

@2gn
Copy link
Author

2gn commented Dec 14, 2022

nix develop worked successfully thanks to #1294. but cargo run failed to run this time with similar errors. And I thought I could add CoreServices to buildInputs in devShell block as well to make it work, and it actually worked (although it may make flake.nix dirty ).

buildInputs = with pkgs; [
  cargo
  rustc
  rust-analyzer
  rustlings
] ++ lib.optionals stdenv.isDarwin [
  darwin.apple_sdk.frameworks.CoreServices
];

Do you think it's a good idea? or would there be a better workaround?

P.S. This wasn't necessary.

@dbarrosop
Copy link
Contributor

It depends, the "nix way" would be to add a package and app so you would be doing nix build and/or nix run instead but as this is a learning tool your proposal seems reasonable to me too. I am also unsure where the maintainers of rustlings stand with nix, I am quite new here myself.

Quick question though, do you need to run cargo run in this repo for any reason? I am only done through a few exercises and everything i needed so far was the command rustlings.

@2gn
Copy link
Author

2gn commented Dec 14, 2022

Sorry, I just realized I could run rustlings without running cargo run.

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