Closed JamieMagee closed 1 year ago
+1. The difficult thing here is going to be getting the NAR hash and updating it, otherwise Nix projects could just use the regex manager and git datasource.
Related PR renovatebot/docker-buildpack#94
Hi there,
You're requesting support for a new package manager. We need to know some basic information about this package manager first. Please copy/paste the new package manager questionnaire, and fill it out in full.
Once the questionnaire is filled out we will evaluate if adding support for this manager is something we want to do.
Good luck,
The Renovate team
Please feel free to suggest corrections if any of this is wrong 😄
Did you read our documentation on adding a package manager?
nix
nix
5.4k stars on the package manager repo 8.5k stars on the default registry repo
Nix files have the .nix
extension
Lockfiles are called flake.lock
See above
No
Nix files are written in the nix language. Lockfiles are written in JSON
^1.0.0
or 1.x
?^1.0.0
or 1.x
)Used, yes. Mandatory, no.
Not 100% sure for nix files
For flake lockfiles, they can be updated with nix flake update
nix flake lock
to create
nix flake update
to update
is there anybody that got this working with regexManager?
flake lockfile updates are a WIP: https://github.com/JamieMagee/renovate-flake/pull/1
awesome! it'll be hard to implement it all though. so much things can be updated within a single nix file, but even having basic functionality would be awesome.
I'd like to start with two scenarios:
flake.lock
updatesnixpkgs
updates i.e. github:nixos/nixpkgs/nixos-21.11
to github:nixos/nixpkgs/nixos-22.05
in flake.nix
inputs.One scenario which might be easy to support is JSON lockfiles. Example:
{
"name": "release-22.05-2022-10-27T10-42-29Z",
"url": "https://github.com/NixOS/nixpkgs/archive/0a773b4ddf75c41c08a46f5c979f435bbfa6f6cb.tar.gz",
"sha256": "0vf73j9179h4wxyj9yx8mkxnnngzrva49176raw3fnlrnb94s2sg"
}
{ pkgs ? import
(
fetchTarball (
builtins.fromJSON (
builtins.readFile ./nixpkgs.json)))
{ }
}
Update script:
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
shopt -s failglob inherit_errexit
if [[ $# -ne 1 ]]; then
cat >&2 <<EOF
bump-nixpkgs.bash: Update nixpkgs.json with latest info from given release
Usage:
./bump-nixpkgs.bash RELEASE
Example:
./bump-nixpkgs.bash 22.05
Bumps nixpkgs within the 22.05 release.
EOF
exit 2
fi
release="$1"
cleanup() {
rm --force --recursive "$working_dir"
}
trap cleanup EXIT
working_dir="$(mktemp --directory)"
release_file="${working_dir}/release.json"
curl "https://api.github.com/repos/NixOS/nixpkgs/git/refs/heads/release-${release}" >"$release_file"
commit_id="$(jq --raw-output .object.sha "$release_file")"
commit_date="$(curl "https://api.github.com/repos/NixOS/nixpkgs/commits/$commit_id" | jq --raw-output '.commit.committer.date' | tr ':' '-')"
partial_file="${working_dir}/nixpkgs-partial.json"
jq --arg commit_date "$commit_date" --raw-output '{name: (.ref | split("/")[-1] + "-" + $commit_date), url: ("https://github.com/NixOS/nixpkgs/archive/" + .object.sha + ".tar.gz")}' "$release_file" >"$partial_file"
archive_checksum="$(nix-prefetch-url --unpack "$(jq --raw-output .url "$partial_file")")"
full_file="${working_dir}/nixpkgs.json"
jq '. + {sha256: $hash}' --arg hash "$archive_checksum" "$partial_file" >"$full_file"
target_file='./nixpkgs.json'
if diff "$full_file" "$target_file"; then
echo "No change; aborting." >&2
else
mv "$full_file" "$target_file"
fi
:tada: This issue has been resolved in version 34.23.0 :tada:
The release is available on:
34.23.0
Your semantic-release bot :package::rocket:
Nix is in Renovate, but currently disabled by default. The minimal renovate.json
configuration to enable it is:
"nix": {
"enabled": true
},
"lockFileMaintenance": {
"enabled": true
}
Please give it a go and leave any feedback here.
@JamieMagee Gave this a test run today and have some feedback.
Was hoping to use this as a replacement for https://github.com/DeterminateSystems/update-flake-lock, so all my dep managers are using renovate.
Will parse commented out URLs
Only finds nixpkgs url and wont update others
Wont update flake lock for "floating" versions (like nixpkgs-unstable)
Thanks for testing it out. Nix support is definitely in alpha or beta and it's why I've set it as disabled by default.
The commented our URLs being parsed is due to the regex parsing. I had originally intended to use nix
directly to extract nixpkgs
references with nix --extra-experimental-features nix-command --extra-experimental-features flakes eval --raw --file flake.nix inputs.nixpkgs.url
, but Renovate doesn't currently use external tools during the extraction phase. I wanted to get a basic level of support in, especially for flake.lock
updates, and improve nixpkgs
updates later. Maybe with a custom parser, like how we do for gradle, but implementing a nix parser is something I would like to avoid if possible :sweat_smile:
nixpkgs branch updates are the only supported updates right now. From what I can find on GitHub search, most other flake inputs use the default branch on GitHub without any versioning
flake.lock
updates for nixpkgs-unstable was one of the scenarios I tested, and the main one I wanted to support. Let me take a look at your logs and see what's up
One issue I'm currently facing is updating the lockfile for flake that have internal non public flakes in there inputs.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
warning: could not read HEAD ref from repo at 'ssh://**redacted**@gitlab.[company-internal].de/[namespace]/[repository].git'
We normally fix this issue by configuring git to replace the ssh
url with an https
url. With something like this:
git config --global --add url.https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.[company-internal].de/.insteadOf "git@gitlab.[company-internal].de:"
But as nix is started in a sidecar container this configuration isn't picked up by git.
What would you like Renovate to be able to do?
Add support for the nix package manger. A typical nix expression might contain something like:
It appears to me that this is something that Renovate could help with.
Did you already have any implementation ideas?
Requires renovatebot/docker-buildpack#80
References: