diff --git a/base.nix b/base.nix index e7f5d6d..093d1fc 100644 --- a/base.nix +++ b/base.nix @@ -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; diff --git a/default.nix b/default.nix index d5e1e2d..0812645 100644 --- a/default.nix +++ b/default.nix @@ -1,12 +1,26 @@ -{ configuration ? import ./configuration.nix, nixpkgs ? , extraModules ? [], system ? builtins.currentSystem, platform ? null }: +{ configuration ? import ./configuration.nix +, 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 ).systems.examples.aarch64-multiplatform; + config = config.nixpkgs.config; + }); + nixpkgs.localSystem = { + inherit system; + } // pkgs.lib.optionalAttrs (crossSystem != null) { + inherit crossSystem; + }; }; }; baseModules = [ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4561661 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "firmware": { + "flake": false, + "locked": { + "lastModified": 1697732010, + "narHash": "sha256-kGXbqkqHCPU2Xz6az3LtdAccVzGtlq+vnTLiR3Xl9+8=", + "owner": "raspberrypi", + "repo": "firmware", + "rev": "ce3a0b4197eaf311ba0734efdb9f5bdedefe5e27", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "repo": "firmware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697730408, + "narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ff0a5a776b56e0ca32d47a4a47695452ec7f7d80", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "firmware": "firmware", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1a9000b --- /dev/null +++ b/flake.nix @@ -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; + }; + }; +} diff --git a/rpi_image.nix b/rpi_image.nix index de8873a..ef1903e 100644 --- a/rpi_image.nix +++ b/rpi_image.nix @@ -11,6 +11,7 @@ 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 @@ -18,10 +19,10 @@ 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 '';