2
0

Make Liminix usable as an input to a flake

This change allows Liminix to be used as a non-flake input to a flake
by making <nixpkgs> into a default argument.

An example flake that makes use of this is here:
https://github.com/pcc/liminix-flake-demo
This commit is contained in:
Peter Collingbourne
2026-05-02 23:19:34 -07:00
parent d0376d4101
commit 17d8576cc4
5 changed files with 19 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
nixpkgs:
{
config,
pkgs,
@@ -65,7 +66,7 @@ in
};
};
imports = [
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
];
config = {
boot.kernelParams = [ "loglevel=9" ];

View File

@@ -2,15 +2,18 @@
deviceName ? null,
device ? (import ./devices/${deviceName}),
liminix-config ? <liminix-config>,
nixpkgs ? <nixpkgs>,
system ? builtins.currentSystem,
borderVmConf ? ./bordervm.conf.nix,
imageType ? "primary",
}:
let
overlay = import ./overlay.nix;
pkgs = import <nixpkgs> (
overlay = import ./overlay.nix nixpkgs;
pkgs = import nixpkgs (
device.system
// {
inherit system;
overlays = [ overlay ];
config = {
allowUnsupportedSystem = true; # mipsel
@@ -53,8 +56,8 @@ let
config = eval.config;
borderVm =
((import <nixpkgs/nixos/lib/eval-config.nix>) {
system = builtins.currentSystem;
((import "${nixpkgs}/nixos/lib/eval-config.nix") {
inherit system;
modules = [
{
nixpkgs.overlays = [
@@ -64,7 +67,7 @@ let
})
];
}
(import ./bordervm-configuration.nix)
(import ./bordervm-configuration.nix nixpkgs)
borderVmConf
];
}).config.system;
@@ -72,6 +75,7 @@ in
{
outputs = config.system.outputs // {
default = config.system.outputs.${config.hardware.defaultOutput};
borderVm = borderVm.build.vm;
optionsJson =
let
o = import ./doc/extract-options.nix {

View File

@@ -1,9 +1,10 @@
final: prev:
nixpkgs: final: prev:
let
isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform;
crossOnly = pkg: amendFn: if isCross then (amendFn pkg) else pkg;
extraPkgs = import ./pkgs/default.nix {
inherit (final) lib callPackage;
inherit nixpkgs;
};
inherit (final) fetchpatch lib;
luaHost =

View File

@@ -1,4 +1,4 @@
{ callPackage, lib }:
{ callPackage, lib, nixpkgs }:
let
typeChecked =
caller: type: value:
@@ -17,7 +17,9 @@ in
{
liminix = {
builders = {
squashfs = callPackage ./liminix-tools/builders/squashfs.nix { };
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {
inherit nixpkgs;
};
dtb = callPackage ./kernel/dtb.nix { };
uimage = callPackage ./kernel/uimage.nix { };
kernel = callPackage ./kernel { };

View File

@@ -1,6 +1,7 @@
{
buildPackages,
callPackage,
nixpkgs,
pseudofile,
runCommand,
writeText,
@@ -9,7 +10,7 @@ filesystem:
let
pseudofiles = pseudofile.write "files.pf" filesystem;
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
storefs = callPackage "${nixpkgs}/nixos/lib/make-squashfs.nix" {
# 1) Every required package is referenced from somewhere
# outside /nix/store. 2) Every file outside the store is
# specified by config.filesystem. 3) Therefore, closing over