From 5b8a51fb19fa445bcdfe651c2902974fd7851681 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 24 Jan 2024 12:50:41 +0100 Subject: [PATCH] Add qemu and qemu-nc NixOS configurations --- configuration.nix | 4 ++++ flake.nix | 40 ++++++++++++++++------------------------ no-compressed.nix | 9 +++++++++ 3 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 no-compressed.nix diff --git a/configuration.nix b/configuration.nix index edc7a02..4bc19b8 100644 --- a/configuration.nix +++ b/configuration.nix @@ -5,6 +5,10 @@ "${modulesPath}/profiles/base.nix" ]; + nixpkgs.crossSystem = { + system = "riscv64-linux"; + }; + networking.hostName = "nixos-riscv"; nixpkgs.overlays = [ (import ./overlay.nix) ]; diff --git a/flake.nix b/flake.nix index b9bf18a..855d8ec 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/no-compressed.nix b/no-compressed.nix new file mode 100644 index 0000000..acbba80 --- /dev/null +++ b/no-compressed.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + nixpkgs.crossSystem = { + system = "riscv64-linux"; + gcc.arch = "rv64g"; + gcc.tune = "rv64g"; + }; +}