add per-device overlay
presently this is used to reference the appropriate kernel and (if needed) openwrt source trees, but I would not be surprised if we find other uses
This commit is contained in:
parent
fa31d00d6a
commit
77922c875b
9 changed files with 56 additions and 27 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
overlay = import ./overlay.nix;
|
overlay = import ./overlay.nix;
|
||||||
nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; });
|
nixpkgs = import <nixpkgs> (device.system // {overlays = [overlay device.overlay]; });
|
||||||
inherit (nixpkgs.pkgs) callPackage writeText liminix;
|
inherit (nixpkgs.pkgs) callPackage writeText liminix;
|
||||||
inherit (nixpkgs.lib) concatStringsSep;
|
inherit (nixpkgs.lib) concatStringsSep;
|
||||||
config = (import ./merge-modules.nix) [
|
config = (import ./merge-modules.nix) [
|
||||||
|
@ -56,16 +56,18 @@ let
|
||||||
bootm 0x${toHexString uimageStart}
|
bootm 0x${toHexString uimageStart}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
directory = nixpkgs.pkgs.runCommand "liminix" {} ''
|
directory = nixpkgs.pkgs.runCommand "liminix" {} (''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd $out
|
cd $out
|
||||||
ln -s ${squashfs} squashfs
|
ln -s ${squashfs} squashfs
|
||||||
ln -s ${kernel.vmlinux} vmlinux
|
ln -s ${kernel.vmlinux} vmlinux
|
||||||
ln -s ${manifest} manifest
|
ln -s ${manifest} manifest
|
||||||
|
'' +
|
||||||
|
(if device ? boot then ''
|
||||||
ln -s ${uimage} uimage
|
ln -s ${uimage} uimage
|
||||||
${if phram then "ln -s ${boot-scr} boot.scr" else ""}
|
${if phram then "ln -s ${boot-scr} boot.scr" else ""}
|
||||||
ln -s ${boot-scr} flash.scr
|
ln -s ${boot-scr} flash.scr
|
||||||
'';
|
'' else ""));
|
||||||
# this exists so that you can run "nix-store -q --tree" on it and find
|
# this exists so that you can run "nix-store -q --tree" on it and find
|
||||||
# out what's in the image, which is nice if it's unexpectedly huge
|
# out what's in the image, which is nice if it's unexpectedly huge
|
||||||
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
|
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
|
||||||
|
|
|
@ -20,6 +20,34 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# We need to be able to import default.nix before we import nixpkgs
|
||||||
|
# because it has the system config to tell nixpkgs what arch to build for.
|
||||||
|
# But we also need some way to do things like fetchFromGitHub in the
|
||||||
|
# per-device config and we can only do that once we have a reference to
|
||||||
|
# pkgs
|
||||||
|
|
||||||
|
overlay = final: prev:
|
||||||
|
let inherit (final) fetchFromGitHub;
|
||||||
|
in {
|
||||||
|
sources = {
|
||||||
|
openwrt = fetchFromGitHub {
|
||||||
|
name = "openwrt-source";
|
||||||
|
repo = "openwrt";
|
||||||
|
owner = "openwrt";
|
||||||
|
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
|
||||||
|
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
||||||
|
};
|
||||||
|
kernel = fetchFromGitHub {
|
||||||
|
name = "kernel-source";
|
||||||
|
owner = "torvalds";
|
||||||
|
repo = "linux";
|
||||||
|
rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19
|
||||||
|
hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
kernel = rec {
|
kernel = rec {
|
||||||
checkedConfig = {
|
checkedConfig = {
|
||||||
"MIPS_ELF_APPENDED_DTB" = "y";
|
"MIPS_ELF_APPENDED_DTB" = "y";
|
||||||
|
@ -42,7 +70,6 @@
|
||||||
CONSOLE_LOGLEVEL_DEFAULT = "8";
|
CONSOLE_LOGLEVEL_DEFAULT = "8";
|
||||||
CONSOLE_LOGLEVEL_QUIET = "4";
|
CONSOLE_LOGLEVEL_QUIET = "4";
|
||||||
|
|
||||||
|
|
||||||
# "empty" initramfs source should create an initial
|
# "empty" initramfs source should create an initial
|
||||||
# filesystem that has a /dev/console node and not much
|
# filesystem that has a /dev/console node and not much
|
||||||
# else. Note that pid 1 is started *before* the root
|
# else. Note that pid 1 is started *before* the root
|
|
@ -12,6 +12,21 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
overlay = final: prev:
|
||||||
|
let inherit (final) fetchFromGitHub;
|
||||||
|
in {
|
||||||
|
sources = {
|
||||||
|
kernel = fetchFromGitHub {
|
||||||
|
name = "kernel-source";
|
||||||
|
owner = "torvalds";
|
||||||
|
repo = "linux";
|
||||||
|
rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19
|
||||||
|
hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
kernel = {
|
kernel = {
|
||||||
config = {
|
config = {
|
||||||
SYSVIPC= "y";
|
SYSVIPC= "y";
|
|
@ -6,15 +6,9 @@
|
||||||
|
|
||||||
, config
|
, config
|
||||||
, checkedConfig
|
, checkedConfig
|
||||||
|
, sources
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
source = fetchFromGitHub {
|
|
||||||
owner = "torvalds";
|
|
||||||
repo = "linux";
|
|
||||||
rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19
|
|
||||||
hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4=";
|
|
||||||
};
|
|
||||||
|
|
||||||
# The kernel is huge and takes a long time just to
|
# The kernel is huge and takes a long time just to
|
||||||
# download and unpack. This derivation creates
|
# download and unpack. This derivation creates
|
||||||
# a source tree in a suitable shape to build from -
|
# a source tree in a suitable shape to build from -
|
||||||
|
@ -24,7 +18,7 @@ let
|
||||||
|
|
||||||
tree = stdenvNoCC.mkDerivation {
|
tree = stdenvNoCC.mkDerivation {
|
||||||
name = "spindled-kernel-tree";
|
name = "spindled-kernel-tree";
|
||||||
src = source;
|
src = sources.kernel;
|
||||||
phases = [ "unpackPhase" "patchPhase" "patchScripts" "installPhase" ];
|
phases = [ "unpackPhase" "patchPhase" "patchScripts" "installPhase" ];
|
||||||
patches = [ ./random.patch ];
|
patches = [ ./random.patch ];
|
||||||
patchScripts = ''
|
patchScripts = ''
|
||||||
|
@ -36,15 +30,6 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
openwrtSource = fetchFromGitHub {
|
|
||||||
name = "openwrt-source-tree";
|
|
||||||
repo = "openwrt";
|
|
||||||
owner = "openwrt";
|
|
||||||
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
|
|
||||||
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
vmlinux = callPackage ./vmlinux.nix {
|
vmlinux = callPackage ./vmlinux.nix {
|
||||||
inherit tree config checkedConfig;
|
inherit tree config checkedConfig;
|
||||||
|
@ -53,7 +38,7 @@ in rec {
|
||||||
uimage = callPackage ./uimage.nix { };
|
uimage = callPackage ./uimage.nix { };
|
||||||
|
|
||||||
dtb = callPackage ./dtb.nix {
|
dtb = callPackage ./dtb.nix {
|
||||||
openwrt = openwrtSource;
|
openwrt = sources.openwrt;
|
||||||
kernel = tree;
|
kernel = tree;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set -e
|
set -e
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=../smoke/configuration.nix --arg device "import <liminix/devices/$DEVICE.nix>" -A outputs.kernel.vmlinux -o vmlinux $*
|
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=../smoke/configuration.nix --arg device "import <liminix/devices/$DEVICE>" -A outputs.kernel.vmlinux -o vmlinux $*
|
||||||
|
|
||||||
TESTS=$(cat <<"EOF"
|
TESTS=$(cat <<"EOF"
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
set -e
|
set -e
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build --arg device "import <liminix/devices/qemu.nix>" test.nix
|
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build --arg device "import <liminix/devices/qemu>" test.nix
|
||||||
|
|
|
@ -14,7 +14,7 @@ fatal(){
|
||||||
}
|
}
|
||||||
trap fatal ERR
|
trap fatal ERR
|
||||||
|
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $*
|
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu>" -A outputs.default $*
|
||||||
|
|
||||||
if ! ( echo "cont" | socat - unix-connect:../support/ppp-server/qemu-monitor); then
|
if ! ( echo "cont" | socat - unix-connect:../support/ppp-server/qemu-monitor); then
|
||||||
echo "need pppoe server running"
|
echo "need pppoe server running"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set -e
|
set -e
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/$DEVICE.nix>" -A outputs.squashfs -o smoke.img $*
|
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/$DEVICE>" -A outputs.squashfs -o smoke.img $*
|
||||||
|
|
||||||
TESTS=$(cat <<"EOF"
|
TESTS=$(cat <<"EOF"
|
||||||
test -n "${TMPDIR}"
|
test -n "${TMPDIR}"
|
||||||
|
|
|
@ -14,7 +14,7 @@ fatal(){
|
||||||
}
|
}
|
||||||
trap fatal ERR
|
trap fatal ERR
|
||||||
|
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $*
|
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu>" -A outputs.default $*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue