Adds (incomplete) system image build

This includes the proper kernel, but does nothing more.
This commit is contained in:
Samuel Dionne-Riel 2020-01-06 15:22:39 -05:00
parent 0658481977
commit 42e59d8105
5 changed files with 76 additions and 0 deletions

13
build.sh Executable file
View File

@ -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 `<nixpkgs/*>` 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 "$@"

19
configuration.nix Normal file
View File

@ -0,0 +1,19 @@
{ config, pkgs, lib, ... }:
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>
<nixpkgs/nixos/modules/profiles/minimal.nix>
<nixpkgs/nixos/modules/profiles/installation-device.nix>
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix>
];
nixpkgs.crossSystem = {
system = "aarch64-linux";
};
nixpkgs.overlays = [
(import ./overlay.nix)
];
boot.kernelPackages = pkgs.linuxPackages-pinebookpro;
}

26
cross-hacks.nix Normal file
View File

@ -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;
}

7
system.nix Normal file
View File

@ -0,0 +1,7 @@
import <nixpkgs/nixos> {
configuration =
if builtins.currentSystem == "aarch64-linux"
then builtins.toPath (./. + "/configuration.nix")
else builtins.toPath (./. + "/with-cross.nix")
;
}

11
with-cross.nix Normal file
View File

@ -0,0 +1,11 @@
{ config, pkgs, lib, ... }:
{
imports = [
./cross-hacks.nix
./configuration.nix
];
nixpkgs.crossSystem = {
system = "aarch64-linux";
};
}