-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: implement nix flakes for developers
- Implement flakes with development dependencies - Add a `shell.nix` that leverages edolstra/flake-compat
- Loading branch information
Showing
6 changed files
with
388 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.DS_Store | ||
*.nix | ||
*.backup | ||
__pycache__ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
{ | ||
description = "A Nix flake for OSRD dev shell"; | ||
|
||
inputs = { | ||
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"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
alejandra = { | ||
url = "github:kamadorueda/alejandra/3.0.0"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
rust-overlay, | ||
flake-utils, | ||
alejandra, | ||
... | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [rust-overlay.overlays.default]; | ||
}; | ||
pythonPackages = ps: [ | ||
ps.black | ||
ps.isort | ||
ps.flake8 | ||
ps.intervaltree | ||
ps.numpy | ||
ps.mock | ||
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.pyosmium | ||
|
||
ps.progress | ||
ps.tqdm | ||
ps.ipywidgets | ||
]; | ||
|
||
fixedNode = pkgs.nodejs-18_x; | ||
fixedNodePackages = pkgs.nodePackages.override { | ||
nodejs = fixedNode; | ||
}; | ||
|
||
scriptFiles = builtins.attrNames (builtins.readDir ./scripts); | ||
scriptBins = | ||
map ( | ||
scriptFile: | ||
pkgs.writeShellScriptBin | ||
(pkgs.lib.strings.removeSuffix ".sh" scriptFile) | ||
(pkgs.lib.strings.replaceStrings | ||
["#!/bin/sh"] [""] | ||
(builtins.readFile ./scripts/${scriptFile})) | ||
) | ||
scriptFiles; | ||
in | ||
with pkgs; { | ||
devShells.default = mkShell { | ||
buildInputs = | ||
[ | ||
# API | ||
(python310.withPackages pythonPackages) | ||
poetry | ||
|
||
# EDITOAST | ||
osmium-tool | ||
geos | ||
postgresql | ||
openssl | ||
pkg-config | ||
rustPackages.clippy | ||
cargo-watch | ||
cargo-tarpaulin | ||
rust-analyzer | ||
rust-bin.stable.latest.default | ||
|
||
# CORE | ||
jdk17 | ||
|
||
# FRONT | ||
fixedNodePackages.create-react-app | ||
fixedNodePackages.eslint | ||
fixedNodePackages.yarn | ||
fixedNode | ||
|
||
# Nix formatter | ||
alejandra.defaultPackage.${system} | ||
] | ||
++ scriptBins; | ||
|
||
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}"; | ||
OSRD_DEV = "True"; | ||
OSRD_BACKEND_URL = "http://localhost:8080"; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
lib, | ||
buildPythonPackage, | ||
fetchPypi, | ||
pydantic, | ||
}: | ||
buildPythonPackage rec { | ||
pname = "geojson-pydantic"; | ||
version = "0.3.1"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "1clj89s39qyc510sylyx5fcfx9lpk7g8mi64rbzw067hcd5n2hk5"; | ||
}; | ||
|
||
doCheck = false; | ||
|
||
propagatedBuildInputs = [pydantic]; | ||
|
||
meta = with lib; { | ||
maintainers = with maintainers; [flomonster]; | ||
description = "GeoJson support for pydantic"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
lib, | ||
buildPythonPackage, | ||
fetchPypi, | ||
}: | ||
buildPythonPackage rec { | ||
pname = "kdtree"; | ||
version = "0.16"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "0d3m7pir24vp2sjg85anigv9xya4z5fh7qvlp7xf01bah73zcv9q"; | ||
}; | ||
|
||
doCheck = false; | ||
|
||
meta = with lib; { | ||
maintainers = with maintainers; [flomonster]; | ||
description = "Kdtree"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
( | ||
import | ||
( | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{src = ./.;} | ||
) | ||
.shellNix |