diff --git a/flake.lock b/flake.lock index e981171aca4..cd375307875 100644 --- a/flake.lock +++ b/flake.lock @@ -45,6 +45,27 @@ "type": "github" } }, + "fenix_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src_2" + }, + "locked": { + "lastModified": 1717568841, + "narHash": "sha256-uF0TjD2fu8uShcCubVoKA9CQaAjJpDVCnzrK0uSMU1g=", + "owner": "nix-community", + "repo": "fenix", + "rev": "1df7cd8d759674ac69bdb67e0d55446c2394da68", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "locked": { "lastModified": 1696426674, @@ -77,24 +98,6 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "flakeCompat": { "flake": false, "locked": { @@ -130,10 +133,10 @@ "root": { "inputs": { "alejandra": "alejandra", + "fenix": "fenix_2", "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs" } }, "rust-analyzer-src": { @@ -153,24 +156,20 @@ "type": "github" } }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "nixpkgs" - ] - }, + "rust-analyzer-src_2": { + "flake": false, "locked": { - "lastModified": 1717121863, - "narHash": "sha256-/3sxIe7MZqF/jw1RTQCSmgTjwVod43mmrk84m50MJQ4=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "2a7b53172ed08f856b8382d7dcfd36a4e0cbd866", + "lastModified": 1717511332, + "narHash": "sha256-50VrD5Wl2BVJZkSRj/stvEvHvbrJcIOPTtQbI6Zvqfw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "29e5cdfb054635364b6d8290a096e64d258ce78b", "type": "github" }, "original": { - "owner": "oxalica", - "repo": "rust-overlay", + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", "type": "github" } }, @@ -188,21 +187,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8dbc246a16d..c49b7c7a402 100644 --- a/flake.nix +++ b/flake.nix @@ -5,8 +5,8 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; + fenix = { + url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; alejandra = { @@ -18,7 +18,7 @@ outputs = { self, nixpkgs, - rust-overlay, + fenix, flake-utils, alejandra, ... @@ -27,76 +27,32 @@ system: let pkgs = import nixpkgs { inherit system; - overlays = [rust-overlay.overlays.default]; }; - pythonPackages = ps: [ - ps.black - ps.flake8 - ps.intervaltree - ps.isort - ps.mock - ps.numpy - ps.pillow - ps.psycopg - ps.psycopg2 - ps.pyyaml - ps.requests - ps.websockets - (ps.callPackage (import ./nix/kdtree.nix) {}) - (ps.callPackage (import ./nix/geojson-pydantic.nix) {inherit (ps) pydantic;}) - # DATA SCIENCE - ps.ipykernel - ps.jupyterlab - ps.shapely - ps.pyproj - ps.ipympl - ps.matplotlib - ps.networkx - - ps.progress - ps.tqdm - ps.ipywidgets - - # TOOLS - ps.python-lsp-server - ]; + pythonPackages = ps: (import ./nix/python_env.nix {inherit ps;}); fixedNode = pkgs.nodejs-18_x; fixedNodePackages = pkgs.nodePackages.override { nodejs = fixedNode; }; - rustChan = pkgs.rust-bin.stable."1.78.0".default.override { - targets = []; - extensions = [ - "clippy" - "rust-src" - "rustc-dev" - "rustfmt" - "rust-analyzer" - ]; - }; + rustVer = fenix.packages.${system}.stable; + rustChan = rustVer.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]; - osrd-dev-scripts = pkgs.stdenv.mkDerivation { - name = "osrd-dev-scripts"; - src = ./scripts; - installPhase = '' - mkdir -p $out/bin - cp -rv * $out/bin - # Create symlinks for scripts without the extension (.py, .sh, etc...) for ease of use - for script in $out/bin/*; do - ln -s $script $out/bin/$(basename $script | cut -d. -f1) - done - chmod +x $out/bin/* - ''; - }; + osrd-dev-scripts = pkgs.callPackage ./nix/scripts.nix {}; in with pkgs; { devShells.default = mkShell { - nativeBuildInputs = [rustChan]; buildInputs = [ + # Rust + rustChan # Tools & Libs diesel-cli cargo-watch @@ -111,7 +67,7 @@ # API (python311.withPackages pythonPackages) ruff-lsp - + # Core gradle jdk17 @@ -133,7 +89,6 @@ SystemConfiguration ]); - RUST_SRC_PATH = "${rustPlatform.rustLibSrc}"; RUSTFLAGS = "-C link-arg=-fuse-ld=mold"; }; } diff --git a/nix/python_env.nix b/nix/python_env.nix new file mode 100644 index 00000000000..70f935b0896 --- /dev/null +++ b/nix/python_env.nix @@ -0,0 +1,35 @@ +{ps}: let + kdTree = ./kdtree.nix; + geojsonPydantic = ./geojson-pydantic.nix; +in [ + ps.black + ps.flake8 + ps.intervaltree + ps.isort + ps.mock + ps.numpy + ps.pillow + ps.psycopg + ps.psycopg2 + ps.pyyaml + ps.requests + ps.websockets + (ps.callPackage (import kdTree) {}) + (ps.callPackage (import geojsonPydantic) {inherit (ps) pydantic;}) + + # DATA SCIENCE + ps.ipykernel + ps.jupyterlab + ps.shapely + ps.pyproj + ps.ipympl + ps.matplotlib + ps.networkx + + ps.progress + ps.tqdm + ps.ipywidgets + + # TOOLS + ps.python-lsp-server +] diff --git a/nix/scripts.nix b/nix/scripts.nix new file mode 100644 index 00000000000..6e2262a6734 --- /dev/null +++ b/nix/scripts.nix @@ -0,0 +1,14 @@ +{stdenv}: +stdenv.mkDerivation { + name = "osrd-dev-scripts"; + src = ../scripts; + installPhase = '' + mkdir -p $out/bin + cp -rv * $out/bin + # Create symlinks for scripts without the extension (.py, .sh, etc...) for ease of use + for script in $out/bin/*; do + ln -s $script $out/bin/$(basename $script | cut -d. -f1) + done + chmod +x $out/bin/* + ''; +}