Add a Nix flake packaging lc and astra, with a NixOS module - #250
Open
charnock-fr wants to merge 1 commit into
Open
charnock-fr wants to merge 1 commit into
charnock-fr wants to merge 1 commit into
Conversation
packages.default builds lc's wheel from the flake source and wraps lc,
astra and git-annex's four executables in `uv tool run --from <wheel>`,
so uv installs Python and lc's dependencies at first run, as with uv
tool install. No uv.lock is tracked: dependencies resolve with
--exclude-newer set to the commit's date, so one commit resolves one
set of them. The package also provides uv and git and puts them first
on the wrappers' PATH, so lc, git add and uv add use the same uv and
git. packages.lc is an alias for `nix run ...#lc`.
nixosModules.default adds programs.lightcone.enable. It installs the
package, sets programs.git.package to the package's git, enables
nix-ld, and sets python-preference = "only-managed" in
/etc/uv/uv.toml. NixOS cannot run the interpreters and wheels uv
downloads without nix-ld, and a Nix Python on PATH would otherwise be
picked for project environments. Evaluation fails if the package's uv
is below 0.12; `.override { uv = ...; }` changes it.
hatch-vcs cannot see tags inside a Nix build, so the flake versions
itself <next>.dev0+g<commit>.nix, with <next> derived from lastRelease.
The dev and +g<commit> parts keep lc's rerun pin on the exact commit;
.nix marks the dev count as unknown rather than zero.
lastRelease must be set to the new tag after every release; nix.yml
fails until it is. nix.yml also builds the package on x86_64-linux,
aarch64-linux and aarch64-darwin and runs lc init in a new directory.
Checked on NixOS: nix flake check --all-systems passes, the module
evaluates with the default package and with a uv override, and the
getting-started guide runs end to end in nix shell, including the
fresh-clone check.
Signed-off-by: Tom Charnock <tom@charnock.fr>
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Would close #249 . On NixOS,
lc runandlc materializealso need#247; the flake builds and
lc initworks without it.Whats in this commit
flake.nixpackages.default(alsopackages.lc):lc,astraand git-annex's four executables for x86_64-linux, aarch64-linux and aarch64-darwin. Each is a wrapper arounduv tool run --from <wheel>, with lc's wheel built from the flake source. uv installs Python and lc's dependencies on first run, asuv tool installdoes, with--exclude-newerset to the commit's date so a commit's resolution does not drift as new releases appear. lc's dependency tree is not repackaged for Nix.PATH, solc,git addanduv adduse the same uv and git..override { uv = …; }changes uv.nixosModules.default:programs.lightcone.enableinstalls the package and setsprograms.git.packageto the package's git. It also:python-preference = "only-managed"in/etc/uv/uv.toml, so uv never builds a project on a Nix Python. It is a config file becausechild_env()scrubs ambientUV_*settings. It is not an install setting, so it moves noenv_versionand raises no machine-config advisory;required-versionlightcone projects declare.flake.lock: pins nixpkgs-unstable, which supplies uv, git and the wheel's build tools..github/workflows/nix.ymllc initandlc init --checkwith it;lastReleasefalls behind the latest tag, printing the valuu to set.docs/user/install.md: Nix and NixOS tabs for install, upgrade and uninstall.Versioning
Nix builds see no tags, so hatch-vcs cannot version them. The flake builds
<next>.dev0+g<commit>.nix, with<next>derived fromlastReleasethe way hatch-vcs guesses it. Thedevand+g<commit>parts keep_engine_requirement()pinning reruns to the exact commit; I'm using.nixto mark the dev count as unknown rather than believing the zero. After each releaselastReleaseneeds to be set to the new tag.nix.ymlfails until it is.uv versions
Bumping the image's pinned uv (
UV_IMAGE, as in #248) changes nothing in the flake, and updatingflake.lockchanges nothing in images. They are two different uvs, like for the requirement #248 describes for CI which applies to any user whose uv is newer than the images:UV_IMAGEis copied into a containerized project's image, where it installs the interpreter and syncs the environment.flake.lock(currently 0.12.17). It runslcitself and, in direct mode, the project'suv lockanduv sync.The two meet in one place.
lc initpins.python-versionto the interpreterlcruns on, which the flake's uv chose, andlc buildthen needsUV_IMAGE's uv to know that Python patch. That holds while the flake's uv is no newer thanUV_IMAGE's i.e. 0.12.23 after #248, so aflake.lockupdate should not move uv past it.Testing
On NixOS:
nix flake check --all-systemspasses.nix shell, including the fresh-clone check.aarch64-darwin is evaluated only; the first macOS build would come from the CI job.
Known gaps