feat(project): support nixos

This commit is contained in:
2025-11-30 20:30:41 +08:00
parent 1b8c2f4ee0
commit 3231492204
5 changed files with 264 additions and 1 deletions

11
.gitignore vendored
View File

@@ -205,3 +205,14 @@ cython_debug/
marimo/_static/
marimo/_lsp/
__marimo__/
# Devenv
.devenv*
devenv.local.nix
devenv.local.yaml
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

152
devenv.lock Normal file
View File

@@ -0,0 +1,152 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1764449550,
"owner": "cachix",
"repo": "devenv",
"rev": "dfb58ac03bed07b93f629df55034bc50394d3971",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1761588595,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1761588595,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1763988335,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "50b9238891e388c9fdc6a5c49e49c42533a1b5ce",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1762808025,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1761313199,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "d1c30452ebecfc55185ae6d1c983c09da0c274ff",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-python": {
"inputs": {
"flake-compat": "flake-compat_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1763677049,
"owner": "cachix",
"repo": "nixpkgs-python",
"rev": "159d63dc49a4b12bf85fe0e83011a8b69ba1bcb0",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "nixpkgs-python",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1764316264,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9a7b80b6f82a71ea04270d7ba11b48855681c4b0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"nixpkgs-python": "nixpkgs-python",
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
"root": "root",
"version": 7
}

84
devenv.nix Normal file
View File

@@ -0,0 +1,84 @@
{
pkgs,
lib,
config,
inputs,
...
}: {
packages = with pkgs; [
glxinfo
vulkan-tools
];
languages.c.enable = true;
languages.python = {
enable = true;
version = "3.12";
uv.enable = true;
venv.enable = true;
libraries =
(with pkgs; [
zlib
vulkan-loader
# OpenGL/EGL + DRI
libGL
libGLU
libGLX
libglvnd
mesa
egl-wayland
# Wayland
wayland
libxkbcommon
# Debug Toolseglinfo/glxinfo
mesa-demos
])
++ (
with pkgs.xorg; [
libXScrnSaver
libXrender
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libX11
libXcomposite
libxshmfence
libXtst
libxcb
]
);
};
env = rec {
NIX_LD_LIBRARY_PATH = "$NIX_LD_LIBRARY_PATH:/usr/lib/wsl/lib/";
LD_LIBRARY_PATH = NIX_LD_LIBRARY_PATH;
GLVND = "${pkgs.libglvnd}";
MESA = "${pkgs.mesa}";
MESAD = MESA;
GALLIUM_DRIVER = "d3d12";
MESA_D3D12_DEFAULT_ADAPTER_NAME = "NVIDIA";
# LIBGL_ALWAYS_INDIRECT = 0;
# __GLX_VENDOR_LIBRARY_NAME = "nvidia";
# __NV_PRIME_RENDER_OFFLOAD = 1;
# __VK_LAYER_NV_optimus = "NVIDIA_only";
# PYOPENGL_PLATFORM = "egl";
# EGL_PLATFORM = "wayland";
# __EGL_VENDOR_LIBRARY_DIRS = "${MESA}/share/glvnd/egl_vendor.d:${GLVND}/share/glvnd/egl_vendor.d";
# LIBGL_DRIVERS_PATH = "${MESA}/lib/dri";
};
# https://devenv.sh/basics/
enterShell = ''
git --version # Use packages
'';
}

17
devenv.yaml Normal file
View File

@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-python:
url: github:cachix/nixpkgs-python
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true
# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"
# If you have more than one devenv you can merge them
#imports:
# - ./backend

View File

@@ -5,7 +5,6 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"genesis-world>=0.3.7",
"torch>=2.9.1",
"torchvision>=0.24.1",
]