feat: dev-registry for dev environments

This commit is contained in:
2026-03-27 15:05:09 +01:00
parent c40fbaec57
commit 38cdcebddd
4 changed files with 119 additions and 10 deletions

16
features/dev-registry.nix Normal file
View File

@@ -0,0 +1,16 @@
{
nixos =
{ inputs, ... }:
{
nix.registry.dev = {
from = {
type = "indirect";
id = "dev";
};
to = {
type = "path";
path = inputs.self.outPath;
};
};
};
}

View File

@@ -36,6 +36,7 @@
}; };
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
}; };
outputs = outputs =

View File

@@ -1,17 +1,107 @@
_: { _: {
perSystem = perSystem =
{ pkgs, ... }: { pkgs, lib, ... }:
let
# libraries needed by python native extensions
pythonLibraries = [
pkgs.stdenv.cc.cc.lib
pkgs.zlib
pkgs.openssl
pkgs.curl
];
mkUv = python: {
packages = [
python
pkgs.uv
];
libraries = pythonLibraries;
env = {
UV_PYTHON_DOWNLOADS = "never";
UV_PYTHON_PREFERENCE = "only-system";
UV_PYTHON = "${python}/bin/python";
};
shellHook = ''
unset PYTHONPATH
export UV_PROJECT_ENVIRONMENT="$HOME/.venvs/$(basename "$PWD")-$(echo "$PWD" | md5sum | cut -c1-8)"
'';
};
# composable dev environment components
# each is exposed as its own devShell, layered via `use dev` in .envrc
components = {
uv_10 = mkUv pkgs.python310;
uv_11 = mkUv pkgs.python311;
uv_12 = mkUv pkgs.python312;
uv_13 = mkUv pkgs.python313;
uv_14 = mkUv pkgs.python314;
pg_15 = {
packages = [ pkgs.postgresql_15 ];
};
pg_16 = {
packages = [ pkgs.postgresql_16 ];
};
pg_17 = {
packages = [ pkgs.postgresql_17 ];
};
pg_18 = {
packages = [ pkgs.postgresql_18 ];
};
rust = {
packages = [
pkgs.rustc
pkgs.cargo
pkgs.rust-analyzer
pkgs.openssl
pkgs.pkg-config
];
};
cmake = {
packages = [
pkgs.cmake
pkgs.ninja
];
};
};
mkComponentShell =
component:
let
c = components.${component};
libraries = c.libraries or [ ];
libPath = lib.makeLibraryPath libraries;
in
pkgs.mkShell (
{
packages = c.packages or [ ];
shellHook =
(lib.optionalString (libraries != [ ]) ''
export LD_LIBRARY_PATH="${libPath}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
'')
+ (c.shellHook or "");
}
// lib.optionalAttrs (c ? env) { inherit (c) env; }
);
componentShells = lib.mapAttrs (name: _: mkComponentShell name) components;
in
{ {
formatter = pkgs.nixfmt-tree; formatter = pkgs.nixfmt-tree;
devShells.default = pkgs.mkShell { devShells = {
packages = [ default = pkgs.mkShell {
pkgs.pre-commit packages = [
pkgs.statix pkgs.pre-commit
pkgs.shellcheck pkgs.statix
pkgs.shfmt pkgs.shellcheck
pkgs.qemu pkgs.shfmt
]; pkgs.qemu
}; ];
};
}
// componentShells;
}; };
} }

View File

@@ -30,6 +30,7 @@ in
"yubikey" "yubikey"
"calibre" "calibre"
"steam" "steam"
"dev-registry"
"neovim" "neovim"
"dev" "dev"
"claude" "claude"
@@ -56,6 +57,7 @@ in
"calibre" "calibre"
"steam" "steam"
"initrd-ssh" "initrd-ssh"
"dev-registry"
"neovim" "neovim"
"dev" "dev"
"claude" "claude"