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
This commit is contained in:
Ana Hobden 2023-02-06 07:50:23 -08:00 committed by GitHub
parent 8dcd991c57
commit 2c91bea9eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 1 deletions

View file

@ -25,6 +25,14 @@ steps:
- nix --extra-experimental-features "nix-command flakes" build .#packages.x86_64-linux.nix-installer-static -L - 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 - cp result/bin/nix-installer ./nix-installer-x86_64-linux
- buildkite-agent artifact upload 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 - label: nix-installer-aarch64-linux
agents: agents:
system: aarch64-linux system: aarch64-linux

View file

@ -30,7 +30,7 @@
, ... , ...
} @ inputs: } @ inputs:
let 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)); forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: (forSystem system f));
@ -49,6 +49,8 @@
stable.rust-src stable.rust-src
] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [ ] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std 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") [ ] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std targets.aarch64-unknown-linux-musl.stable.rust-std
]); ]);
@ -99,6 +101,12 @@
(sharedAttrs // { (sharedAttrs // {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; 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 { } // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "aarch64-linux") rec {
default = nix-installer-static; default = nix-installer-static;
nix-installer-static = naerskLib.buildPackage nix-installer-static = naerskLib.buildPackage
@ -170,6 +178,9 @@
} // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") { } // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
inherit (pkgs) nix-installer-static; inherit (pkgs) nix-installer-static;
default = 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") { } // nixpkgs.lib.optionalAttrs (system == "aarch64-linux") {
inherit (pkgs) nix-installer-static; inherit (pkgs) nix-installer-static;
default = pkgs.nix-installer-static; default = pkgs.nix-installer-static;

View file

@ -192,6 +192,11 @@ get_architecture() {
x86_64 | x86-64 | x64 | amd64) x86_64 | x86-64 | x64 | amd64)
_cputype=x86_64 _cputype=x86_64
;; ;;
i686)
_cputype=i686
;;
*) *)
err "unknown CPU type: $_cputype" err "unknown CPU type: $_cputype"
;; ;;

View file

@ -135,6 +135,10 @@ impl BuiltinPlanner {
Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?))
}, },
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
(Architecture::X86_32(_), OperatingSystem::Linux) => {
Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?))
},
#[cfg(target_os = "linux")]
(Architecture::Aarch64(_), OperatingSystem::Linux) => { (Architecture::Aarch64(_), OperatingSystem::Linux) => {
Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?))
}, },

View file

@ -11,6 +11,9 @@ use crate::channel_value::ChannelValue;
/// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux x86_64 /// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux x86_64
pub const NIX_X64_64_LINUX_URL: &str = 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"; "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 /// Default [`nix_package_url`](CommonSettings::nix_package_url) for Linux aarch64
pub const NIX_AARCH64_LINUX_URL: &str = pub const NIX_AARCH64_LINUX_URL: &str =
"https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-aarch64-linux.tar.xz"; "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, 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( #[cfg_attr(
all(target_os = "linux", target_arch = "aarch64", feature = "cli"), all(target_os = "linux", target_arch = "aarch64", feature = "cli"),
clap( clap(
@ -211,6 +220,12 @@ impl CommonSettings {
nix_build_user_id_base = 3000; nix_build_user_id_base = 3000;
}, },
#[cfg(target_os = "linux")] #[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) => { (Architecture::Aarch64(_), OperatingSystem::Linux) => {
url = NIX_AARCH64_LINUX_URL; url = NIX_AARCH64_LINUX_URL;
nix_build_user_prefix = "nixbld"; nix_build_user_prefix = "nixbld";
@ -449,6 +464,10 @@ impl InitSettings {
(init, start_daemon) = linux_detect_init().await; (init, start_daemon) = linux_detect_init().await;
}, },
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
(Architecture::X86_32(_), OperatingSystem::Linux) => {
(init, start_daemon) = linux_detect_init().await;
},
#[cfg(target_os = "linux")]
(Architecture::Aarch64(_), OperatingSystem::Linux) => { (Architecture::Aarch64(_), OperatingSystem::Linux) => {
(init, start_daemon) = linux_detect_init().await; (init, start_daemon) = linux_detect_init().await;
}, },