Skip to content

Commit

Permalink
Update doc/flake.nix (#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski committed May 15, 2024
1 parent 07d6133 commit 0ab983a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.cache
.history
.env/
.lib/
/cdk
/aws-cdk-tests
Expand Down
81 changes: 7 additions & 74 deletions doc/flake.lock

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

42 changes: 19 additions & 23 deletions doc/flake.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
{
description = "Python shell flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

mach-nix.url = "github:davhau/mach-nix";
};

outputs = { self, nixpkgs, mach-nix, flake-utils, ... }:
let
pythonVersion = "python37";
in
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
mach = mach-nix.lib.${system};

pythonEnv = mach.mkPython {
python = pythonVersion;
requirements = builtins.readFile ./requirements.txt;
};
in
python = pkgs.python3.withPackages (ps: with ps; [
pip
]);
in
{
devShells.default = pkgs.mkShellNoCC {
packages = [ pythonEnv ];

shellHook = ''
export PYTHONPATH="${pythonEnv}/bin/python"
devShell = pkgs.mkShell {
buildInputs = [ python ];

shellHook = ''
# Create a Python virtual environment and activate it
python -m venv .env
source .env/bin/activate
# Install the Python dependencies from requirements.txt
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
'';
};
}
);
}
}

0 comments on commit 0ab983a

Please sign in to comment.