diff options
Diffstat (limited to 'nix/rootfs-bootstrap-cross')
-rw-r--r-- | nix/rootfs-bootstrap-cross/default.nix | 17 | ||||
-rw-r--r-- | nix/rootfs-bootstrap-cross/ext4-image.nix | 81 | ||||
-rw-r--r-- | nix/rootfs-bootstrap-cross/installer-configuration.nix | 89 | ||||
-rw-r--r-- | nix/rootfs-bootstrap-cross/sample-configuration.nix | 107 |
4 files changed, 0 insertions, 294 deletions
diff --git a/nix/rootfs-bootstrap-cross/default.nix b/nix/rootfs-bootstrap-cross/default.nix deleted file mode 100644 index 15e1aabe324c..000000000000 --- a/nix/rootfs-bootstrap-cross/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -# mod of https://github.com/samueldr/cross-system/blob/master/default.nix - -{ pkgs }: - -let - nixpkgsPath = pkgs.path; - fromPkgs = path: pkgs.path + "/${path}"; - evalConfig = import (fromPkgs "nixos/lib/eval-config.nix"); -in (evalConfig { - specialArgs = { - inherit nixpkgsPath; - }; - modules = [ - ./installer-configuration.nix - ./ext4-image.nix - ]; -}).config.system.build.ext4Image diff --git a/nix/rootfs-bootstrap-cross/ext4-image.nix b/nix/rootfs-bootstrap-cross/ext4-image.nix deleted file mode 100644 index 9e322a8e8b52..000000000000 --- a/nix/rootfs-bootstrap-cross/ext4-image.nix +++ /dev/null @@ -1,81 +0,0 @@ -# mod of https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image.nix - -{ config, lib, pkgs, ... }: - -with lib; - -let - rootfsImage = pkgs.callPackage "${pkgs.path}/nixos/lib/make-ext4-fs.nix" ({ - inherit (config.sdImage) storePaths; - compressImage = false; - populateImageCommands = config.sdImage.populateRootCommands; - volumeLabel = "NIXOS_SD"; - } // optionalAttrs (config.sdImage.rootPartitionUUID != null) { - uuid = config.sdImage.rootPartitionUUID; - }); - - # we use tar and gzip to compress the image instead of the default zstd so - # that it can be transferred and decompressed in recoveryOS (which doesn't - # even have bare gzip, only tar!!!) - compressedImage = if !config.sdImage.compressImage then rootfsImage else ( - pkgs.callPackage ({ pigz }: rootfsImage.overrideAttrs (o: { - name = o.name + ".tar.gz"; - nativeBuildInputs = o.nativeBuildInputs ++ [ pigz ]; - buildCommand = '' - imgout=$out - out=nixos_root.img - '' + o.buildCommand + '' - out=$imgout - echo "Compressing image" - tar c nixos_root.img | pigz -p $NIX_BUILD_CORES -c > $out - ''; - }) - )) {}; -in -{ - config = { - system.build.ext4Image = let - ext4Name = replaceStrings ["sd"] ["ext4"] config.sdImage.imageName; - in pkgs.callPackage ({ stdenv }: stdenv.mkDerivation { - name = ext4Name; - - inherit (config.sdImage) compressImage; - - buildCommand = '' - mkdir -p $out/nix-support $out/ext4-image - export img=$out/ext4-image/nixos_root.img - if test -n "$compressImage"; then - export img=$img.tar.gz - fi - - echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system - echo "file ext4-image $img" >> $out/nix-support/hydra-build-products - - ln -s ${compressedImage} $img - ''; - }) {}; - - sdImage.expandOnBoot = lib.mkForce false; - - boot.postBootCommands = '' - # On the first boot do some maintenance tasks - if [ -f /nix-path-registration ]; then - set -euo pipefail - set -x - # Figure out device names for the boot device and root filesystem. - rootPart=$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE /) - bootDevice=$(lsblk -npo PKNAME $rootPart) - partNum=$(lsblk -npo MAJ:MIN $rootPart | ${pkgs.gawk}/bin/awk -F: '{print $2}') - # Resize the filesystem to fit the disk - ${pkgs.e2fsprogs}/bin/resize2fs $rootPart - # Register the contents of the initial Nix store - ${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration - # nixos-rebuild also requires a "system" profile and an /etc/NIXOS tag. - touch /etc/NIXOS - ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system - # Prevents this from running on later boots. - rm -f /nix-path-registration - fi - ''; - }; -} diff --git a/nix/rootfs-bootstrap-cross/installer-configuration.nix b/nix/rootfs-bootstrap-cross/installer-configuration.nix deleted file mode 100644 index f5c2d9c57c42..000000000000 --- a/nix/rootfs-bootstrap-cross/installer-configuration.nix +++ /dev/null @@ -1,89 +0,0 @@ -# this configuration is intended to have just enough stuff to get the disk, -# display, USB input, and network up so the user can build a real config. - -# based on https://github.com/samueldr/cross-system/blob/master/configuration.nix - -{ config, pkgs, lib, nixpkgsPath, ... }: - -{ - imports = [ - (nixpkgsPath + "/nixos/modules/profiles/minimal.nix") - (nixpkgsPath + "/nixos/modules/profiles/installation-device.nix") - (nixpkgsPath + "/nixos/modules/installer/sd-card/sd-image.nix") - ]; - - sdImage.populateRootCommands = '' - mkdir -p ./files/boot - ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot - - mkdir -p ./files/etc/nixos/kernel - cp -r ${../kernel}/* ./files/etc/nixos/kernel - cp ${./sample-configuration.nix} ./files/etc/nixos/configuration.nix - chmod +w -R ./files/etc/nixos/ - ''; - - installer.cloneConfig = false; - - boot.loader.grub.enable = false; - boot.loader.generic-extlinux-compatible.enable = true; - - boot.consoleLogLevel = 7; - - boot.kernelParams = [ - "earlycon" - "console=ttySAC0,1500000" - "console=tty0" - "debug" - "boot.shell_on_fail" - ]; - - boot.kernelPackages = pkgs.callPackage ../kernel { nativeBuild = false; }; - - # our kernel config is weird and doesn't have these modules as modules - boot.initrd.availableKernelModules = lib.mkForce []; - - # save space and compilation time. might revise? - hardware.enableAllFirmware = lib.mkForce false; - hardware.enableRedistributableFirmware = lib.mkForce false; - sound.enable = false; - networking.wireless.enable = false; - documentation.nixos.enable = lib.mkOverride 49 false; - system.extraDependencies = lib.mkForce [ ]; - - hardware.wirelessRegulatoryDatabase = true; - hardware.firmware = [ - # all the firmware is big, but including the tigon one avoids an awkward - # minute long hang on mac mini - (pkgs.stdenv.mkDerivation { - name = "tigon-firmware"; - buildCommand = '' - mkdir -p $out/lib/firmware - cp -r ${pkgs.firmwareLinuxNonfree}/lib/firmware/tigon $out/lib/firmware - ''; - }) - ]; - - # (Failing build in a dep to be investigated) - security.polkit.enable = false; - - # cifs-utils fails to cross-compile - # Let's simplify this by removing all unneeded filesystems from the image. - boot.supportedFilesystems = lib.mkForce [ "vfat" ]; - - # texinfoInteractive has trouble cross-compiling - documentation.info.enable = lib.mkForce false; - - # `xterm` is being included even though this is GUI-less. - # → https://github.com/NixOS/nixpkgs/pull/62852 - services.xserver.desktopManager.xterm.enable = lib.mkForce false; - - # ec6224b6cd147943eee685ef671811b3683cb2ce re-introduced udisks in the installer - # udisks fails due to gobject-introspection being not cross-compilation friendly. - services.udisks2.enable = lib.mkForce false; - - networking.firewall.enable = false; - - nixpkgs.crossSystem = { - system = "aarch64-linux"; - }; -} diff --git a/nix/rootfs-bootstrap-cross/sample-configuration.nix b/nix/rootfs-bootstrap-cross/sample-configuration.nix deleted file mode 100644 index 99c3272f01ef..000000000000 --- a/nix/rootfs-bootstrap-cross/sample-configuration.nix +++ /dev/null @@ -1,107 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible online at -# https://nixos.org/manual/nixos/stable/index.html#sec-installation). - -{ config, pkgs, lib, ... }: - -{ - # Enables the generation of /boot/extlinux/extlinux.conf - # GRUB cannot correctly load device trees, so do not change this. - boot.loader.grub.enable = false; - boot.loader.generic-extlinux-compatible.enable = true; - - # Use the customized Asahi Linux kernel. - # If you wish to modify the kernel, see /etc/nixos/kernel/default.nix. - - # IMPORTANT: if you have to build the kernel on the Mac itself, set - # nativeBuild here to `true`. If you don't, Nix will complain that it - # cannot find an x86_64-linux builder. - boot.kernelPackages = pkgs.callPackage ./kernel { nativeBuild = false; }; - - boot.consoleLogLevel = 7; - boot.kernelParams = lib.mkForce [ - "earlycon" - "console=ttySAC0,1500000" - "console=tty0" - "debug" - "boot.shell_on_fail" - ]; - - # networking.hostName = "nixos"; # Define your hostname. - - # Set your time zone. - # time.timeZone = "Europe/Amsterdam"; - - # Change this to the name of your interface, available via `ip addr`. - # `enp3s0` is the internal interface on the Mac mini. - networking.interfaces.enp3s0.useDHCP = true; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # }; - - # Enable the X11 windowing system and at least one desktop manager. - # services.xserver.enable = true; - # services.xserver.desktopManager.xfce.enable = true; - - # Configure keymap in X11 - # services.xserver.layout = "us"; - # services.xserver.xkbOptions = "eurosign:e"; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - # firefox - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # nftables support is not yet in the kernel config, so enabling the firewall - # does not work yet - networking.firewall.enable = false; - - # our kernel config is weird so don't try to include any modules - boot.initrd.availableKernelModules = lib.mkForce [ ]; - - # do not change these, they match the built root FS and partition layout - fileSystems."/" = - { device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; - fsType = "ext4"; - }; - swapDevices = [ ]; - - hardware.firmware = [ pkgs.firmwareLinuxNonfree ]; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "22.05"; # Did you read the comment? - -} |