Skip to content

Commit a4de285

Browse files
flake.nix setup for dev shell
Signed-off-by: Ethan Carter Edwards <[email protected]>
1 parent 4d9daaa commit a4de285

File tree

3 files changed

+40
-150
lines changed

3 files changed

+40
-150
lines changed

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
layout_uv
2+
use flake
23
export $(< CONSTANTS )
4+
export DEV=true

flake.lock

Lines changed: 7 additions & 93 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,39 @@
11
{
2-
description = "API for Ethan";
2+
description = "Ethan's Api Dev Flake";
33

4-
inputs.nixpkgs.url = "github:nixos/nixpkgs/master";
5-
inputs.nur.url = "github:nix-community/nur";
6-
inputs.nur.inputs.nixpkgs.follows = "nixpkgs";
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
};
77

8-
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
9-
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
10-
11-
outputs =
12-
{ nixpkgs, pyproject-nix, ... }:
13-
let
14-
# Loads pyproject.toml into a high-level project representation
15-
# Do you notice how this is not tied to any `system` attribute or package sets?
16-
# That is because `project` refers to a pure data representation.
17-
project = pyproject-nix.lib.project.loadPyproject {
18-
# Read & unmarshal pyproject.toml relative to this project root.
19-
# projectRoot is also used to set `src` for renderers such as buildPythonPackage.
20-
projectRoot = ./.;
21-
};
22-
23-
# This example is only using aarch64-darwin
24-
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
25-
26-
# We are using the default nixpkgs Python3 interpreter & package set.
27-
#
28-
# This means that you are purposefully ignoring:
29-
# - Version bounds
30-
# - Dependency sources (meaning local path dependencies won't resolve to the local path)
31-
#
32-
# To use packages from local sources see "Overriding Python packages" in the nixpkgs manual:
33-
# https://nixos.org/manual/nixpkgs/stable/#reference
34-
#
35-
# Or use an overlay generator such as uv2nix:
36-
# https://github.com/pyproject-nix/uv2nix
37-
python = pkgs.python3;
38-
39-
in
8+
outputs = inputs@{ self, nixpkgs, ... }:
9+
let
10+
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
11+
in
4012
{
41-
# Create a development shell containing dependencies from `pyproject.toml`
42-
devShells.aarch64-darwin.default =
43-
let
44-
# Returns a function that can be passed to `python.withPackages`
45-
arg = project.renderers.withPackages { inherit python; };
46-
47-
# Returns a wrapped environment (virtualenv like) with all our packages
48-
pythonEnv = python.withPackages arg;
49-
50-
in
51-
# Create a devShell like normal.
52-
pkgs.mkShell { packages = [ pythonEnv ]; };
53-
54-
# Build our package using `buildPythonPackage
55-
packages.aarch64-darwin.default =
13+
devShell = forAllSystems (system:
5614
let
57-
# Returns an attribute set that can be passed to `buildPythonPackage`.
58-
attrs = project.renderers.buildPythonPackage { inherit python; };
15+
pkgs = import nixpkgs { inherit system; };
5916
in
60-
# Pass attributes to buildPythonPackage.
61-
# Here is a good spot to add on any missing or custom attributes.
62-
python.pkgs.buildPythonPackage (attrs // { env.CUSTOM_ENVVAR = "hello"; });
17+
with pkgs;
18+
mkShell {
19+
name = "dev shell";
20+
21+
nativeBuildInputs = [ uv ];
22+
23+
build-system = with python3Packages; [
24+
hatchling
25+
];
26+
27+
dependencies = with python312Packages; [
28+
flask
29+
flask-restful
30+
yt-dlp
31+
podgen
32+
feedparser
33+
pygeocodio
34+
jobspy
35+
];
36+
}
37+
);
6338
};
6439
}
65-

0 commit comments

Comments
 (0)