Skip to content

Commit

Permalink
add a flake file for the rpi, currently configured for native buildin…
Browse files Browse the repository at this point in the history
…g only
  • Loading branch information
cleverca22 committed Oct 20, 2023
1 parent b389114 commit c3a5cd0
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 8 deletions.
16 changes: 16 additions & 0 deletions base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ with lib;
The set of NTP servers from which to synchronise.
'';
};
system.systemBuilderArgs = mkOption {
type = types.attrsOf types.unspecified;
internal = true;
default = {};
description = lib.mdDoc ''
`lib.mkDerivation` attributes that will be passed to the top level system builder.
'';
};
system.systemBuilderCommands = mkOption {
type = types.lines;
internal = true;
default = "";
description = ''
This code will be added to the builder creating the system store path.
'';
};
};
config = {
environment.systemPackages = lib.optional config.not-os.nix pkgs.nix;
Expand Down
22 changes: 18 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
{ configuration ? import ./configuration.nix, nixpkgs ? <nixpkgs>, extraModules ? [], system ? builtins.currentSystem, platform ? null }:
{ configuration ? import ./configuration.nix
, nixpkgs ? <nixpkgs>
, extraModules ? []
, system ? builtins.currentSystem
, platform ? null
, crossSystem ? null }:

let
pkgs = import nixpkgs { inherit system; platform = platform; config = {}; };
pkgsModule = rec {
pkgsModule = {config, ... }: {
_file = ./default.nix;
key = _file;
key = ./default.nix;
config = {
nixpkgs.localSystem = { inherit system; };
nixpkgs.pkgs = (import nixpkgs {
inherit system;
#crossSystem = (import <nixpkgs/lib>).systems.examples.aarch64-multiplatform;
config = config.nixpkgs.config;
});
nixpkgs.localSystem = {
inherit system;
} // pkgs.lib.optionalAttrs (crossSystem != null) {
inherit crossSystem;
};
};
};
baseModules = [
Expand Down
42 changes: 42 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
inputs = {
firmware = {
url = "github:raspberrypi/firmware";
flake = false;
};
};
outputs = { self, nixpkgs, firmware }: {
packages.armv7l-linux = let
platforms = (import nixpkgs { config = {}; }).platforms;
in {
rpi_image = (import ./default.nix {
extraModules = [
./rpi_image.nix
{ system.build.rpi_firmware = firmware; }
];
platform = system: platforms.raspberrypi2;
system = "armv7l-linux";
inherit nixpkgs;
}).config.system.build.rpi_image;
};
};
}
9 changes: 5 additions & 4 deletions rpi_image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
cmdline = pkgs.writeText "cmdline.txt" ''
console=ttyS0,115200 pi3-disable-bt kgdboc=ttyS0,115200 systemConfig=${builtins.unsafeDiscardStringContext config.system.build.toplevel} netroot=192.168.2.1=9080d9b6/root.squashfs quiet splash plymouth.ignore-serial-consoles plymouth.ignore-udev
'';
firm = config.system.build.rpi_firmware;
in pkgs.runCommand "rpi_image" {} ''
mkdir $out
cd $out
cp ${config_txt} config.txt
cp ${cmdline} cmdline.txt
cp -s ${config.system.build.kernel}/*zImage kernel7.img
cp -s ${config.system.build.squashfs} root.squashfs
cp ${./../bcm2710-rpi-3-b.dtb} bcm2710-rpi-3-b.dtb
cp -r ${./../../overlays} overlays
cp -s ${../../start.elf} start.elf
cp ${../../fixup.dat} fixup.dat
cp ${firm}/boot/bcm2710-rpi-3-b.dtb bcm2710-rpi-3-b.dtb
cp -r ${firm}/boot/overlays overlays
cp -s ${firm}/boot/start.elf start.elf
cp ${firm}/boot/fixup.dat fixup.dat
cp -s ${config.system.build.initialRamdisk}/initrd initrd
ls -ltrhL
'';
Expand Down

0 comments on commit c3a5cd0

Please sign in to comment.