diff --git a/flake.nix b/flake.nix index 4fc64af..38a1d63 100644 --- a/flake.nix +++ b/flake.nix @@ -43,6 +43,7 @@ nixpkgs.lib.nixosSystem { system = arch; modules = [ + (import ./overlays) ./nixosModules ./hosts/${host} ./hosts/base diff --git a/nixosModules/dev/python.nix b/nixosModules/dev/python.nix index 00fc715..eb29c22 100644 --- a/nixosModules/dev/python.nix +++ b/nixosModules/dev/python.nix @@ -28,7 +28,7 @@ in python3 poetry pre-commit - uv + uv-bin ] ++ lib.optionals cfg.install-additional [ python313 diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..d1c5771 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + nixpkgs.overlays = [ + (import ./uv) + ]; +} diff --git a/overlays/uv/default.nix b/overlays/uv/default.nix new file mode 100644 index 0000000..4f235a0 --- /dev/null +++ b/overlays/uv/default.nix @@ -0,0 +1,3 @@ +(final: prev: { + uv-bin = prev.callPackage ./package.nix { }; +}) diff --git a/overlays/uv/package.nix b/overlays/uv/package.nix new file mode 100644 index 0000000..ea95dcf --- /dev/null +++ b/overlays/uv/package.nix @@ -0,0 +1,58 @@ +{ + stdenv, + versionCheckHook, + lib, + installShellFiles, + autoPatchelfHook, +}: +stdenv.mkDerivation rec { + pname = "uv-bin"; + version = "0.5.5"; + + src = fetchTarball { + url = "https://github.com/astral-sh/uv/releases/download/${version}/uv-x86_64-unknown-linux-gnu.tar.gz"; + sha256 = "1rgqmgj9syjansfmkvg1819i70f41za647izgh5hrvjsmcnm6nk7"; + }; + + nativeBuildInputs = [ + installShellFiles + autoPatchelfHook + stdenv.cc.cc.lib + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + + cp * $out/bin + + runHook postInstall + ''; + + dontAutoPatchelf = true; + + postFixup = '' + autoPatchelf -- "$out" + + export HOME=$TMPDIR + installShellCompletion --cmd uv \ + --bash <($out/bin/uv --generate-shell-completion bash) \ + --fish <($out/bin/uv --generate-shell-completion fish) \ + --zsh <($out/bin/uv --generate-shell-completion zsh) + ''; + + nativeCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = [ "--version" ]; + + meta = { + description = "Extremely fast Python package installer and resolver, written in Rust"; + homepage = "https://github.com/astral-sh/uv"; + license = with lib.licenses; [ + asl20 + mit + ]; + }; +}