Skip to content

Commit e165210

Browse files
committed
misc: add nix flake
1 parent 53f6486 commit e165210

File tree

2 files changed

+165
-0
lines changed

2 files changed

+165
-0
lines changed

flake.lock

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

flake.nix

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
4+
pyproject-nix = {
5+
url = "github:nix-community/pyproject.nix";
6+
inputs.nixpkgs.follows = "nixpkgs";
7+
};
8+
uv2nix = {
9+
url = "github:adisbladis/uv2nix";
10+
inputs.pyproject-nix.follows = "pyproject-nix";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
};
13+
};
14+
15+
outputs = {
16+
self,
17+
nixpkgs,
18+
pyproject-nix,
19+
uv2nix,
20+
systems,
21+
...
22+
}: let
23+
forEachSystem = nixpkgs.lib.genAttrs (import systems);
24+
pkgsFor = forEachSystem (system: import nixpkgs {inherit system;});
25+
26+
workspace = uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ./.;};
27+
28+
overlay = workspace.mkPyprojectOverlay {
29+
sourcePreference = "wheel"; # or sourcePreference = "sdist";
30+
};
31+
32+
pyprojectOverrides = _final: _prev: {
33+
};
34+
35+
pythonSets = forEachSystem (
36+
system:
37+
(pkgsFor.${system}.callPackage pyproject-nix.build.packages {
38+
python = pkgsFor.${system}.python312;
39+
})
40+
.overrideScope
41+
(nixpkgs.lib.composeExtensions overlay pyprojectOverrides)
42+
);
43+
in {
44+
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
45+
46+
devShells = forEachSystem (system: {
47+
default = let
48+
editableOverlay = workspace.mkEditablePyprojectOverlay {
49+
root = "$REPO_ROOT";
50+
};
51+
editablePythonSets = pythonSets.${system}.overrideScope editableOverlay;
52+
53+
virtualenv = editablePythonSets.mkVirtualEnv "scim2-cli" workspace.deps.all;
54+
in
55+
pkgsFor.${system}.mkShell {
56+
packages = with pkgsFor.${system}; [
57+
uv
58+
virtualenv
59+
];
60+
shellHook = ''
61+
unset PYTHONPATH
62+
export REPO_ROOT=$(git rev-parse --show-toplevel)
63+
'';
64+
};
65+
});
66+
67+
packages = forEachSystem (system: {
68+
default = pythonSets.${system}.mkVirtualEnv "scim2-cli" workspace.deps.default;
69+
});
70+
71+
apps = forEachSystem (system: {
72+
default = {
73+
type = "app";
74+
program = "${self.packages.${system}.default}/bin/scim2";
75+
};
76+
});
77+
};
78+
}

0 commit comments

Comments
 (0)