feat: dev-registry for dev environments
This commit is contained in:
16
features/dev-registry.nix
Normal file
16
features/dev-registry.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
nixos =
|
||||
{ inputs, ... }:
|
||||
{
|
||||
nix.registry.dev = {
|
||||
from = {
|
||||
type = "indirect";
|
||||
id = "dev";
|
||||
};
|
||||
to = {
|
||||
type = "path";
|
||||
path = inputs.self.outPath;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
};
|
||||
|
||||
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
|
||||
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
||||
@@ -1,10 +1,98 @@
|
||||
_: {
|
||||
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;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.pre-commit
|
||||
pkgs.statix
|
||||
@@ -13,5 +101,7 @@ _: {
|
||||
pkgs.qemu
|
||||
];
|
||||
};
|
||||
}
|
||||
// componentShells;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ in
|
||||
"yubikey"
|
||||
"calibre"
|
||||
"steam"
|
||||
"dev-registry"
|
||||
"neovim"
|
||||
"dev"
|
||||
"claude"
|
||||
@@ -56,6 +57,7 @@ in
|
||||
"calibre"
|
||||
"steam"
|
||||
"initrd-ssh"
|
||||
"dev-registry"
|
||||
"neovim"
|
||||
"dev"
|
||||
"claude"
|
||||
|
||||
Reference in New Issue
Block a user