diff --git a/flake.nix b/flake.nix index b2e3e52..a79e29b 100644 --- a/flake.nix +++ b/flake.nix @@ -4,16 +4,26 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, rust-overlay }: let supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; in flake-utils.lib.eachSystem supportedSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; - weftPkgs = pkgs.callPackage ./infra/nixos/weft-packages.nix { }; + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + rust193 = pkgs.rust-bin.stable."1.93.0".default; + weftPkgs = pkgs.callPackage ./infra/nixos/weft-packages.nix { + inherit rust193; + }; in { packages = weftPkgs // { @@ -23,7 +33,7 @@ devShells.default = pkgs.mkShell { name = "weft-dev"; nativeBuildInputs = with pkgs; [ - rustup + rust193 pkg-config cmake clang @@ -52,7 +62,10 @@ ) // { nixosConfigurations.weft-vm = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - specialArgs = { inherit self; }; + specialArgs = { + inherit self; + rustOverlay = rust-overlay.overlays.default; + }; modules = [ ./infra/nixos/configuration.nix ]; diff --git a/infra/nixos/configuration.nix b/infra/nixos/configuration.nix index f53c2b5..7b68ddb 100644 --- a/infra/nixos/configuration.nix +++ b/infra/nixos/configuration.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, self, modulesPath, ... }: +{ pkgs, lib, self, modulesPath, rustOverlay, ... }: { imports = [ @@ -66,8 +66,12 @@ ]; nixpkgs.overlays = [ + rustOverlay (final: prev: { - weft = final.callPackage ./weft-packages.nix { }; + rust193 = final.rust-bin.stable."1.93.0".default; + weft = final.callPackage ./weft-packages.nix { + rust193 = final.rust193; + }; }) ]; diff --git a/infra/nixos/weft-packages.nix b/infra/nixos/weft-packages.nix index bb59405..e4cccac 100644 --- a/infra/nixos/weft-packages.nix +++ b/infra/nixos/weft-packages.nix @@ -1,6 +1,11 @@ -{ pkgs, ... }: +{ pkgs, rust193, ... }: let + rustPlatform = pkgs.makeRustPlatform { + cargo = rust193; + rustc = rust193; + }; + src = ../..; cargoLock = { @@ -17,7 +22,7 @@ let nativeBuildInputs = with pkgs; [ pkg-config ]; }; - mkWeftPkg = { pname, extraBuildInputs ? [], extraNativeBuildInputs ? [], cargoFlags ? [], extraEnv ? {} }: pkgs.rustPlatform.buildRustPackage (commonArgs // { + mkWeftPkg = { pname, extraBuildInputs ? [], extraNativeBuildInputs ? [], cargoFlags ? [], extraEnv ? {} }: rustPlatform.buildRustPackage (commonArgs // { inherit pname; cargoBuildFlags = [ "--package" pname ] ++ cargoFlags; cargoTestFlags = [ "--package" pname ];