Add qemu and qemu-nc NixOS configurations

This commit is contained in:
Rodrigo Arias 2024-01-24 12:50:41 +01:00
parent d3f97dac58
commit 5b8a51fb19
3 changed files with 29 additions and 24 deletions

View File

@ -5,6 +5,10 @@
"${modulesPath}/profiles/base.nix"
];
nixpkgs.crossSystem = {
system = "riscv64-linux";
};
networking.hostName = "nixos-riscv";
nixpkgs.overlays = [ (import ./overlay.nix) ];

View File

@ -12,43 +12,35 @@
system = "x86_64-linux";
overlay = import ./overlay.nix;
pkgs = import nixpkgs { inherit system; };
modules = [
# For now we only define a config for VM, later we will want to split
# this into different configs.
./vm.nix
./configuration.nix
];
in {
overlay = import ./overlay.nix;
nixosConfigurations = {
# The cross configuration defines a system that runs in the RISC-V
# The qemu configuration defines a system that runs in the RISC-V
# architecture, but is build from an x86 host machine.
cross = nixpkgs.lib.nixosSystem {
qemu = nixpkgs.lib.nixosSystem {
system = "${system}";
modules = modules ++ [
{
nixpkgs.crossSystem = {
gcc.arch = "rv64g";
gcc.tune = "rv64g";
system = "riscv64-linux";
};
}
modules = [
./configuration.nix
./vm.nix
];
};
# Same, but disable compressed instructions
qemu-nc = nixpkgs.lib.nixosSystem {
system = "${system}";
modules = [
./configuration.nix
./vm.nix
./no-compressed.nix
];
};
# The native configuration defines the same system, but built from an
# RISC-V machine. Not needed for now.
#native = nixpkgs.lib.nixosSystem {
# system = "riscv64-linux";
# modules = modules;
#};
};
# A development shell with QEMU ready to boot the RISC-V system in an x86
# machine.
devShells.x86_64-linux.default =
let
nixosconf = self.nixosConfigurations.cross;
nixosconf = self.nixosConfigurations.qemu-nc;
syspkgs = nixosconf.pkgs;
toplevel = nixosconf.config.system.build.toplevel;
#toplevel = "${nixosconf.config.system.build.vm}/system";

9
no-compressed.nix Normal file
View File

@ -0,0 +1,9 @@
{ config, lib, pkgs, modulesPath, ... }:
{
nixpkgs.crossSystem = {
system = "riscv64-linux";
gcc.arch = "rv64g";
gcc.tune = "rv64g";
};
}