diff --git a/examples/rust-complex/flake.nix b/examples/rust-complex/flake.nix index c94f96d6..fec10a77 100644 --- a/examples/rust-complex/flake.nix +++ b/examples/rust-complex/flake.nix @@ -1,6 +1,5 @@ { - inputs.nixify.inputs.nixpkgs-darwin.follows = "nixpkgs"; - inputs.nixify.inputs.nixpkgs-nixos.follows = "nixpkgs"; + inputs.nixify.inputs.nixpkgs.follows = "nixpkgs"; inputs.nixify.url = "github:rvolosatovs/nixify"; inputs.nixpkgs.url = "github:NixOS/nixpkgs"; diff --git a/flake.lock b/flake.lock index ef7cc6d2..afb617f0 100644 --- a/flake.lock +++ b/flake.lock @@ -68,16 +68,16 @@ "fenix": { "inputs": { "nixpkgs": [ - "nixpkgs-nixos" + "nixpkgs" ], "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1729375822, - "narHash": "sha256-bRo4xVwUhvJ4Gz+OhWMREFMdBOYSw4Yi1Apj01ebbug=", + "lastModified": 1729492502, + "narHash": "sha256-d6L4bBlUWr4sHC+eRXo+4acFPEFXKmqHpM/BfQ5gQQw=", "owner": "nix-community", "repo": "fenix", - "rev": "2853e7d9b5c52a148a9fb824bfe4f9f433f557ab", + "rev": "4002a1ec3486b855f341d2b864ba06b61e73af28", "type": "github" }, "original": { @@ -161,7 +161,7 @@ "macos-sdk": { "flake": false, "locked": { - "lastModified": 1694769349, + "lastModified": 1693509154, "narHash": "sha256-TEvVJy+NMPyzgWSk/6S29ZMQR+ICFxSdS3tw247uhFc=", "type": "tarball", "url": "https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz" @@ -321,34 +321,18 @@ "type": "github" } }, - "nixpkgs-darwin": { + "nixpkgs_2": { "locked": { - "lastModified": 1729242558, - "narHash": "sha256-VgcLDu4igNT0eYua6OAl9pWCI0cYXhDbR+pWP44tte0=", + "lastModified": 1729519136, + "narHash": "sha256-6/hRRcendHWPsRHwrQD692XIJX/qKE+RQtUlk+7kbbE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4a3f2d3195b60d07530574988df92e049372c10e", + "rev": "3576b958e4397bcfbf8d664286fca8f418c906be", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-24.05-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-nixos": { - "locked": { - "lastModified": 1729181673, - "narHash": "sha256-LDiPhQ3l+fBjRATNtnuDZsBS7hqoBtPkKBkhpoBHv3I=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-24.05", + "ref": "staging", "repo": "nixpkgs", "type": "github" } @@ -363,19 +347,18 @@ "nix-filter": "nix-filter", "nix-log": "nix-log", "nixlib": "nixlib_3", - "nixpkgs-darwin": "nixpkgs-darwin", - "nixpkgs-nixos": "nixpkgs-nixos", + "nixpkgs": "nixpkgs_2", "rust-overlay": "rust-overlay_2" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1729255720, - "narHash": "sha256-yODOuZxBkS0UfqMa6nmbqNbVfIbsu0tYLbV5vZzmsqI=", + "lastModified": 1729454508, + "narHash": "sha256-1W5B/CnLgdC03iIFG0wtawO1+dGDWDpc84PeOHo2ecU=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "72b214fbfbe6f7b95a7877b962783bd42062cc0a", + "rev": "9323b5385863739d1c113f02e4cf3f2777c09977", "type": "github" }, "original": { @@ -432,15 +415,15 @@ "rust-overlay_2": { "inputs": { "nixpkgs": [ - "nixpkgs-nixos" + "nixpkgs" ] }, "locked": { - "lastModified": 1729391507, - "narHash": "sha256-as0I9xieJUHf7kiK2a9znDsVZQTFWhM1pLivII43Gi0=", + "lastModified": 1729477859, + "narHash": "sha256-r0VyeJxy4O4CgTB/PNtfQft9fPfN1VuGvnZiCxDArvg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "784981a9feeba406de38c1c9a3decf966d853cca", + "rev": "ada8266712449c4c0e6ee6fcbc442b3c217c79e1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 43f65402..85b10e8b 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ inputs.advisory-db.flake = false; inputs.advisory-db.url = "github:rustsec/advisory-db"; inputs.crane.url = "github:ipetkov/crane"; - inputs.fenix.inputs.nixpkgs.follows = "nixpkgs-nixos"; + inputs.fenix.inputs.nixpkgs.follows = "nixpkgs"; inputs.fenix.url = "github:nix-community/fenix"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.macos-sdk.url = "https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz"; @@ -27,9 +27,8 @@ inputs.nix-filter.url = "github:numtide/nix-filter"; inputs.nix-log.url = "github:rvolosatovs/nix-log"; inputs.nixlib.url = "github:nix-community/nixpkgs.lib"; - inputs.nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.05-darwin"; - inputs.nixpkgs-nixos.url = "github:nixos/nixpkgs/nixos-24.05"; - inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs-nixos"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/staging"; + inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; inputs.rust-overlay.url = "github:oxalica/rust-overlay"; outputs = inputs: let diff --git a/lib/mkFlake.nix b/lib/mkFlake.nix index 5db22a0a..43a6b500 100644 --- a/lib/mkFlake.nix +++ b/lib/mkFlake.nix @@ -2,8 +2,7 @@ self, flake-utils, nixlib, - nixpkgs-darwin, - nixpkgs-nixos, + nixpkgs, ... }: { defaultExcludePaths, @@ -61,11 +60,7 @@ with self.lib; ( system: let pkgs = - import ( - if system == aarch64-darwin || system == x86_64-darwin - then nixpkgs-darwin - else nixpkgs-nixos - ) { + import nixpkgs { inherit overlays system diff --git a/lib/rust/defaultPkgsFor.nix b/lib/rust/defaultPkgsFor.nix index 9a363a45..1caf0f48 100644 --- a/lib/rust/defaultPkgsFor.nix +++ b/lib/rust/defaultPkgsFor.nix @@ -2,8 +2,7 @@ { self, flake-utils, - nixpkgs-darwin, - nixpkgs-nixos, + nixpkgs, ... }: with flake-utils.lib.system; @@ -88,11 +87,7 @@ with self.lib.rust.targets; else if target == wasm32-unknown-unknown || target == wasm32-wasip1 then pkgs.pkgsCross.wasi32 else - import ( - if pkgs.stdenv.buildPlatform.isDarwin - then nixpkgs-darwin - else nixpkgs-nixos - ) { + import nixpkgs { crossSystem.config = if target == riscv64gc-unknown-linux-musl then "riscv64-unknown-linux-musl" diff --git a/lib/rust/mkAttrs.nix b/lib/rust/mkAttrs.nix index 507078dd..1e375a05 100644 --- a/lib/rust/mkAttrs.nix +++ b/lib/rust/mkAttrs.nix @@ -334,9 +334,9 @@ with self.lib.rust.targets; # Removing vendor references here invalidates the signature, which is required on aarch64-darwin doNotRemoveReferencesToVendorDir = true; } - # Use `rust-lld` linker and Zig C compiler for Darwin targets // ( - if pkgsCross.stdenv.hostPlatform.isDarwin + # Use Zig C compiler and `rust-lld` linker for Darwin targets on non-Darwin platforms + if !final.stdenv.buildPlatform.isDarwin && pkgsCross.stdenv.hostPlatform.isDarwin then { depsBuildBuild = [ crossZigCC @@ -346,51 +346,49 @@ with self.lib.rust.targets; crossZigCC ]; - preBuild = - '' - export HOME=$(mktemp -d) - '' - + optionalString pkgsCross.stdenv.hostPlatform.isDarwin '' - export SDKROOT="${macos-sdk}" - ''; + preBuild = '' + export HOME=$(mktemp -d) + export SDKROOT="${macos-sdk}" + ''; "CC_${target}" = "${target}-zigcc"; "CARGO_TARGET_${toUpper (kebab2snake target)}_LINKER" = "rust-lld"; } else - ( - { - depsBuildBuild = - [ - pkgsCross.stdenv.cc - ] - ++ optional pkgsCross.stdenv.hostPlatform.isWindows pkgsCross.windows.pthreads; - - disallowedReferences = [ + { + depsBuildBuild = + [ pkgsCross.stdenv.cc - ]; + ] + ++ optional pkgsCross.stdenv.hostPlatform.isWindows pkgsCross.windows.pthreads; - "AR_${target}" = "${pkgsCross.stdenv.cc.targetPrefix}ar"; - "CC_${target}" = "${pkgsCross.stdenv.cc.targetPrefix}cc"; - } - # Use `mold` linker for Linux targets - // optionalAttrs pkgsCross.stdenv.hostPlatform.isLinux { - nativeBuildInputs = [ - final.mold - ]; + disallowedReferences = [ + pkgsCross.stdenv.cc + ]; - "CARGO_TARGET_${toUpper (kebab2snake target)}_RUSTFLAGS" = "-Clink-arg=-fuse-ld=mold"; - } - # Always build static binaries for Windows targets - // optionalAttrs pkgsCross.stdenv.hostPlatform.isWindows { - "CARGO_TARGET_${toUpper (kebab2snake target)}_RUSTFLAGS" = "-Ctarget-feature=+crt-static"; - } - # Use default linker for Wasm targets - // optionalAttrs (!pkgsCross.stdenv.hostPlatform.isWasm) { - "CARGO_TARGET_${toUpper (kebab2snake target)}_LINKER" = "${pkgsCross.stdenv.cc.targetPrefix}cc"; - } - ) + "AR_${target}" = "${pkgsCross.stdenv.cc.targetPrefix}ar"; + "CC_${target}" = "${pkgsCross.stdenv.cc.targetPrefix}cc"; + } + # Use `mold` linker for Linux targets + // optionalAttrs pkgsCross.stdenv.hostPlatform.isLinux { + nativeBuildInputs = [ + final.mold + ]; + + "CARGO_TARGET_${toUpper (kebab2snake target)}_RUSTFLAGS" = "-Clink-arg=-fuse-ld=mold"; + } + # Always build static binaries for Windows targets + // optionalAttrs pkgsCross.stdenv.hostPlatform.isWindows { + "CARGO_TARGET_${toUpper (kebab2snake target)}_RUSTFLAGS" = "-Ctarget-feature=+crt-static"; + } + // optionalAttrs pkgsCross.stdenv.hostPlatform.isDarwin { + "CARGO_TARGET_${toUpper (kebab2snake target)}_LINKER" = "rust-lld"; + } + # Use default linker for Wasm targets + // optionalAttrs (!pkgsCross.stdenv.hostPlatform.isWasm) { + "CARGO_TARGET_${toUpper (kebab2snake target)}_LINKER" = "${pkgsCross.stdenv.cc.targetPrefix}cc"; + } ) // optionalAttrs (final.stdenv.buildPlatform.config != pkgsCross.stdenv.hostPlatform.config) ( {