Skip to content

Commit

Permalink
add nix devenv flake
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Feb 12, 2025
1 parent 7655374 commit 847be96
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
146 changes: 146 additions & 0 deletions flake.lock

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

94 changes: 94 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
description = "VATSIM LoA";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default-linux";

pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

uv2nix = {
url = "github:adisbladis/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;

perSystem =
{ pkgs, lib, ... }:
let
workspace = inputs.uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };

overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};

python = pkgs.python313;

pythonSet =
(pkgs.callPackage inputs.pyproject-nix.build.packages {
inherit python;
}).overrideScope
(
lib.composeManyExtensions [
inputs.pyproject-build-systems.overlays.default
overlay
]
);
in
{
formatter = pkgs.nixfmt-rfc-style;

packages = {
default = pythonSet.mkVirtualEnv "loa-env" workspace.deps.default;
};

devShells = {
impure = pkgs.mkShell {
packages = [
python
pkgs.uv
];
shellHook = ''
unset PYTHONPATH
'';
};

default =
let
editableOverlay = workspace.mkEditablePyprojectOverlay {
root = "$REPO_ROOT";
};
editablePythonSet = pythonSet.overrideScope editableOverlay;
virtualenv = editablePythonSet.mkVirtualEnv "loa-dev-env" workspace.deps.all;
in
pkgs.mkShell {
packages = [
virtualenv
pkgs.uv
];
shellHook = ''
unset PYTHONPATH
export REPO_ROOT=$(git rev-parse --show-toplevel)
'';
};
};
};
};
}

0 comments on commit 847be96

Please sign in to comment.