Skip to content

Commit 7391736

Browse files
committed
Convert to numtides blueprint
1 parent 1d2cfe3 commit 7391736

18 files changed

+159
-237
lines changed

.envrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# Used by https://direnv.net
3+
4+
# Automatically reload when this file changes
5+
watch_file lib/devshell.nix
6+
7+
# Load `nix develop`
8+
use flake
9+
10+
# Extend the environment with per-user overrides
11+
source_env_if_exists .envrc.local

flake.lock

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

flake.nix

Lines changed: 20 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,31 @@
11
{
2-
description = "Stryke Force Website built using uv2nix";
2+
description = "Simple flake with a devshell";
33

4+
# Add all your dependencies here
45
inputs = {
5-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-24.11";
67

7-
pyproject-nix = {
8-
url = "github:nix-community/pyproject.nix";
9-
inputs.nixpkgs.follows = "nixpkgs";
10-
};
8+
blueprint.url = "github:numtide/blueprint";
9+
blueprint.inputs.nixpkgs.follows = "nixpkgs";
1110

12-
uv2nix = {
13-
url = "github:adisbladis/uv2nix";
14-
inputs.pyproject-nix.follows = "pyproject-nix";
15-
inputs.nixpkgs.follows = "nixpkgs";
16-
};
11+
pyproject-nix.url = "github:nix-community/pyproject.nix";
12+
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
1713

18-
pyproject-build-systems = {
19-
url = "github:pyproject-nix/build-system-pkgs";
20-
inputs.pyproject-nix.follows = "pyproject-nix";
21-
inputs.uv2nix.follows = "uv2nix";
22-
inputs.nixpkgs.follows = "nixpkgs";
23-
};
24-
flake-utils.url = "github:numtide/flake-utils";
14+
uv2nix.url = "github:adisbladis/uv2nix";
15+
uv2nix.inputs.pyproject-nix.follows = "pyproject-nix";
16+
uv2nix.inputs.nixpkgs.follows = "nixpkgs";
17+
18+
pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs";
19+
pyproject-build-systems.inputs.pyproject-nix.follows = "pyproject-nix";
20+
pyproject-build-systems.inputs.uv2nix.follows = "uv2nix";
21+
pyproject-build-systems.inputs.nixpkgs.follows = "nixpkgs";
2522
};
2623

24+
# Load the blueprint
2725
outputs =
28-
{
29-
self,
30-
nixpkgs,
31-
flake-utils,
32-
uv2nix,
33-
pyproject-nix,
34-
pyproject-build-systems,
35-
...
36-
}:
37-
flake-utils.lib.eachDefaultSystem (
38-
system:
39-
let
40-
pkgs = nixpkgs.legacyPackages.${system};
41-
inherit (nixpkgs) lib;
42-
43-
python = pkgs.python312;
44-
45-
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
46-
overlay = workspace.mkPyprojectOverlay {
47-
sourcePreference = "wheel";
48-
};
49-
50-
pythonSet =
51-
let
52-
baseSet = pkgs.callPackage pyproject-nix.build.packages {
53-
inherit python;
54-
stdenv = pkgs.stdenv.override {
55-
targetPlatform = pkgs.stdenv.targetPlatform // {
56-
# allow downloading of opencv-python wheel
57-
darwinSdkVersion = "15.2";
58-
};
59-
};
60-
};
61-
62-
pillowHeifOverrides = import ./lib/overrides-pillow-heif.nix { inherit pkgs; };
63-
psycopgOverrides = import ./lib/overrides-psycopg.nix { inherit pkgs; };
64-
opencvOverrides = import ./lib/overrides-opencv.nix { inherit pkgs; };
65-
strykeforceOverrides = import ./lib/overrides-strykeforce.nix { inherit pkgs workspace; };
66-
tbaApiOverrides = import ./lib/overrides-tba-api-v3client.nix { inherit pkgs; };
67-
in
68-
baseSet.overrideScope (
69-
lib.composeManyExtensions [
70-
pyproject-build-systems.overlays.default
71-
overlay
72-
pillowHeifOverrides
73-
psycopgOverrides
74-
opencvOverrides
75-
strykeforceOverrides
76-
tbaApiOverrides
77-
]
78-
);
79-
80-
inherit (pkgs) writeShellApplication;
81-
82-
in
83-
{
84-
checks = pythonSet.website.passthru.tests;
85-
86-
packages = {
87-
venv = pythonSet.mkVirtualEnv "strykeforce-env" workspace.deps.default;
88-
89-
static = import ./lib/static.nix {
90-
inherit pkgs pythonSet;
91-
inherit (self.packages.${system}) venv;
92-
};
93-
94-
manage = import ./lib/manage.nix {
95-
inherit pkgs;
96-
inherit (self.packages.${system}) venv;
97-
inherit (self.packages.${system}) static;
98-
};
99-
100-
manage-old = writeShellApplication {
101-
name = "strykeforce-manage";
102-
103-
text = ''
104-
export DJANGO_SETTINGS_MODULE=website.settings.production
105-
export SECRET_KEY=notsecret
106-
export TBA_READ_KEY=
107-
export EMAIL_HOST_USER=
108-
export EMAIL_HOST_PASSWORD=
109-
export STATIC_ROOT=${self.packages.${system}.static}
110-
exec ${self.packages.${system}.venv}/bin/strykeforce-manage "$@"
111-
'';
112-
};
113-
114-
# refresh venv for Pycharm with: nix build .#venv -o venv
115-
default = self.packages.${system}.venv;
116-
};
117-
118-
apps = {
119-
default = {
120-
type = "app";
121-
program = "${self.packages.${system}.manage}/bin/strykeforce-manage";
122-
};
123-
};
124-
125-
devShells.default =
126-
let
127-
pkgs = nixpkgs.legacyPackages.${system};
128-
packages = with pkgs; [
129-
cachix
130-
just
131-
nil
132-
nix-output-monitor
133-
nixfmt-rfc-style
134-
nodejs
135-
postgresql.dev
136-
pre-commit
137-
python
138-
tailwindcss
139-
uv2nix.packages.${system}.uv-bin
140-
watchman
141-
];
142-
in
143-
pkgs.mkShell {
144-
inherit packages;
145-
shellHook = ''
146-
unset PYTHONPATH
147-
export UV_PYTHON_DOWNLOADS=never
148-
'';
149-
};
150-
}
151-
)
152-
// {
153-
nixosModules.strykeforce = import ./lib/module.nix self;
154-
nixosModules.default = self.nixosModules.strykeforce;
155-
156-
nixosConfigurations.container = import ./lib/container.nix {
157-
inherit self nixpkgs;
158-
};
26+
inputs:
27+
inputs.blueprint {
28+
inherit inputs;
29+
prefix = "lib";
15930
};
16031
}

lib/container.nix

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/devshell.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
flake,
3+
perSystem,
4+
pkgs,
5+
}:
6+
pkgs.mkShell {
7+
packages = with pkgs; [
8+
(flake.lib.python pkgs)
9+
cachix
10+
just
11+
nil
12+
nix-output-monitor
13+
nixfmt-rfc-style
14+
nodejs
15+
postgresql.dev
16+
pre-commit
17+
tailwindcss
18+
perSystem.uv2nix.uv-bin
19+
watchman
20+
];
21+
22+
env = {
23+
UV_PYTHON_DOWNLOADS = "never";
24+
};
25+
26+
shellHook = ''
27+
unset PYTHONPATH
28+
'';
29+
}

lib/lib/default.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{ flake, inputs, ... }:
2+
let
3+
workspace = inputs.uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ../../.; };
4+
5+
overlay = workspace.mkPyprojectOverlay {
6+
sourcePreference = "wheel";
7+
};
8+
9+
python = pkgs: pkgs.python312;
10+
11+
pythonSets =
12+
pkgs:
13+
let
14+
baseSet = pkgs.callPackage inputs.pyproject-nix.build.packages {
15+
python = python pkgs;
16+
stdenv = pkgs.stdenv.override {
17+
targetPlatform = pkgs.stdenv.targetPlatform // {
18+
# allow downloading of opencv-python wheel
19+
darwinSdkVersion = "15.2";
20+
};
21+
};
22+
};
23+
24+
pillowHeifOverrides = import ./overrides/overrides-pillow-heif.nix { inherit pkgs; };
25+
psycopgOverrides = import ./overrides/overrides-psycopg.nix { inherit pkgs; };
26+
opencvOverrides = import ./overrides/overrides-opencv.nix { inherit pkgs; };
27+
strykeforceOverrides = import ./overrides/overrides-strykeforce.nix { inherit pkgs workspace; };
28+
tbaApiOverrides = import ./overrides/overrides-tba-api-v3client.nix { inherit pkgs; };
29+
in
30+
baseSet.overrideScope (
31+
inputs.nixpkgs.lib.composeManyExtensions [
32+
inputs.pyproject-build-systems.overlays.default
33+
overlay
34+
pillowHeifOverrides
35+
psycopgOverrides
36+
opencvOverrides
37+
strykeforceOverrides
38+
tbaApiOverrides
39+
]
40+
);
41+
in
42+
{
43+
44+
inherit
45+
overlay
46+
python
47+
pythonSets
48+
workspace
49+
;
50+
51+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)