From 2c91bea9eb3d8851c4d7f7f02e0891a4023f6947 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Mon, 6 Feb 2023 07:50:23 -0800 Subject: [PATCH] Add 32 bit support (#229) * Add 32 bit support * Add buildkite job for i686 * Use x86 for system on i686 * Adapt nix-installer.sh script to support i686 --- .buildkite/pipeline.yml | 8 ++++++++ flake.nix | 13 ++++++++++++- nix-installer.sh | 5 +++++ src/planner/mod.rs | 4 ++++ src/settings.rs | 19 +++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4cd586e..2aaad78 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -25,6 +25,14 @@ steps: - nix --extra-experimental-features "nix-command flakes" build .#packages.x86_64-linux.nix-installer-static -L - cp result/bin/nix-installer ./nix-installer-x86_64-linux - buildkite-agent artifact upload nix-installer-x86_64-linux + - label: nix-installer-i686-linux + agents: + system: x86_64-linux + nix: 1 + command: + - nix --extra-experimental-features "nix-command flakes" build .#packages.i686-linux.nix-installer-static -L + - cp result/bin/nix-installer ./nix-installer-i686-linux + - buildkite-agent artifact upload nix-installer-i686-linux - label: nix-installer-aarch64-linux agents: system: aarch64-linux diff --git a/flake.nix b/flake.nix index 6e264a0..e58297c 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,7 @@ , ... } @ inputs: let - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + supportedSystems = [ "i686-linux" "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: (forSystem system f)); @@ -49,6 +49,8 @@ stable.rust-src ] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [ targets.x86_64-unknown-linux-musl.stable.rust-std + ] ++ nixpkgs.lib.optionals (system == "i686-linux") [ + targets.i686-unknown-linux-musl.stable.rust-std ] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [ targets.aarch64-unknown-linux-musl.stable.rust-std ]); @@ -99,6 +101,12 @@ (sharedAttrs // { CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; }); + } // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "i686-linux") rec { + default = nix-installer-static; + nix-installer-static = naerskLib.buildPackage + (sharedAttrs // { + CARGO_BUILD_TARGET = "i686-unknown-linux-musl"; + }); } // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "aarch64-linux") rec { default = nix-installer-static; nix-installer-static = naerskLib.buildPackage @@ -170,6 +178,9 @@ } // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") { inherit (pkgs) nix-installer-static; default = pkgs.nix-installer-static; + } // nixpkgs.lib.optionalAttrs (system == "i686-linux") { + inherit (pkgs) nix-installer-static; + default = pkgs.nix-installer-static; } // nixpkgs.lib.optionalAttrs (system == "aarch64-linux") { inherit (pkgs) nix-installer-static; default = pkgs.nix-installer-static; diff --git a/nix-installer.sh b/nix-installer.sh index 18d1bfe..1b0c5c4 100755 --- a/nix-installer.sh +++ b/nix-installer.sh @@ -192,6 +192,11 @@ get_architecture() { x86_64 | x86-64 | x64 | amd64) _cputype=x86_64 ;; + + i686) + _cputype=i686 + ;; + *) err "unknown CPU type: $_cputype" ;; diff --git a/src/planner/mod.rs b/src/planner/mod.rs index 3c73b8d..bd9de53 100644 --- a/src/planner/mod.rs +++ b/src/planner/mod.rs @@ -135,6 +135,10 @@ impl BuiltinPlanner { Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) }, #[cfg(target_os = "linux")] + (Architecture::X86_32(_), OperatingSystem::Linux) => { + Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) + }, + #[cfg(target_os = "linux")] (Architecture::Aarch64(_), OperatingSystem::Linux) => { Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) }, diff --git a/src/settings.rs b/src/settings.rs index 3cf367b..465f6b0 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -11,6 +11,9 @@ use crate::channel_value::ChannelValue; /// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux x86_64 pub const NIX_X64_64_LINUX_URL: &str = "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-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.nixos.org/nix/nix-2.12.0/nix-2.12.0-i686-linux.tar.xz"; /// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux aarch64 pub const NIX_AARCH64_LINUX_URL: &str = "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-aarch64-linux.tar.xz"; @@ -169,6 +172,12 @@ pub struct CommonSettings { default_value = NIX_X64_64_LINUX_URL, ) )] + #[cfg_attr( + all(target_os = "linux", target_arch = "x86", feature = "cli"), + clap( + default_value = NIX_I686_LINUX_URL, + ) + )] #[cfg_attr( all(target_os = "linux", target_arch = "aarch64", feature = "cli"), clap( @@ -211,6 +220,12 @@ impl CommonSettings { nix_build_user_id_base = 3000; }, #[cfg(target_os = "linux")] + (Architecture::X86_32(_), OperatingSystem::Linux) => { + url = NIX_I686_LINUX_URL; + nix_build_user_prefix = "nixbld"; + nix_build_user_id_base = 3000; + }, + #[cfg(target_os = "linux")] (Architecture::Aarch64(_), OperatingSystem::Linux) => { url = NIX_AARCH64_LINUX_URL; nix_build_user_prefix = "nixbld"; @@ -449,6 +464,10 @@ impl InitSettings { (init, start_daemon) = linux_detect_init().await; }, #[cfg(target_os = "linux")] + (Architecture::X86_32(_), OperatingSystem::Linux) => { + (init, start_daemon) = linux_detect_init().await; + }, + #[cfg(target_os = "linux")] (Architecture::Aarch64(_), OperatingSystem::Linux) => { (init, start_daemon) = linux_detect_init().await; },