From 42e59d81053735c288c56ac477fe9ff1a2dea2a5 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 6 Jan 2020 15:22:39 -0500 Subject: [PATCH] Adds (incomplete) system image build This includes the proper kernel, but does nothing more. --- build.sh | 13 +++++++++++++ configuration.nix | 19 +++++++++++++++++++ cross-hacks.nix | 26 ++++++++++++++++++++++++++ system.nix | 7 +++++++ with-cross.nix | 11 +++++++++++ 5 files changed, 76 insertions(+) create mode 100755 build.sh create mode 100644 configuration.nix create mode 100644 cross-hacks.nix create mode 100644 system.nix create mode 100644 with-cross.nix diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4b19c01 --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +set -u +PS4=" $ " + +# Ugh, I would have liked to do it through a simpler `nix-build`, but as this +# needs to set `NIX_PATH` for use of `` imports, this is the better +# way to go. + +set -x +exec env -i NIX_PATH="nixpkgs=channel:nixos-19.09" nix-build \ + system.nix -A config.system.build.sdImage "$@" diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..c746eee --- /dev/null +++ b/configuration.nix @@ -0,0 +1,19 @@ +{ config, pkgs, lib, ... }: +{ + imports = [ + + + + + ]; + + nixpkgs.crossSystem = { + system = "aarch64-linux"; + }; + + nixpkgs.overlays = [ + (import ./overlay.nix) + ]; + + boot.kernelPackages = pkgs.linuxPackages-pinebookpro; +} diff --git a/cross-hacks.nix b/cross-hacks.nix new file mode 100644 index 0000000..77fb3ad --- /dev/null +++ b/cross-hacks.nix @@ -0,0 +1,26 @@ +# From this upstream repo: +# https://github.com/samueldr/cross-system +{ config, pkgs, lib, ... }: +{ + + nixpkgs.overlays = [ + (self: super: { + # Does not cross-compile... + alsa-firmware = pkgs.runCommandNoCC "neutered-firmware" {} "mkdir -p $out"; + }) + ]; + + # (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; +} diff --git a/system.nix b/system.nix new file mode 100644 index 0000000..975a7b2 --- /dev/null +++ b/system.nix @@ -0,0 +1,7 @@ +import { + configuration = + if builtins.currentSystem == "aarch64-linux" + then builtins.toPath (./. + "/configuration.nix") + else builtins.toPath (./. + "/with-cross.nix") + ; +} diff --git a/with-cross.nix b/with-cross.nix new file mode 100644 index 0000000..d0e44a3 --- /dev/null +++ b/with-cross.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, ... }: +{ + imports = [ + ./cross-hacks.nix + ./configuration.nix + ]; + + nixpkgs.crossSystem = { + system = "aarch64-linux"; + }; +}