From 4a4f16676d35da9fe1b19728dfa12805029d586f Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Fri, 14 Jun 2024 21:02:23 -0700 Subject: [PATCH] Update version to 2.90.0-rc1 Change-Id: I05f3efd6663bec418ce93fb2dca53977d3523f7d --- flake.lock | 50 ++++++++++++++++++----------- flake.nix | 43 +++++++++++++++---------- set_version.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ src/settings.rs | 63 +++++++++++++++++++++---------------- 4 files changed, 178 insertions(+), 61 deletions(-) create mode 100755 set_version.py diff --git a/flake.lock b/flake.lock index da40dcb..a27a16a 100644 --- a/flake.lock +++ b/flake.lock @@ -40,23 +40,21 @@ "lix": { "inputs": { "flake-compat": "flake-compat", + "nix2container": "nix2container", "nixpkgs": "nixpkgs", "nixpkgs-regression": "nixpkgs-regression", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1714955862, - "narHash": "sha256-REWlo2RYHfJkxnmZTEJu3Cd/2VM+wjjpPy7Xi4BdDTQ=", - "ref": "refs/tags/2.90-beta.1", - "rev": "b6799ab0374a8e1907a48915d3187e07da41d88c", - "revCount": 15501, - "type": "git", - "url": "https://git.lix.systems/lix-project/lix" + "lastModified": 1718419213, + "narHash": "sha256-WY7BGnu5PnbK4O8cKKv9kvxwzZIGbIQUQLGPHFXitI0=", + "rev": "253546d5fbf8a5aa60ac8164c1b4f5794dc4e9d1", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/253546d5fbf8a5aa60ac8164c1b4f5794dc4e9d1.tar.gz" }, "original": { - "ref": "refs/tags/2.90-beta.1", - "type": "git", - "url": "https://git.lix.systems/lix-project/lix" + "type": "tarball", + "url": "https://git.lix.systems/lix-project/lix/archive/2.90.0-rc1.tar.gz" } }, "naersk": { @@ -79,18 +77,34 @@ "type": "github" } }, + "nix2container": { + "flake": false, + "locked": { + "lastModified": 1712990762, + "narHash": "sha256-hO9W3w7NcnYeX8u8cleHiSpK2YJo7ecarFTUlbybl7k=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "20aad300c925639d5d6cbe30013c8357ce9f2a2e", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1711481231, - "narHash": "sha256-J/fW3Xhm3WsJPNd8ksZmfMnol5aOG2qEMDPbOnNNdTQ=", + "lastModified": 1718379166, + "narHash": "sha256-B/Q/Pf4kD+yWk3fGh5H0fUpwxmLgEKt9KBon+bZ3d9U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9d6ddb13cee3cc1192e4430277708c732685f38a", + "rev": "93fbfcd45e966ea1cff043d48bd45d1285082770", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11-small", + "ref": "nixos-24.05-small", "repo": "nixpkgs", "type": "github" } @@ -113,16 +127,16 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1714763106, - "narHash": "sha256-DrDHo74uTycfpAF+/qxZAMlP/Cpe04BVioJb6fdI0YY=", + "lastModified": 1718379166, + "narHash": "sha256-B/Q/Pf4kD+yWk3fGh5H0fUpwxmLgEKt9KBon+bZ3d9U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e9be42459999a253a9f92559b1f5b72e1b44c13d", + "rev": "93fbfcd45e966ea1cff043d48bd45d1285082770", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-24.05-small", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index fd0d292..c4fe485 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "The Lix Installer"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; fenix = { url = "github:nix-community/fenix"; @@ -15,7 +15,10 @@ }; lix = { - url = "git+https://git.lix.systems/lix-project/lix?ref=refs/tags/2.90-beta.1"; + # See set_version.py + # BEGIN GENERATE-URLS + url = "https://git.lix.systems/lix-project/lix/archive/2.90.0-rc1.tar.gz"; + # END GENERATE-URLS # Omitting `inputs.nixpkgs.follows = "nixpkgs";` on purpose }; }; @@ -122,6 +125,13 @@ let toolchain = fenixToolchain system; check = import ./nix/check.nix { inherit pkgs toolchain; }; + + inherit (pkgs) lib; + + pythonEnv = pkgs.python3.withPackages (p: [ + (p.toPythonModule pkgs.xonsh-unwrapped) + p.requests + ]); in { default = pkgs.mkShell { @@ -129,10 +139,21 @@ RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; - nativeBuildInputs = with pkgs; [ ]; - buildInputs = with pkgs; [ + buildInputs = lib.optionals (pkgs.stdenv.isDarwin) + (with pkgs; [ + libiconv + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.SystemConfiguration + ]) + ++ lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ + checkpolicy + semodule-utils + /* users are expected to have a system docker, too */ + ]); + + nativeBuildInputs = with pkgs; [ zig - xonsh + pythonEnv awscli2 toolchain rust-analyzer @@ -148,17 +169,7 @@ check.check-editorconfig check.check-semver check.check-clippy - ] - ++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [ - libiconv - darwin.apple_sdk.frameworks.Security - darwin.apple_sdk.frameworks.SystemConfiguration - ]) - ++ lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ - checkpolicy - semodule-utils - /* users are expected to have a system docker, too */ - ]); + ]; }; }); diff --git a/set_version.py b/set_version.py new file mode 100755 index 0000000..05562f2 --- /dev/null +++ b/set_version.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +from pathlib import Path +import textwrap +import dataclasses +import requests + +SYSTEMS = ['x86_64-linux', 'x86_64-darwin', 'aarch64-linux', 'aarch64-darwin'] + +@dataclasses.dataclass +class Package: + system: str + version: str + + def url(self): + return f"https://releases.lix.systems/lix/lix-{self.version}/lix-{self.version}-{self.system}.tar.xz"; + + def variable_name(self): + system = self.system.replace('-', '_').upper() + return f'LIX_{system}_URL' + + +def make_urls_section(packages: list[Package]): + def one_item(package: Package): + return textwrap.dedent("""\ + /// Default [`nix_package_url`](CommonSettings::nix_package_url) for {system}. + pub const {variable_name}: &str = + "{url}"; + """).format(system=package.system, variable_name=package.variable_name(), url=package.url()) + + return '\n'.join(one_item(package) for package in packages) + +def replace_section(old: str, section: str) -> str: + lines = [] + eat = False + + for line in old.splitlines(): + next_eat = eat + + if 'BEGIN GENERATE-URLS' in line.strip(): + next_eat = True + elif 'END GENERATE-URLS' in line.strip(): + lines.append(section) + eat = False + next_eat = False + + if not eat: + lines.append(line) + eat = next_eat + + return '\n'.join(lines) + +def replace_in_file(file: Path, section: str): + new_file = replace_section(file.read_text(), section) + file.write_text(new_file) + + +def make_flake_url_section(version: str) -> str: + return f' url = "https://git.lix.systems/lix-project/lix/archive/{version}.tar.gz";' + + +def main(): + import argparse + ap = argparse.ArgumentParser(description='Update the version of lix-installer') + + ap.add_argument('new_version', help='The new version') + + args = ap.parse_args() + + settings_rs = Path('src/settings.rs') + packages = [Package(system, args.new_version) for system in SYSTEMS] + + for package in packages: + resp = requests.head(package.url()) + if resp.status_code != 200: + print(f'Warning: broken URL {package.url()} returns HTTP {resp.status_code}') + + replace_in_file(settings_rs, make_urls_section(packages)) + flake_nix = Path('flake.nix') + replace_in_file(flake_nix, make_flake_url_section(args.new_version)) + +if __name__ == '__main__': + main() + diff --git a/src/settings.rs b/src/settings.rs index 24fe19f..da707ef 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -11,21 +11,25 @@ use url::Url; pub const SCRATCH_DIR: &str = "/nix/temp-install-dir"; -/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux x86_64 -pub const NIX_X64_64_LINUX_URL: &str = - "https://releases.lix.systems/lix/lix-2.90-beta.1/nix-2.90.0-beta.1-x86_64-linux.tar.xz"; -/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux x86 (32 bit) -pub const NIX_I686_LINUX_URL: &str = - "https://releases.lix.systems/lix/lix-2.90-beta.1/nix-2.90.0-beta.1-i686-linux.tar.xz"; -/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux aarch64 -pub const NIX_AARCH64_LINUX_URL: &str = - "https://releases.lix.systems/lix/lix-2.90-beta.1/nix-2.90.0-beta.1-aarch64-linux.tar.xz"; -/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Darwin x86_64 -pub const NIX_X64_64_DARWIN_URL: &str = - "https://releases.lix.systems/lix/lix-2.90-beta.1/nix-2.90.0-beta.1-x86_64-darwin.tar.xz"; -/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Darwin aarch64 -pub const NIX_AARCH64_DARWIN_URL: &str = - "https://releases.lix.systems/lix/lix-2.90-beta.1/nix-2.90.0-beta.1-aarch64-darwin.tar.xz"; +// See set_version.py +// BEGIN GENERATE-URLS +/// Default [`nix_package_url`](CommonSettings::nix_package_url) for x86_64-linux. +pub const LIX_X86_64_LINUX_URL: &str = + "https://releases.lix.systems/lix/lix-2.90.0-rc1/lix-2.90.0-rc1-x86_64-linux.tar.xz"; + +/// Default [`nix_package_url`](CommonSettings::nix_package_url) for x86_64-darwin. +pub const LIX_X86_64_DARWIN_URL: &str = + "https://releases.lix.systems/lix/lix-2.90.0-rc1/lix-2.90.0-rc1-x86_64-darwin.tar.xz"; + +/// Default [`nix_package_url`](CommonSettings::nix_package_url) for aarch64-linux. +pub const LIX_AARCH64_LINUX_URL: &str = + "https://releases.lix.systems/lix/lix-2.90.0-rc1/lix-2.90.0-rc1-aarch64-linux.tar.xz"; + +/// Default [`nix_package_url`](CommonSettings::nix_package_url) for aarch64-darwin. +pub const LIX_AARCH64_DARWIN_URL: &str = + "https://releases.lix.systems/lix/lix-2.90.0-rc1/lix-2.90.0-rc1-aarch64-darwin.tar.xz"; + +// END GENERATE-URLS #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "cli", derive(clap::ValueEnum))] @@ -150,31 +154,34 @@ pub struct CommonSettings { #[cfg_attr( all(target_os = "macos", target_arch = "x86_64", feature = "cli"), clap( - default_value = NIX_X64_64_DARWIN_URL, + default_value = LIX_X86_64_DARWIN_URL, ) )] #[cfg_attr( all(target_os = "macos", target_arch = "aarch64", feature = "cli"), clap( - default_value = NIX_AARCH64_DARWIN_URL, + default_value = LIX_AARCH64_DARWIN_URL, ) )] #[cfg_attr( all(target_os = "linux", target_arch = "x86_64", feature = "cli"), clap( - default_value = NIX_X64_64_LINUX_URL, + default_value = LIX_X86_64_LINUX_URL, ) )] + // FIXME(i686): release i686 binaries again + /* #[cfg_attr( all(target_os = "linux", target_arch = "x86", feature = "cli"), clap( - default_value = NIX_I686_LINUX_URL, + default_value = LIX_I686_LINUX_URL, ) )] + */ #[cfg_attr( all(target_os = "linux", target_arch = "aarch64", feature = "cli"), clap( - default_value = NIX_AARCH64_LINUX_URL, + default_value = LIX_AARCH64_LINUX_URL, ) )] pub nix_package_url: UrlOrPath, @@ -216,7 +223,6 @@ pub struct CommonSettings { ) )] pub enable_flakes: bool, - } impl CommonSettings { @@ -231,21 +237,24 @@ impl CommonSettings { match (Architecture::host(), OperatingSystem::host()) { #[cfg(target_os = "linux")] (Architecture::X86_64, OperatingSystem::Linux) => { - url = NIX_X64_64_LINUX_URL; + url = LIX_X86_64_LINUX_URL; nix_build_user_prefix = "nixbld"; nix_build_user_id_base = 30000; nix_build_user_count = 32; }, + // FIXME(i686): support i686-linux again + /* #[cfg(target_os = "linux")] (Architecture::X86_32(_), OperatingSystem::Linux) => { - url = NIX_I686_LINUX_URL; + url = LIX_I686_LINUX_URL; nix_build_user_prefix = "nixbld"; nix_build_user_id_base = 30000; nix_build_user_count = 32; }, + */ #[cfg(target_os = "linux")] (Architecture::Aarch64(_), OperatingSystem::Linux) => { - url = NIX_AARCH64_LINUX_URL; + url = LIX_AARCH64_LINUX_URL; nix_build_user_prefix = "nixbld"; nix_build_user_id_base = 30000; nix_build_user_count = 32; @@ -253,7 +262,7 @@ impl CommonSettings { #[cfg(target_os = "macos")] (Architecture::X86_64, OperatingSystem::MacOSX { .. }) | (Architecture::X86_64, OperatingSystem::Darwin) => { - url = NIX_X64_64_DARWIN_URL; + url = LIX_X86_64_DARWIN_URL; nix_build_user_prefix = "_nixbld"; nix_build_user_id_base = 300; nix_build_user_count = 32; @@ -261,7 +270,7 @@ impl CommonSettings { #[cfg(target_os = "macos")] (Architecture::Aarch64(_), OperatingSystem::MacOSX { .. }) | (Architecture::Aarch64(_), OperatingSystem::Darwin) => { - url = NIX_AARCH64_DARWIN_URL; + url = LIX_AARCH64_DARWIN_URL; nix_build_user_prefix = "_nixbld"; nix_build_user_id_base = 300; nix_build_user_count = 32; @@ -668,4 +677,4 @@ mod tests { ); Ok(()) } -} +} \ No newline at end of file