diff --git a/nix/README.md b/nix/README.md new file mode 100644 index 0000000..b5fb590 --- /dev/null +++ b/nix/README.md @@ -0,0 +1,23 @@ +# Nix-compiled binaries for xrsh.iso + +Crosscompiling used to be tricky, due to dependencies. +With Nix this belongs to the past. + +# building hello.c + +```bash +$ nix-shell --run '$CC hello.c -o hello' hello.nix +$ file hello +hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped +``` + +# building a nixos pkg + +```bash +$ nix-build '<nixpkgs>' --pure -I nixpkgs=channel:nixos-24.05 -A pkgsCross.$ARCH.pkgsStatic.hello +$ file hello +hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped +``` + +use the build-shellscripts in this directory as a startingpoint for your xrsh binaries. + diff --git a/nix/build_hello.sh b/nix/build_hello_c.sh similarity index 100% rename from nix/build_hello.sh rename to nix/build_hello_c.sh diff --git a/nix/chibicc.nix b/nix/chibicc.nix deleted file mode 100644 index dc0c5fe..0000000 --- a/nix/chibicc.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ pkgs ? import <nixpkgs> {} }: - -pkgs.mkShell { - buildInputs = [ - pkgs.pkg-config - pkgs.gnumake # For running make - pkgs.gcc_multi # GCC with multi-lib support (32-bit and 64-bit) - pkgs.glibc_multi - pkgs.gccMultiStdenv - pkgs.binutils - ]; - - # Set up environment variables for cross-compilation to 32-bit - shellHook = '' - export CC="gcc -m32 -static" - export CXX="g++ -m32 -static" - export LD="ld -m elf_i386" - echo "32-bit cross-compilation environment with static linking is set up." - git clone https://github.com/rui314/chibicc - cd chibicc - make - ''; -} diff --git a/nix/configuration.nix b/nix/configuration.nix deleted file mode 100644 index c57b5ff..0000000 --- a/nix/configuration.nix +++ /dev/null @@ -1,43 +0,0 @@ -# /etc/nixos/configuration.nix -{ config, pkgs, ... }: - -{ - # Set the hostname of the system - networking.hostName = "nixos-minimal"; - - # Enable the OpenSSH service (optional, useful for remote access) - services.openssh.enable = false; - - # Timezone configuration - time.timeZone = "UTC"; - - # Set the default shell to bash - users.defaultUserShell = pkgs.bash; - - # Create a minimal user (replace "your-user" with desired username) - users.users.yourUser = { - isNormalUser = true; - shell = pkgs.bash; - initialPassword = "password"; # Replace with a hashed password for production - }; - - # Boot loader (for booting the system) - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.devices = [ "/dev/sda" ]; # Replace with your actual boot device - - # Allow unfree packages (if needed) - nixpkgs.config.allowUnfree = true; - - # Enable virtual console - console.useXkbConfig = true; - - # Enable bash as a package (part of the basic system environment) - environment.systemPackages = with pkgs; [ - bash - ]; - - # Disable the display manager (minimal CLI system, no graphical interface) - services.xserver.enable = false; -} - diff --git a/nix/cross.nix b/nix/cross.nix deleted file mode 100644 index 46cf107..0000000 --- a/nix/cross.nix +++ /dev/null @@ -1,12 +0,0 @@ -let - nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/release-24.05"; - pkgs = (import nixpkgs {}).pkgsCross.i686-embedded; -in - -# callPackage is needed due to https://github.com/NixOS/nixpkgs/pull/126844 -pkgs.pkgsStatic.callPackage ({ mkShell, zlib, pkg-config, file }: mkShell { - # these tools run on the build platform, but are configured to target the host platform - nativeBuildInputs = [ pkg-config file ]; - # libraries needed for the host platform - buildInputs = [ zlib ]; -}) {} diff --git a/nix/howto.txt b/nix/howto.txt deleted file mode 100644 index 03cce29..0000000 --- a/nix/howto.txt +++ /dev/null @@ -1,3 +0,0 @@ -nix-shell --run gcc -m32 -static hello.c -o hello cross.nix -nix-shell --run 'gcc -m32 -static hello.c -o hello' cross.nix -nix-build '<nixpkgs>' -I nixpkgs=channel:nixos-24.05 -A pkgsCross.i686-embedded.hello --show-trace