This commit is contained in:
Jake Waksbaum 2020-09-14 08:49:01 -05:00 committed by GitHub
commit 31dcd39df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 112 additions and 62 deletions

View File

@ -39,13 +39,10 @@ The backlight can be controlled using `light` (`programs.light.enable`).
## Image build
```
$ ./build.sh
$ nix build
$ lsblk /dev/mmcblk0 && sudo dd if=$(echo result/sd-image/*.img) of=/dev/mmcblk0 bs=8M oflag=direct status=progress
```
The `build.sh` script transmits parameters to `nix-build`, so e.g. `-j0` can
be used.
Once built, this image is self-sufficient, meaning that it should already be
booting, no need burn u-boot to it.

View File

@ -1,16 +0,0 @@
#!/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 \
NIXPKGS_ALLOW_UNFREE=1 \
NIX_PATH="nixpkgs=channel:nixos-unstable" \
"$(command -v nix-build)" \
system.nix -A config.system.build.sdImage "$@"

View File

@ -1,13 +1,13 @@
{ config, pkgs, lib, ... }:
{ nixpkgs, config, pkgs, lib, ... }:
let
uboot = pkgs.uBootPinebookProExternalFirst;
in
{
imports = [
<nixpkgs/nixos/modules/profiles/base.nix>
<nixpkgs/nixos/modules/profiles/minimal.nix>
<nixpkgs/nixos/modules/profiles/installation-device.nix>
"${nixpkgs}/nixos/modules/profiles/base.nix"
"${nixpkgs}/nixos/modules/profiles/minimal.nix"
"${nixpkgs}/nixos/modules/profiles/installation-device.nix"
./nixos/sd-image-aarch64.nix
./pinebook_pro.nix
];

View File

@ -1,17 +1,5 @@
{
pkgs ? import <nixpkgs> {
overlays = [
(import ./overlay.nix)
];
(
import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}
}:
let
pkgs' = if builtins.currentSystem == "aarch64-linux"
then pkgs
else pkgs.pkgsCross.aarch64-multiplatform
;
in
{
pkgs = pkgs';
}
).defaultNix

43
flake.lock Normal file
View File

@ -0,0 +1,43 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1597053966,
"narHash": "sha256-f9lbPS/GJ1His8fsDqM6gfa8kSqREU4eKiMCS5hrKg4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ec20f52e2ff61e9c36c2b894b62fc1b4bd04c71b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1599597582,
"narHash": "sha256-dBtZSveC7AS6ElKV1GruRN4j8QukyI27RMAuTzrZueg=",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "c411fe8ae0888994361279cf71a1bf820c4b22f4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-20.09",
"repo": "nixpkgs-channels",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

56
flake.nix Normal file
View File

@ -0,0 +1,56 @@
{
description = "WIP stuff to get started on the pinebook pro.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs-channels/nixos-20.09";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
{
overlay = final: prev: import "${self}/overlay.nix" final prev;
nixosModule = import "${self}/pinebook_pro.nix";
} // flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (
system:
let
inherit (nixpkgs) lib;
pkgsNative = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ self.overlay ];
};
pkgs = if system == "aarch64-linux" then pkgsNative else pkgsNative.pkgsCross.aarch64-multiplatform;
in
rec {
packages = rec {
inherit (pkgs)
uBootPinebookPro uBootPinebookProExternalFirst
linux_pinebookpro_latest
linux_pinebookpro_lts
pinebookpro-firmware
pinebookpro-keyboard-updater
;
inherit (nixosConfigurations.config.system.build) sdImage;
};
defaultPackage = packages.sdImage;
nixosConfigurations = lib.nixosSystem {
system = "aarch64-linux";
# Pass nixpkgs as an argument to each module so that modules from nixpkgs can be imported purely
specialArgs = { inherit nixpkgs; };
modules = [
{ nixpkgs.config.allowUnfree = true; }
"${self}/configuration.nix"
(
lib.optionalAttrs (system != "aarch64-linux") {
imports = [ "${self}/cross-hacks.nix" ];
nixpkgs.crossSystem.system = "aarch64-linux";
}
)
];
};
}
);
}

View File

@ -1,8 +1,8 @@
{ config, lib, pkgs, ... }:
{ nixpkgs, config, lib, pkgs, ... }:
let
extlinux-conf-builder =
import <nixpkgs/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix> {
import "${nixpkgs}/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix" {
pkgs = pkgs.buildPackages;
};
in

View File

@ -1,9 +1,9 @@
{ config, lib, pkgs, ... }:
{ nixpkgs, config, lib, pkgs, ... }:
with lib;
let
rootfsImage = pkgs.callPackage <nixpkgs/nixos/lib/make-ext4-fs.nix> ({
rootfsImage = pkgs.callPackage "${nixpkgs}/nixos/lib/make-ext4-fs.nix" ({
inherit (config.sdImage) storePaths;
#compressImage = false;
populateImageCommands = config.sdImage.populateRootCommands;

View File

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

View File

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