mirror of
https://github.com/samueldr/wip-pinebook-pro.git
synced 2025-01-24 17:55:01 +01:00
Use flakes
This should let users build an SD image simply with `nix build` run from the root of the repo, or even `nix build github:samudeldr/wip-pinebook-pro'.
This commit is contained in:
parent
3746c617f8
commit
a217594cf3
9 changed files with 111 additions and 51 deletions
|
@ -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.
|
||||
|
||||
|
|
16
build.sh
16
build.sh
|
@ -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 "$@"
|
|
@ -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
|
||||
];
|
||||
|
|
20
default.nix
20
default.nix
|
@ -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
generated
Normal file
43
flake.lock
generated
Normal 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": 1597943282,
|
||||
"narHash": "sha256-G/VQBlqO7YeFOSvn29RqdvABZxmQBtiRYVA6kjqWZ6o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs-channels",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
55
flake.nix
Normal file
55
flake.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
description = "WIP stuff to get started on the pinebook pro.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs-channels/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
{
|
||||
overlay = final: prev: import "${self}/overlay.nix" final prev;
|
||||
} // flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
darwin_network_cmds_openssl_overlay = final: prev: {
|
||||
darwin = prev.darwin // {
|
||||
network_cmds = prev.darwin.network_cmds.override { openssl_1_0_2 = prev.openssl; };
|
||||
};
|
||||
};
|
||||
pkgsNative = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [ darwin_network_cmds_openssl_overlay 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 = nixpkgs.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; }
|
||||
(if system == "aarch64-linux" then "${self}/configuration.nix" else "${self}/with-cross.nix")
|
||||
];
|
||||
};
|
||||
|
||||
nixosModule = import "${self}/pinebook_pro.nix";
|
||||
}
|
||||
);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import <nixpkgs/nixos> {
|
||||
configuration =
|
||||
if builtins.currentSystem == "aarch64-linux"
|
||||
then builtins.toPath (./. + "/configuration.nix")
|
||||
else builtins.toPath (./. + "/with-cross.nix")
|
||||
;
|
||||
}
|
Loading…
Add table
Reference in a new issue