Skip to content

Commit 1a6c7ca

Browse files
committed
add nix to container
1 parent 56a5477 commit 1a6c7ca

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

flake.nix

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222
};
2323
};
2424

25-
outputs =
26-
{ self
27-
, nixpkgs
28-
, flake-utils
29-
, uv2nix
30-
, pyproject-nix
31-
, pyproject-build-systems
32-
, ...
33-
}: flake-utils.lib.eachDefaultSystem (system:
34-
let
25+
outputs = {
26+
self,
27+
nixpkgs,
28+
flake-utils,
29+
uv2nix,
30+
pyproject-nix,
31+
pyproject-build-systems,
32+
...
33+
}:
34+
flake-utils.lib.eachDefaultSystem (system: let
3535
inherit (nixpkgs) lib;
3636

3737
pkgs = nixpkgs.legacyPackages.${system};
3838

39-
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
39+
workspace = uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ./.;};
4040

4141
overlay = workspace.mkPyprojectOverlay {
4242
sourcePreference = "wheel";
@@ -54,34 +54,36 @@
5454
);
5555

5656
venv = pythonSet.mkVirtualEnv "wooper-dev-env" workspace.deps.default;
57-
in
58-
{
59-
packages = {
60-
default = pkgs.writeShellApplication {
61-
name = "wooper-dev";
57+
in {
58+
packages =
59+
{
60+
default = pkgs.writeShellApplication {
61+
name = "wooper-dev";
6262

63-
runtimeInputs = [ venv ];
63+
runtimeInputs = [venv];
6464

65-
text = ''
66-
uvicorn wooper_dev.main:app --host=0.0.0.0
67-
'';
68-
};
69-
} // lib.optionalAttrs pkgs.stdenv.isLinux {
70-
containerImage = pkgs.dockerTools.streamLayeredImage {
71-
name = "ghcr.io/buurro/wooper.dev";
72-
tag = pythonSet.wooper-dev.version;
73-
contents = [
74-
venv
75-
pkgs.busybox
76-
];
77-
config = {
78-
Cmd = [ "uvicorn" "wooper_dev.main:app" "--host=0.0.0.0" ];
79-
ExposedPorts = {
80-
"8000/tcp" = { };
65+
text = ''
66+
uvicorn wooper_dev.main:app --host=0.0.0.0
67+
'';
68+
};
69+
}
70+
// lib.optionalAttrs pkgs.stdenv.isLinux {
71+
containerImage = pkgs.dockerTools.streamLayeredImage {
72+
name = "ghcr.io/buurro/wooper.dev";
73+
tag = pythonSet.wooper-dev.version;
74+
contents = [
75+
venv
76+
pkgs.busybox
77+
pkgs.nix
78+
];
79+
config = {
80+
Cmd = ["uvicorn" "wooper_dev.main:app" "--host=0.0.0.0"];
81+
ExposedPorts = {
82+
"8000/tcp" = {};
83+
};
8184
};
8285
};
8386
};
84-
};
8587
devShells.default = pkgs.mkShell {
8688
name = "wooper";
8789
packages = [

wooper_dev/updater.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def main() -> None:
7272

7373
command = [
7474
"nix",
75+
"--extra-experimental-features",
76+
"nix-command flakes",
7577
"flake",
7678
"metadata",
7779
f"github:nixos/nixpkgs?ref={ref}", # ref here is the short commit hash
@@ -94,7 +96,15 @@ def main() -> None:
9496
(rev, hash, date),
9597
)
9698

97-
command = ["nix", "search", f"github:nixos/nixpkgs?rev={rev}", "^", "--json"]
99+
command = [
100+
"nix",
101+
"--extra-experimental-features",
102+
"nix-command flakes",
103+
"search",
104+
f"github:nixos/nixpkgs?rev={rev}",
105+
"^",
106+
"--json",
107+
]
98108
result = subprocess.run(command, capture_output=True, text=True, check=True)
99109

100110
# Parse the JSON output

0 commit comments

Comments
 (0)