From 013e4c396c97767beed3051c51a6eb6780397b8f Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 16 Sep 2024 18:14:39 +0200 Subject: [PATCH] feat: repair CI and cleanup cross-compilation mechanism Signed-off-by: Raito Bezarius --- ci.nix | 22 ++++------------- devices/qemu/default.nix | 5 +++- devices/zyxel-nwa50ax/default.nix | 4 ++- lon.lock | 15 +++++++++++ lon.nix | 41 +++++++++++++++++++++++++++++++ modules/base.nix | 11 +++++++++ modules/outputs/tftpboot.nix | 8 ------ 7 files changed, 79 insertions(+), 27 deletions(-) create mode 100644 lon.lock create mode 100644 lon.nix diff --git a/ci.nix b/ci.nix index ec345dd..07d26f1 100644 --- a/ci.nix +++ b/ci.nix @@ -1,21 +1,15 @@ { - nixpkgs -, unstable -, liminix + sources ? import ./lon.nix +, nixpkgs ? sources.nixpkgs +, unstable ? nixpkgs +, liminix ? ./. , ... }: let - inherit (builtins) map; - pkgs = (import nixpkgs {}); + pkgs = (import nixpkgs { }); borderVmConf = ./bordervm.conf-example.nix; inherit (pkgs.lib.attrsets) genAttrs; devices = [ - "gl-ar750" - "gl-mt300a" - "gl-mt300n-v2" "qemu" - "qemu-aarch64" - "qemu-armv7l" - "tp-archer-ax23" "zyxel-nwa50ax" ]; vanilla = ./vanilla-configuration.nix; @@ -44,12 +38,6 @@ let imports = [ ./modules/all-modules.nix ]; }; }).outputs.optionsJson; - installers = map (f: "system.outputs.${f}") [ - "vmroot" - "mtdimage" - "ubimage" - ]; - inherit (pkgs.lib) concatStringsSep; in pkgs.stdenv.mkDerivation { name = "liminix-doc"; nativeBuildInputs = with pkgs; [ diff --git a/devices/qemu/default.nix b/devices/qemu/default.nix index b6e860d..fe98952 100644 --- a/devices/qemu/default.nix +++ b/devices/qemu/default.nix @@ -1,7 +1,7 @@ # This "device" generates images that can be used with the QEMU # emulator. The default output is a directory containing separate # kernel (uncompressed vmlinux) and initrd (squashfs) images -{ +rec { system = { crossSystem = { config = "mips-unknown-linux-musl"; @@ -41,6 +41,9 @@ ../../modules/arch/mipseb.nix ../families/qemu.nix ]; + + nixpkgs.hostPlatform = system.crossSystem; + kernel = { config = { MIPS_MALTA= "y"; diff --git a/devices/zyxel-nwa50ax/default.nix b/devices/zyxel-nwa50ax/default.nix index a7834dc..2b4813d 100644 --- a/devices/zyxel-nwa50ax/default.nix +++ b/devices/zyxel-nwa50ax/default.nix @@ -1,4 +1,4 @@ -{ +rec { system = { crossSystem = { config = "mipsel-unknown-linux-musl"; @@ -135,6 +135,8 @@ ../../modules/zyxel-dual-image ]; + nixpkgs.hostPlatform = system.crossSystem; + filesystem = dir { lib = dir { firmware = dir { diff --git a/lon.lock b/lon.lock new file mode 100644 index 0000000..50209e4 --- /dev/null +++ b/lon.lock @@ -0,0 +1,15 @@ +{ + "version": "1", + "sources": { + "nixpkgs": { + "type": "GitHub", + "fetchType": "tarball", + "owner": "nixos", + "repo": "nixpkgs", + "branch": "nixos-unstable-small", + "revision": "b6227cadb5123c7e4cb159bf6f9f5705ae081a47", + "url": "https://github.com/nixos/nixpkgs/archive/b6227cadb5123c7e4cb159bf6f9f5705ae081a47.tar.gz", + "hash": "sha256-KFR30GNFhjzXl0kVEn+KK4xrFr0gggb1NBroP8ukbxY=" + } + } +} diff --git a/lon.nix b/lon.nix new file mode 100644 index 0000000..5f320ea --- /dev/null +++ b/lon.nix @@ -0,0 +1,41 @@ +# Generated by lon. Do not modify! +let + + lock = builtins.fromJSON (builtins.readFile ./lon.lock); + + # Override with a path defined in an environment variable. If no variable is + # set, the original path is used. + overrideFromEnv = + name: path: + let + replacement = builtins.getEnv "LON_OVERRIDE_${name}"; + in + if replacement == "" then + path + else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 replacement == "/" then + /. + replacement + else + /. + builtins.getEnv "PWD" + "/${replacement}"; + + fetchSource = + args@{ fetchType, ... }: + if fetchType == "git" then + builtins.fetchGit { + url = args.url; + ref = args.branch; + rev = args.revision; + narHash = args.hash; + } + else if fetchType == "tarball" then + builtins.fetchTarball { + url = args.url; + sha256 = args.hash; + } + else + builtins.throw "Unsupported source type ${fetchType}"; + +in +builtins.mapAttrs (name: args: overrideFromEnv name (fetchSource args)) lock.sources diff --git a/modules/base.nix b/modules/base.nix index d2182c6..41550e6 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -69,6 +69,14 @@ in { default = "uimage"; }; tftp = { + commandLine = mkOption { + type = types.listOf types.str; + default = config.boot.commandLine; + description = '' + TFTP-specific command line. + Defaults to the classical one if unset. + ''; + }; loadAddress = mkOption { type = types.ints.unsigned; description = '' @@ -98,6 +106,9 @@ in { }; }; config = { + # By default, we enable cross-compilation support. + nixpkgs.buildPlatform = lib.mkDefault builtins.currentSystem; + defaultProfile.packages = with pkgs; [ s6 s6-init-bin execline s6-linux-init s6-rc ]; diff --git a/modules/outputs/tftpboot.nix b/modules/outputs/tftpboot.nix index a8fc4dc..4fd139d 100644 --- a/modules/outputs/tftpboot.nix +++ b/modules/outputs/tftpboot.nix @@ -41,14 +41,6 @@ in { type = types.bool; default = false; }; - commandLine = mkOption { - type = types.listOf types.str; - default = config.boot.commandLine; - description = '' - TFTP-specific command line. - Defaults to the classical one if unset. - ''; - }; }; options.system.outputs = { tftpboot = mkOption {