nixos: replace system.build.toplevel

This commit is contained in:
Ehmry - 2021-01-05 15:11:42 +01:00
parent 15f122f981
commit b15c1b6cea
6 changed files with 163 additions and 13 deletions

View File

@ -57,13 +57,82 @@
lib =
# Local utilities merged with the Nixpkgs lib
forAllCrossSystems ({ system, localSystem, crossSystem }:
nixpkgs.lib // (import ./lib {
inherit system localSystem crossSystem;
pkgs = self.legacyPackages.${system};
})) // {
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
};
nixpkgs.lib.extend (final: prev: {
inherit forAllSystems forAllLocalSystems forAllCrossSystems;
nixosSystem = { modules, ... }@args:
import "${nixpkgs}/nixos/lib/eval-config.nix" (args // {
baseModules =
# TODO: do not blacklist modules for the Linux guests
with builtins;
let
isNotModule = suffix:
let x = "${nixpkgs}/nixos/modules/${suffix}";
in y: x != y;
filters = map isNotModule
(import ./nixos-modules/base-modules-blacklist.nix);
isCompatible = p:
let p' = toString p;
in all (f: f p') filters;
in filter isCompatible
(import "${nixpkgs}/nixos/modules/module-list.nix");
modules = modules ++ [
({ config, lib, ... }: {
options = with lib; {
system.boot.loader.id = mkOption {
internal = true;
default = "";
};
system.boot.loader.kernelFile = mkOption {
internal = true;
default = pkgs.stdenv.hostPlatform.platform.kernelTarget;
type = types.str;
};
system.boot.loader.initrdFile = mkOption {
internal = true;
default = "initrd";
type = types.str;
};
systemd.defaultUnit = mkOption {
default = "multi-user.target";
type = types.str;
};
};
config = {
boot.loader.grub.enable = lib.mkDefault false;
fileSystems."/" = { };
networking.enableIPv6 = lib.mkForce false;
systemd.network.enable = lib.mkForce false;
system.nixos.versionSuffix = ".${
final.substring 0 8
(self.lastModifiedDate or self.lastModified or "19700101")
}.${self.shortRev or "dirty"}";
system.nixos.revision = final.mkIf (self ? rev) self.rev;
system.build.toplevel = config.system.build.initXml;
};
})
];
});
});
legacyPackages =
# The nixpkgs.legacyPackages after overlaying

View File

@ -0,0 +1,60 @@
[
"hardware/openrazer.nix"
"hardware/raid/hpsa.nix"
"hardware/sensor/iio.nix"
"hardware/system-76.nix"
"hardware/tuxedo-keyboard.nix"
"hardware/video/amdgpu-pro.nix"
"hardware/video/ati.nix"
"hardware/video/bumblebee.nix"
"hardware/video/capture/mwprocapture.nix"
"hardware/video/displaylink.nix"
"hardware/video/hidpi.nix"
"hardware/video/nvidia.nix"
"hardware/video/webcam/facetimehd.nix"
"hardware/xpadneo.nix"
"programs/bcc.nix"
"programs/cdemu.nix"
"programs/criu.nix"
"programs/sysdig.nix"
"programs/systemtap.nix"
"services/hardware/nvidia-optimus.nix"
"services/network-filesystems/nfsd.nix"
"services/networking/ntp/chrony.nix"
"services/networking/ntp/ntpd.nix"
"services/networking/ntp/openntpd.nix"
"services/networking/wg-quick.nix"
"services/networking/wireguard.nix"
"services/x11/desktop-managers/plasma5.nix"
"services/x11/hardware/digimend.nix"
"system/activation/linux.nix"
"system/boot/binfmt.nix"
"system/boot/emergency-mode.nix"
"system/boot/grow-partition.nix"
"system/boot/initrd-network.nix"
"system/boot/initrd-openvpn.nix"
"system/boot/initrd-ssh.nix"
"system/boot/loader/raspberrypi/raspberrypi.nix"
"system/boot/loader/systemd-boot/systemd-boot.nix"
"system/boot/luksroot.nix"
"system/boot/plymouth.nix"
"system/boot/tmp.nix"
"tasks/bcache.nix"
"tasks/encrypted-devices.nix"
"tasks/filesystems/bcachefs.nix"
"tasks/filesystems/btrfs.nix"
"tasks/filesystems/cifs.nix"
"tasks/filesystems/ext.nix"
"tasks/filesystems/f2fs.nix"
"tasks/filesystems/jfs.nix"
"tasks/filesystems/nfs.nix"
"tasks/filesystems/reiserfs.nix"
"tasks/filesystems/unionfs-fuse.nix"
"tasks/filesystems/vboxsf.nix"
"tasks/filesystems/vfat.nix"
"tasks/filesystems/xfs.nix"
"tasks/filesystems/zfs.nix"
"tasks/lvm.nix"
"tasks/swraid.nix"
"virtualisation/xen-dom0.nix"
]

View File

@ -12,9 +12,9 @@
./systemd.nix
];
nixpkgs = rec {
localSystem = "x86_64-linux";
crossSystem = "x86_64-genode";
system = localSystem + "-" + crossSystem;
localSystem.system = "x86_64-linux";
crossSystem.system = "x86_64-genode";
system = localSystem.system + "-" + crossSystem.system;
pkgs = flake.legacyPackages.${system};
};
};

View File

@ -191,7 +191,8 @@ in {
in {
assertions = [{
assertion = builtins.any (s: s == config.nixpkgs.system)
assertion = builtins.any (s:
s == config.nixpkgs.system || s == config.nixpkgs.crossSystem.system)
config.genode.core.supportedSystems;
message = "invalid Genode core for this system";
}];

View File

@ -27,7 +27,17 @@ let
autoreconfHost = overrideAttrsHost
(attrs: { nativeBuildInputs = [ final.autoreconfHook ]; });
in {
nullPkgs =
# Nullify this packages to find problems early
if hostPlatform.isGenode then
builtins.listToAttrs (map (name: {
inherit name;
value = null;
}) [ "iproute2" ])
else
{ };
in nullPkgs // {
bash = overrideAttrsTarget (attrs: {
configureFlags = attrs.configureFlags
@ -103,6 +113,16 @@ in {
libvpx = null;
} libtoxcore;
linuxPackages = if hostPlatform.isGenode then {
extend = _: final.linuxPackages;
features = { };
kernel.config = {
isEnabled = _: false;
isYes = _: false;
};
} else
linuxPackages;
llvmPackages_11 = callPackage ./llvm-11 ({
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages.llvmPackages_11.tools;

View File

@ -1,7 +1,7 @@
{ flake, system, localSystem, crossSystem, pkgs }:
let
lib = flake.lib.${system};
lib = flake.lib;
nixpkgs = flake.legacyPackages.${system};
legacyPackages = flake.legacyPackages.${system};