convert devices from overlay to module
this makes it possible for devices to stash things in `config` (e.g. pathname to DTS) that can later be overwritten (even by the end user)
This commit is contained in:
parent
6be459b9ac
commit
8cead61740
8 changed files with 263 additions and 278 deletions
12
default.nix
12
default.nix
|
@ -8,14 +8,14 @@
|
||||||
let
|
let
|
||||||
overlay = import ./overlay.nix;
|
overlay = import ./overlay.nix;
|
||||||
pkgs = import nixpkgs (device.system // {
|
pkgs = import nixpkgs (device.system // {
|
||||||
overlays = [overlay device.overlay];
|
overlays = [overlay];
|
||||||
config = {allowUnsupportedSystem = true; };
|
config = {allowUnsupportedSystem = true; };
|
||||||
});
|
});
|
||||||
inherit (pkgs) callPackage writeText liminix fetchFromGitHub;
|
inherit (pkgs) callPackage writeText liminix fetchFromGitHub;
|
||||||
inherit (pkgs.lib) concatStringsSep;
|
inherit (pkgs.lib) concatStringsSep;
|
||||||
config = (import ./merge-modules.nix) [
|
config = (import ./merge-modules.nix) [
|
||||||
./modules/base.nix
|
./modules/base.nix
|
||||||
({ lib, ... } : { config = { inherit (device) kernel; }; })
|
device.module
|
||||||
liminix-config
|
liminix-config
|
||||||
./modules/s6
|
./modules/s6
|
||||||
./modules/users.nix
|
./modules/users.nix
|
||||||
|
@ -33,11 +33,11 @@ let
|
||||||
|
|
||||||
outputs = rec {
|
outputs = rec {
|
||||||
inherit squashfs;
|
inherit squashfs;
|
||||||
kernel = pkgs.kernel.override {
|
kernel = liminix.builders.kernel.override {
|
||||||
inherit (config.kernel) config;
|
inherit (config.kernel) config src extraPatchPhase;
|
||||||
};
|
};
|
||||||
dtb = (callPackage ./kernel/dtb.nix {}) {
|
dtb = (callPackage ./kernel/dtb.nix {}) {
|
||||||
dts = config.kernel.dts { inherit openwrt; };
|
dts = config.kernel.dts;
|
||||||
includes = [
|
includes = [
|
||||||
"${openwrt}/target/linux/ath79/dts"
|
"${openwrt}/target/linux/ath79/dts"
|
||||||
"${kernel.headers}/include"
|
"${kernel.headers}/include"
|
||||||
|
@ -91,7 +91,7 @@ let
|
||||||
tftpd = pkgs.buildPackages.tufted;
|
tftpd = pkgs.buildPackages.tufted;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
outputs = outputs // { default = outputs.${device.outputs.default}; };
|
outputs = outputs // { default = outputs.${config.device.defaultOutput}; };
|
||||||
|
|
||||||
# this is just here as a convenience, so that we can get a
|
# this is just here as a convenience, so that we can get a
|
||||||
# cross-compiling nix-shell for any package we're customizing
|
# cross-compiling nix-shell for any package we're customizing
|
||||||
|
|
|
@ -24,15 +24,9 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# We need to be able to import default.nix before we import nixpkgs
|
module = {pkgs, ... }:
|
||||||
# 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
|
let
|
||||||
openwrt = final.fetchFromGitHub {
|
openwrt = pkgs.pkgsBuildBuild.fetchFromGitHub {
|
||||||
name = "openwrt-source";
|
name = "openwrt-source";
|
||||||
repo = "openwrt";
|
repo = "openwrt";
|
||||||
owner = "openwrt";
|
owner = "openwrt";
|
||||||
|
@ -40,8 +34,14 @@
|
||||||
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
kernel = prev.kernel.override {
|
device.defaultOutput = "directory";
|
||||||
src = final.fetchurl {
|
device.boot = {
|
||||||
|
loadAddress = "0x80060000";
|
||||||
|
entryPoint = "0x80060000";
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel = {
|
||||||
|
src = pkgs.pkgsBuildBuild.fetchurl {
|
||||||
name = "linux.tar.gz";
|
name = "linux.tar.gz";
|
||||||
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
||||||
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
||||||
|
@ -59,10 +59,7 @@
|
||||||
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
||||||
patches ${openwrt}/target/linux/ath79/patches-5.15/*.patch
|
patches ${openwrt}/target/linux/ath79/patches-5.15/*.patch
|
||||||
'';
|
'';
|
||||||
};
|
dts = "${openwrt}/target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts";
|
||||||
};
|
|
||||||
kernel = rec {
|
|
||||||
dts = { openwrt,... }:"${openwrt}/target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts";
|
|
||||||
config = {
|
config = {
|
||||||
MIPS_ELF_APPENDED_DTB = "y";
|
MIPS_ELF_APPENDED_DTB = "y";
|
||||||
OF = "y";
|
OF = "y";
|
||||||
|
@ -122,9 +119,5 @@
|
||||||
"SQUASHFS_XZ" = "y";
|
"SQUASHFS_XZ" = "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs.default = "directory";
|
|
||||||
boot = {
|
|
||||||
loadAddress = "0x80060000";
|
|
||||||
entryPoint = "0x80060000";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,9 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# We need to be able to import default.nix before we import nixpkgs
|
module = { pkgs, ...}:
|
||||||
# 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
|
let
|
||||||
openwrt = final.fetchFromGitHub {
|
openwrt = pkgs.fetchFromGitHub {
|
||||||
name = "openwrt-source";
|
name = "openwrt-source";
|
||||||
repo = "openwrt";
|
repo = "openwrt";
|
||||||
owner = "openwrt";
|
owner = "openwrt";
|
||||||
|
@ -27,8 +21,16 @@
|
||||||
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
kernel = prev.kernel.override {
|
device = {
|
||||||
src = final.fetchurl {
|
defaultOutput = "directory";
|
||||||
|
boot = {
|
||||||
|
loadAddress = "0x80000000";
|
||||||
|
entryPoint = "0x80000000";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel = {
|
||||||
|
src = pkgs.fetchurl {
|
||||||
name = "linux.tar.gz";
|
name = "linux.tar.gz";
|
||||||
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
||||||
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
||||||
|
@ -46,10 +48,7 @@
|
||||||
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
||||||
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
|
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
|
||||||
'';
|
'';
|
||||||
};
|
dts = "${openwrt}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
|
||||||
};
|
|
||||||
kernel = rec {
|
|
||||||
dts = { openwrt,... } : "${openwrt}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
|
|
||||||
config = {
|
config = {
|
||||||
MIPS_ELF_APPENDED_DTB = "y";
|
MIPS_ELF_APPENDED_DTB = "y";
|
||||||
OF = "y";
|
OF = "y";
|
||||||
|
@ -106,9 +105,5 @@
|
||||||
"SQUASHFS_XZ" = "y";
|
"SQUASHFS_XZ" = "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs.default = "directory";
|
|
||||||
boot = {
|
|
||||||
loadAddress = "0x80000000";
|
|
||||||
entryPoint = "0x80000000";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,9 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# We need to be able to import default.nix before we import nixpkgs
|
module = { pkgs, ...}:
|
||||||
# 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
|
let
|
||||||
openwrt = final.fetchFromGitHub {
|
openwrt = pkgs.fetchFromGitHub {
|
||||||
name = "openwrt-source";
|
name = "openwrt-source";
|
||||||
repo = "openwrt";
|
repo = "openwrt";
|
||||||
owner = "openwrt";
|
owner = "openwrt";
|
||||||
|
@ -27,8 +21,16 @@
|
||||||
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
kernel = prev.kernel.override {
|
device = {
|
||||||
src = final.fetchurl {
|
defaultOutput = "directory";
|
||||||
|
boot = {
|
||||||
|
loadAddress = "0x80000000";
|
||||||
|
entryPoint = "0x80000000";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel = {
|
||||||
|
src = pkgs.fetchurl {
|
||||||
name = "linux.tar.gz";
|
name = "linux.tar.gz";
|
||||||
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
||||||
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
||||||
|
@ -46,10 +48,7 @@
|
||||||
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
|
||||||
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
|
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
|
||||||
'';
|
'';
|
||||||
};
|
dts = "${openwrt}/target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts";
|
||||||
};
|
|
||||||
kernel = rec {
|
|
||||||
dts = { openwrt,... } : "${openwrt}/target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts";
|
|
||||||
config = {
|
config = {
|
||||||
MIPS_ELF_APPENDED_DTB = "y";
|
MIPS_ELF_APPENDED_DTB = "y";
|
||||||
OF = "y";
|
OF = "y";
|
||||||
|
@ -117,9 +116,5 @@
|
||||||
"SQUASHFS_XZ" = "y";
|
"SQUASHFS_XZ" = "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs.default = "directory";
|
|
||||||
boot = {
|
|
||||||
loadAddress = "0x80000000";
|
|
||||||
entryPoint = "0x80000000";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,22 +13,13 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
overlay = final: prev:
|
module = {pkgs, ... }: {
|
||||||
let inherit (final) stdenvNoCC fetchFromGitHub;
|
kernel = {
|
||||||
in {
|
src = pkgs.pkgsBuildBuild.fetchurl {
|
||||||
kernel = prev.kernel.override {
|
|
||||||
# using fetchurl not fetchzip because it doesn't unpack, and
|
|
||||||
# copying 6GB of data from one store location to another
|
|
||||||
# takes an absolute bloody age
|
|
||||||
src = final.fetchurl {
|
|
||||||
name = "linux.tar.gz";
|
name = "linux.tar.gz";
|
||||||
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.19.16.tar.gz";
|
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.19.16.tar.gz";
|
||||||
hash = "sha256-m4NeoEsCEK0HSIKTZ6zYTgk1fD3W0PSOMXN6fyHpkP8=";
|
hash = "sha256-m4NeoEsCEK0HSIKTZ6zYTgk1fD3W0PSOMXN6fyHpkP8=";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
kernel = {
|
|
||||||
config = {
|
config = {
|
||||||
MIPS_MALTA= "y";
|
MIPS_MALTA= "y";
|
||||||
CPU_LITTLE_ENDIAN= "n";
|
CPU_LITTLE_ENDIAN= "n";
|
||||||
|
@ -50,5 +41,6 @@
|
||||||
SERIAL_8250_CONSOLE= "y";
|
SERIAL_8250_CONSOLE= "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs.default = "directory";
|
device.defaultOutput = "directory";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,12 @@ in {
|
||||||
};
|
};
|
||||||
filesystem = mkOption { type = types.anything; };
|
filesystem = mkOption { type = types.anything; };
|
||||||
kernel = {
|
kernel = {
|
||||||
dts = mkOption { type = types.functionTo types.string; };
|
src = mkOption { type = types.package; } ;
|
||||||
|
extraPatchPhase = mkOption {
|
||||||
|
default = "true";
|
||||||
|
type = types.lines;
|
||||||
|
} ;
|
||||||
|
dts = mkOption { type = types.string; };
|
||||||
config = mkOption {
|
config = mkOption {
|
||||||
# mostly the values are y n or m, but sometimes
|
# mostly the values are y n or m, but sometimes
|
||||||
# other strings are also used
|
# other strings are also used
|
||||||
|
@ -40,6 +45,12 @@ in {
|
||||||
users = mkOption {
|
users = mkOption {
|
||||||
type = types.attrsOf types.anything;
|
type = types.attrsOf types.anything;
|
||||||
};
|
};
|
||||||
|
device = {
|
||||||
|
defaultOutput = mkOption {
|
||||||
|
type = types.nonEmptyStr;
|
||||||
|
};
|
||||||
|
boot = mkOption { type = types.any; };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
defaultProfile.packages = with pkgs;
|
defaultProfile.packages = with pkgs;
|
||||||
|
|
|
@ -6,14 +6,13 @@ final: prev: {
|
||||||
networking = final.callPackage ./pkgs/liminix-tools/networking {};
|
networking = final.callPackage ./pkgs/liminix-tools/networking {};
|
||||||
builders = {
|
builders = {
|
||||||
squashfs = final.callPackage ./pkgs/liminix-tools/builders/squashfs.nix {};
|
squashfs = final.callPackage ./pkgs/liminix-tools/builders/squashfs.nix {};
|
||||||
|
kernel = final.callPackage ./pkgs/kernel {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
writeAshScript = final.callPackage ./pkgs/write-ash-script {};
|
writeAshScript = final.callPackage ./pkgs/write-ash-script {};
|
||||||
s6-init-bin = final.callPackage ./pkgs/s6-init-bin {};
|
s6-init-bin = final.callPackage ./pkgs/s6-init-bin {};
|
||||||
s6-rc-database = final.callPackage ./pkgs/s6-rc-database {};
|
s6-rc-database = final.callPackage ./pkgs/s6-rc-database {};
|
||||||
|
|
||||||
kernel = final.callPackage ./pkgs/kernel {};
|
|
||||||
|
|
||||||
dnsmasq =
|
dnsmasq =
|
||||||
let d = prev.dnsmasq.overrideAttrs(o: {
|
let d = prev.dnsmasq.overrideAttrs(o: {
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
, config
|
, config
|
||||||
, src
|
, src
|
||||||
, extraPatchPhase ? "true"
|
, extraPatchPhase ? "echo"
|
||||||
} :
|
} :
|
||||||
let writeConfig = name : config: writeText name
|
let writeConfig = name : config: writeText name
|
||||||
(builtins.concatStringsSep
|
(builtins.concatStringsSep
|
||||||
|
|
Loading…
Reference in a new issue