-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update default.nix and remove overlays for uv package management
- Loading branch information
1 parent
98c834d
commit 25b3311
Showing
5 changed files
with
117 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This file defines overlays | ||
{ | ||
inputs, | ||
... | ||
}: | ||
|
||
{ | ||
# https://nixos.wiki/wiki/Overlays | ||
|
||
modifications = final: prev: { | ||
|
||
uv = prev.uv.overrideAttrs (_: rec { | ||
version = "0.5.10"; | ||
src = prev.fetchFromGitHub { | ||
owner = "astral-sh"; | ||
repo = "uv"; | ||
rev = "refs/tags/${version}"; | ||
hash = "sha256-GE/MgaX6JhzVVwrkz33fr1Vl83QD1WHhlB7vPdJ2W3c="; | ||
}; | ||
cargoDeps = prev.rustPlatform.fetchCargoTarball { | ||
inherit src; | ||
name = "uv-${version}"; | ||
hash = "sha256-GE/MgaX6JhzVVwrkz33fr1Vl83QD1WHhlB7vPdJ2W3c="; | ||
}; | ||
}); | ||
|
||
}; | ||
|
||
# When applied, the unstable nixpkgs set (declared in the flake inputs) will | ||
# be accessible through 'pkgs.unstable' | ||
unstable-packages = final: prev: { | ||
unstable = import inputs.nixpkgs { | ||
inherit (final) system; | ||
config.allowUnfree = true; | ||
}; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,78 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Get the source hash using nix-prefetch-url | ||
echo "Fetching source hash..." | ||
src_hash=$(nix-prefetch-url --unpack https://github.com/astral-sh/uv/archive/refs/tags/0.5.10.tar.gz) | ||
echo "Source hash obtained" | ||
# Function to get latest version from GitHub releases | ||
get_latest_version() { | ||
curl -s https://api.github.com/repos/astral-sh/uv/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | ||
} | ||
|
||
# Function to get hashes | ||
get_hashes() { | ||
local version=$1 | ||
|
||
# Get source hash | ||
local src_hash=$(nix-prefetch-url --unpack https://github.com/astral-sh/uv/archive/refs/tags/${version}.tar.gz) | ||
src_hash="sha256-$(nix-hash --type sha256 --to-base64 $src_hash)" | ||
|
||
# Create a temporary Nix expression to get the cargo hash | ||
cat > temp.nix << 'EOF' | ||
# Create temporary nix file for cargo hash | ||
cat > temp.nix << EOF | ||
{ pkgs ? import <nixpkgs> {} }: | ||
pkgs.rustPlatform.fetchCargoTarball { | ||
src = pkgs.fetchFromGitHub { | ||
owner = "astral-sh"; | ||
repo = "uv"; | ||
rev = "refs/tags/0.5.10"; | ||
rev = "refs/tags/${version}"; | ||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
}; | ||
name = "uv-0.5.10"; | ||
name = "uv-${version}"; | ||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
} | ||
EOF | ||
|
||
echo "Fetching cargo hash..." | ||
cargo_hash=$(nix-build temp.nix 2>&1 | grep 'got:' | tail -n1 | awk '{print $2}') | ||
rm temp.nix | ||
# Get cargo hash | ||
local cargo_hash=$(nix-build temp.nix 2>&1 | grep 'got:' | tail -n1 | awk '{print $2}') | ||
rm temp.nix | ||
|
||
echo "${src_hash} ${cargo_hash}" | ||
} | ||
|
||
# Function to update the overlay file | ||
update_overlay() { | ||
local version=$1 | ||
local src_hash=$2 | ||
local cargo_hash=$3 | ||
local overlay_file="uv-overlay.nix" | ||
|
||
cat > "${overlay_file}" << EOF | ||
final: prev: { | ||
uv = prev.uv.overrideAttrs (oldAttrs: { | ||
version = "${version}"; | ||
src = prev.fetchFromGitHub { | ||
owner = "astral-sh"; | ||
repo = "uv"; | ||
rev = "refs/tags/\${oldAttrs.version}"; | ||
hash = "${src_hash}"; | ||
}; | ||
cargoDeps = prev.rustPlatform.fetchCargoTarball { | ||
inherit (oldAttrs) src; | ||
name = "uv-\${oldAttrs.version}"; | ||
hash = "${cargo_hash}"; | ||
}; | ||
}); | ||
} | ||
EOF | ||
} | ||
|
||
# Main execution | ||
echo "Checking for latest uv version..." | ||
LATEST_VERSION=$(get_latest_version) | ||
echo "Latest version: ${LATEST_VERSION}" | ||
|
||
echo "Getting hashes..." | ||
read src_hash cargo_hash <<< $(get_hashes "${LATEST_VERSION}") | ||
echo "Source hash: ${src_hash}" | ||
echo "Cargo hash: ${cargo_hash}" | ||
|
||
echo "=== Results ===" | ||
echo "Source hash: sha256-$(nix has convert --type sha256 --to-base64 $src_hash)" | ||
echo "Cargo hash: $cargo_hash" | ||
echo "Updating overlay..." | ||
update_overlay "${LATEST_VERSION}" "${src_hash}" "${cargo_hash}" | ||
echo "Overlay updated successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
final: prev: { | ||
uv = prev.uv.overrideAttrs (oldAttrs: { | ||
version = "0.5.10"; | ||
src = prev.fetchFromGitHub { | ||
owner = "astral-sh"; | ||
repo = "uv"; | ||
rev = "refs/tags/${oldAttrs.version}"; | ||
hash = "sha256-GE/MgaX6JhzVVwrkz33fr1Vl83QD1WHhlB7vPdJ2W3c="; | ||
}; | ||
cargoDeps = prev.rustPlatform.fetchCargoTarball { | ||
inherit (oldAttrs) src; | ||
name = "uv-${oldAttrs.version}"; | ||
hash = "sha256-GE/MgaX6JhzVVwrkz33fr1Vl83QD1WHhlB7vPdJ2W3c="; | ||
}; | ||
}); | ||
} |