From a792bffae708bcd68a70aa2dc301fe024f3a5b9c Mon Sep 17 00:00:00 2001 From: jvytee Date: Fri, 10 Oct 2025 00:15:07 +0200 Subject: [PATCH 1/4] Use rust toolchain from nixpkgs --- flake.lock | 45 ++---------------- flake.nix | 135 +++++++++++++++++++++-------------------------------- 2 files changed, 57 insertions(+), 123 deletions(-) diff --git a/flake.lock b/flake.lock index b2bc0dc..fbc89a9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,33 +1,12 @@ { "nodes": { - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1751352216, - "narHash": "sha256-dJj8TUoZGj55Ttro37vvFGF2L+xlYNfspQ9u4BfqTFw=", - "owner": "nix-community", - "repo": "fenix", - "rev": "61b4f1e21bd631da91981f1ed74c959d6993f554", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1751271578, - "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=", + "lastModified": 1759831965, + "narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df", + "rev": "c9b6fb798541223bbb396d287d16f43520250518", "type": "github" }, "original": { @@ -39,26 +18,8 @@ }, "root": { "inputs": { - "fenix": "fenix", "nixpkgs": "nixpkgs" } - }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1751296293, - "narHash": "sha256-oaGMVdCcI32y6jQ7RE0+CqshZngfI19XnY31eYjdinI=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "eaf37e2c98b66ff7f7a0ac04e4cada39e51fde4b", - "type": "github" - }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index bbec243..f4651c8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,109 +1,82 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; - outputs = { self, nixpkgs, fenix }: + outputs = { self, nixpkgs }: let eachSystem = nixpkgs.lib.genAttrs systems; systems = [ "x86_64-linux" "aarch64-linux" ]; - crossTargets = [ - "aarch64-unknown-linux-musl" - "x86_64-unknown-linux-musl" - ]; in { devShells = - let - extraRustStds = system: targets: map (target: fenix.packages.${system}.targets.${target}.stable.rust-std) targets; - toolchain = system: targets: - with fenix.packages.${system}; combine ([ - stable.toolchain - ] ++ (extraRustStds system targets)); - in - eachSystem (system: - { - default = - with import nixpkgs { inherit system; }; - mkShell { - nativeBuildInputs = [ - (toolchain system crossTargets) - yaml-language-server - pkgsCross.aarch64-multiplatform-musl.pkgsStatic.stdenv.cc - pkgsStatic.stdenv.cc - gh - ]; - - CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = - let cc = pkgsStatic.stdenv.cc; - in "${cc}/bin/${cc.targetPrefix}cc"; - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER = - let cc = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.stdenv.cc; - in "${cc}/bin/${cc.targetPrefix}cc"; - # CARGO_BUILD_RUSTFLAGS = [ "-C" "target-feature=+crt-static" ]; - # TARGET_CC = "${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER}"; - }; + eachSystem (system: + { + default = + with import nixpkgs { inherit system; }; + mkShell { + nativeBuildInputs = [ + cargo + gh + yaml-language-server + ]; - test = - with import nixpkgs { inherit system; }; - mkShell { - nativeBuildInputs = [ fenix.packages.${system}.stable.minimalToolchain ]; - }; - } - ); + CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = + let cc = pkgsStatic.stdenv.cc; + in "${cc}/bin/${cc.targetPrefix}cc"; + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER = + let cc = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.stdenv.cc; + in "${cc}/bin/${cc.targetPrefix}cc"; + # CARGO_BUILD_RUSTFLAGS = [ "-C" "target-feature=+crt-static" ]; + # TARGET_CC = "${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER}"; + }; + } + ); packages = eachSystem (system: { default = with import nixpkgs { inherit system; }; - let - toolchain = - with fenix.packages.${system}; - combine [ stable.cargo stable.rustc ]; - rustPlatform = makeRustPlatform { cargo = toolchain; rustc = toolchain; }; - in - rustPlatform.buildRustPackage { - pname = "ipupdate"; - version = "0.3.0"; - src = self; - cargoLock.lockFile = ./Cargo.lock; - }; + rustPlatform.buildRustPackage { + pname = "ipupdate"; + version = "0.3.0"; + src = self; + cargoLock.lockFile = ./Cargo.lock; + }; ipupdate-x86_64 = - with import nixpkgs { localSystem = system; crossSystem = { system = "x86_64-unknown-linux-musl"; isStatic = true; }; }; - let - toolchain = - with fenix.packages.${system}; - combine [ stable.cargo stable.rustc targets.x86_64-unknown-linux-musl.stable.rust-std ]; - rustPlatform = makeRustPlatform { cargo = toolchain; rustc = toolchain; }; - in - rustPlatform.buildRustPackage { - pname = "ipupdate"; - version = "0.3.0"; - src = self; - cargoLock.lockFile = ./Cargo.lock; + with import nixpkgs { + localSystem = system; + crossSystem = { + system = "x86_64-unknown-linux-musl"; + isStatic = true; + rustc.rustcTarget = "x86_64-unknown-linux-musl"; }; + }; + rustPlatform.buildRustPackage { + pname = "ipupdate"; + version = "0.3.0"; + src = self; + cargoLock.lockFile = ./Cargo.lock; + }; ipupdate-aarch64 = - with import nixpkgs { localSystem = system; crossSystem = { system = "aarch64-unknown-linux-musl"; isStatic = true; }; }; - let - toolchain = - with fenix.packages.${system}; - combine [ stable.cargo stable.rustc targets.aarch64-unknown-linux-musl.stable.rust-std ]; - rustPlatform = makeRustPlatform { cargo = toolchain; rustc = toolchain; }; - in - rustPlatform.buildRustPackage { - pname = "ipupdate"; - version = "0.3.0"; - src = self; - cargoLock.lockFile = ./Cargo.lock; + with import nixpkgs { + localSystem = system; + crossSystem = { + system = "aarch64-unknown-linux-musl"; + isStatic = true; + rustc.rustcTarget = "aarch64-unknown-linux-musl"; }; + }; + rustPlatform.buildRustPackage { + pname = "ipupdate"; + version = "0.3.0"; + src = self; + cargoLock.lockFile = ./Cargo.lock; + }; } ); }; From f79e0fb8047883fab2e115f711b4c8a943046535 Mon Sep 17 00:00:00 2001 From: jvytee Date: Sat, 11 Oct 2025 21:24:19 +0200 Subject: [PATCH 2/4] Add rust-analyzer --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index f4651c8..d45edd3 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,7 @@ nativeBuildInputs = [ cargo gh + rust-analyzer yaml-language-server ]; From df29f728738bb75a9c7a46d4726d16aaab217153 Mon Sep 17 00:00:00 2001 From: jvytee Date: Sun, 12 Oct 2025 00:32:23 +0200 Subject: [PATCH 3/4] Add more development tools --- flake.lock | 6 +++--- flake.nix | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index fbc89a9..4cbc85b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1759831965, - "narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=", + "lastModified": 1760038930, + "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c9b6fb798541223bbb396d287d16f43520250518", + "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d45edd3..63dd715 100644 --- a/flake.nix +++ b/flake.nix @@ -19,8 +19,12 @@ mkShell { nativeBuildInputs = [ cargo + clippy + gdb gh rust-analyzer + rustc + rustfmt yaml-language-server ]; From 64a5f099030e5db09b37ecf6d3b5ea87965dbcb7 Mon Sep 17 00:00:00 2001 From: jvytee Date: Fri, 24 Oct 2025 18:23:15 +0200 Subject: [PATCH 4/4] Add back test dev-shell --- flake.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flake.nix b/flake.nix index 63dd715..105c672 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,8 @@ clippy gdb gh + openssl + pkg-config rust-analyzer rustc rustfmt @@ -37,6 +39,17 @@ # CARGO_BUILD_RUSTFLAGS = [ "-C" "target-feature=+crt-static" ]; # TARGET_CC = "${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER}"; }; + + test = + with import nixpkgs { inherit system; }; + mkShell { + nativeBuildInputs = [ + cargo + openssl + pkg-config + rustc + ]; + }; } );