Skip to content

Commit

Permalink
nix: update, use fenix and split flake
Browse files Browse the repository at this point in the history
  • Loading branch information
ElysaSrc committed Jun 5, 2024
1 parent befc539 commit 31ea195
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 110 deletions.
82 changes: 33 additions & 49 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 16 additions & 61 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -18,7 +18,7 @@
outputs = {
self,
nixpkgs,
rust-overlay,
fenix,
flake-utils,
alejandra,
...
Expand All @@ -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
Expand All @@ -111,7 +67,7 @@
# API
(python311.withPackages pythonPackages)
ruff-lsp

# Core
gradle
jdk17
Expand All @@ -133,7 +89,6 @@
SystemConfiguration
]);

RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
};
}
Expand Down
35 changes: 35 additions & 0 deletions nix/python_env.nix
Original file line number Diff line number Diff line change
@@ -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
]
14 changes: 14 additions & 0 deletions nix/scripts.nix
Original file line number Diff line number Diff line change
@@ -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/*
'';
}

0 comments on commit 31ea195

Please sign in to comment.