nixos-riscv/flake.nix

137 lines
4.1 KiB
Nix
Raw Normal View History

2022-06-25 17:37:18 +02:00
{
2024-05-28 18:12:14 +02:00
inputs.nixpkgs.url = "github:NixOS/nixpkgs/e4ad989506ec7d71f7302cc3067abd82730a4beb";
inputs.bscpkgs.url = "git+https://git.sr.ht/~rodarima/bscpkgs?ref=riscv-benchmarks";
# When changing bscpkgs, take directly from disk to avoid having to push:
#inputs.bscpkgs.url = "/home/Computational/rarias/bscpkgs";
2023-02-16 11:57:52 +01:00
2024-05-28 18:12:14 +02:00
outputs = {self,...}@inputs:
2024-01-17 18:22:30 +01:00
let
system = "x86_64-linux";
2024-05-28 18:12:14 +02:00
remoteNixpkgsPatches = [
{
meta.description = "sha256-ZCDQ7SpGhH8JvAwWzdcyrc68RFEWHxxAj0M2+AvEzIg=";
url = "https://github.com/NixOS/nixpkgs/pull/283460.diff";
sha256 = "sha256-g6o4rqkOOYZ6OJTzv9kTPq9Zsu5Z1QXZmPLC3Q7Sq6w=";
}
];
originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
nixpkgs = originPkgs.applyPatches {
name = "nixpkgs-patched";
src = inputs.nixpkgs;
patches = map originPkgs.fetchpatch remoteNixpkgsPatches;
};
nixosSystem = import (nixpkgs + "/nixos/lib/eval-config.nix");
2024-01-17 18:22:30 +01:00
in {
2024-05-13 18:59:00 +02:00
#overlay = import ./overlay.nix;
2024-01-17 18:22:30 +01:00
nixosConfigurations = {
# The qemu configuration defines a system that runs in the RISC-V
2024-01-17 18:22:30 +01:00
# architecture, but is build from an x86 host machine.
2024-05-28 18:12:14 +02:00
qemu = nixosSystem {
2024-05-13 18:59:00 +02:00
specialArgs = { inherit self; };
system = "${system}";
modules = [
./configuration.nix
./vm.nix
];
};
# Same, but disable compressed instructions
2024-05-28 18:12:14 +02:00
qemu-nc = nixosSystem {
2024-05-13 18:59:00 +02:00
specialArgs = { inherit self; };
2024-01-17 18:22:30 +01:00
system = "${system}";
modules = [
./configuration.nix
./vm.nix
./no-compressed.nix
2024-01-17 18:22:30 +01:00
];
};
2024-03-01 18:33:30 +01:00
# FPGA Lagarto Hun CPU
2024-05-28 18:12:14 +02:00
lagarto-hun = nixosSystem {
2024-05-13 18:59:00 +02:00
specialArgs = { inherit self; };
2024-03-01 18:33:30 +01:00
system = "${system}";
modules = [
./configuration.nix
./lagarto-hun.nix
2024-03-04 14:44:49 +01:00
./no-compressed.nix
2024-03-01 18:33:30 +01:00
];
};
2024-06-25 11:11:05 +02:00
# FPGA Lagarto Ox CPU
lagarto-ox = nixosSystem {
specialArgs = { inherit self; };
system = "${system}";
modules = [
./configuration.nix
./lagarto-ox.nix
./no-compressed.nix
];
};
2024-01-17 18:22:30 +01:00
};
2023-02-16 12:49:58 +01:00
2024-01-17 18:22:30 +01:00
# 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.qemu-nc;
2024-01-17 18:22:30 +01:00
syspkgs = nixosconf.pkgs;
2024-01-19 12:32:06 +01:00
toplevel = nixosconf.config.system.build.toplevel;
2024-05-13 18:59:00 +02:00
in syspkgs.mkShell {
2024-01-17 18:22:30 +01:00
pname = "qemu-shell";
2024-05-28 18:12:14 +02:00
nativeBuildInputs = with syspkgs; [ qemu e2fsprogs ];
2024-01-17 18:22:30 +01:00
# Here we tell the run script where to find the system
2024-01-17 18:33:58 +01:00
NIXOS_SYSTEM_TOPLEVEL = toplevel;
2024-01-18 17:58:00 +01:00
OPENSBI = syspkgs.opensbi-uboot;
2022-06-25 17:37:18 +02:00
};
2024-03-04 18:32:25 +01:00
devShells.x86_64-linux.lagarto-hun =
let
nixosconf = self.nixosConfigurations.lagarto-hun;
syspkgs = nixosconf.pkgs;
build = nixosconf.config.system.build;
2024-05-13 18:59:00 +02:00
in syspkgs.mkShell {
2024-03-04 18:32:25 +01:00
pname = "lagarto-hun-shell";
2024-03-07 16:49:48 +01:00
TOPLEVEL = build.toplevel;
2024-03-04 18:32:25 +01:00
OPENSBI = syspkgs.opensbi;
KERNEL = build.kernel;
INITRD = build.initialRamdisk;
2024-03-07 12:05:10 +01:00
ROOTFS = build.sdImage;
2024-03-07 16:49:48 +01:00
UBOOT_ENV = syspkgs.uboot-env;
shellHook = ''
echo "Here are the current system pieces:"
echo " TOPLEVEL = $TOPLEVEL"
echo " KERNEL = $KERNEL"
echo " OPENSBI = $OPENSBI"
echo " INITRD = $INITRD"
echo " ROOTFS = $ROOTFS"
echo " UBOOT_ENV = $UBOOT_ENV"
'';
2024-03-04 18:32:25 +01:00
};
2024-06-25 11:11:05 +02:00
devShells.x86_64-linux.lagarto-ox =
let
nixosconf = self.nixosConfigurations.lagarto-ox;
syspkgs = nixosconf.pkgs;
build = nixosconf.config.system.build;
in syspkgs.mkShell {
pname = "lagarto-ox-shell";
Remove unused PMEM regions Boots until the init, then fails with: [ 42.561840] Freeing unused kernel image (initmem) memory: 2448K [ 42.572360] Run /init as init process [ 42.577400] with arguments: [ 42.581780] /init [ 42.584520] with environment: [ 42.589320] HOME=/ [ 42.592140] TERM=linux [ 42.637580] init[1]: unhandled signal 4 code 0x1 at 0x0000003f966980d8 in ld-linux-riscv64-lp64d.so.1[3f96683000+23000] [ 42.650580] CPU: 0 PID: 1 Comm: init Not tainted 6.1.62 #1-NixOS [ 42.657720] Hardware name: Barcelona Supercomputing Center - Lagarto Ox (NixOS) (DT) [ 42.666760] epc : 0000003f966980d8 ra : 0000000000000000 sp : 0000003fe5c95db0 [ 42.675040] gp : ffffffff8197ea48 tp : 0000000000000000 t0 : 0000000000000000 [ 42.683320] t1 : 0000000000000000 t2 : 0000000000000000 s0 : 0000000000000000 [ 42.691600] s1 : 0000000000000000 a0 : 0000000000000000 a1 : 0000000000000000 [ 42.699880] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 [ 42.708160] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 [ 42.716420] s2 : 0000000000000000 s3 : 0000000000000000 s4 : 0000000000000000 [ 42.724700] s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000 [ 42.733380] s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000000000000000 [ 42.741660] s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 [ 42.749920] t5 : 0000000000000000 t6 : 0000000000000000 [ 42.756440] status: 0000000200004020 badaddr: 0000000000010513 cause: 0000000000000002 [ 42.767620] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 [ 42.775720] CPU: 0 PID: 1 Comm: init Not tainted 6.1.62 #1-NixOS [ 42.782320] Hardware name: Barcelona Supercomputing Center - Lagarto Ox (NixOS) (DT) [ 42.790460] Call Trace: [ 42.793380] [<ffffffff800070c4>] dump_backtrace+0x38/0x48 [ 42.799520] [<ffffffff809f063c>] show_stack+0x50/0x68 [ 42.805280] [<ffffffff809fd1f8>] dump_stack_lvl+0x60/0x84 [ 42.811400] [<ffffffff809fd23c>] dump_stack+0x20/0x30 [ 42.817140] [<ffffffff809f0918>] panic+0x160/0x390 [ 42.822620] [<ffffffff80020184>] do_exit+0xa70/0xa78 [ 42.828260] [<ffffffff800203a4>] do_group_exit+0x44/0xb0 [ 42.834240] [<ffffffff80031eec>] get_signal+0x9b4/0xa00 [ 42.840140] [<ffffffff80005ca0>] do_work_pending+0x18c/0x610 [ 42.846480] [<ffffffff80003880>] resume_userspace_slow+0x10/0x14 [ 42.853420] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 ]---
2024-06-28 14:36:32 +02:00
#TOPLEVEL = build.toplevel;
2024-06-25 11:11:05 +02:00
OPENSBI = syspkgs.opensbi;
KERNEL = build.kernel;
INITRD = build.initialRamdisk;
Remove unused PMEM regions Boots until the init, then fails with: [ 42.561840] Freeing unused kernel image (initmem) memory: 2448K [ 42.572360] Run /init as init process [ 42.577400] with arguments: [ 42.581780] /init [ 42.584520] with environment: [ 42.589320] HOME=/ [ 42.592140] TERM=linux [ 42.637580] init[1]: unhandled signal 4 code 0x1 at 0x0000003f966980d8 in ld-linux-riscv64-lp64d.so.1[3f96683000+23000] [ 42.650580] CPU: 0 PID: 1 Comm: init Not tainted 6.1.62 #1-NixOS [ 42.657720] Hardware name: Barcelona Supercomputing Center - Lagarto Ox (NixOS) (DT) [ 42.666760] epc : 0000003f966980d8 ra : 0000000000000000 sp : 0000003fe5c95db0 [ 42.675040] gp : ffffffff8197ea48 tp : 0000000000000000 t0 : 0000000000000000 [ 42.683320] t1 : 0000000000000000 t2 : 0000000000000000 s0 : 0000000000000000 [ 42.691600] s1 : 0000000000000000 a0 : 0000000000000000 a1 : 0000000000000000 [ 42.699880] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 [ 42.708160] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 [ 42.716420] s2 : 0000000000000000 s3 : 0000000000000000 s4 : 0000000000000000 [ 42.724700] s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000 [ 42.733380] s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000000000000000 [ 42.741660] s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 [ 42.749920] t5 : 0000000000000000 t6 : 0000000000000000 [ 42.756440] status: 0000000200004020 badaddr: 0000000000010513 cause: 0000000000000002 [ 42.767620] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 [ 42.775720] CPU: 0 PID: 1 Comm: init Not tainted 6.1.62 #1-NixOS [ 42.782320] Hardware name: Barcelona Supercomputing Center - Lagarto Ox (NixOS) (DT) [ 42.790460] Call Trace: [ 42.793380] [<ffffffff800070c4>] dump_backtrace+0x38/0x48 [ 42.799520] [<ffffffff809f063c>] show_stack+0x50/0x68 [ 42.805280] [<ffffffff809fd1f8>] dump_stack_lvl+0x60/0x84 [ 42.811400] [<ffffffff809fd23c>] dump_stack+0x20/0x30 [ 42.817140] [<ffffffff809f0918>] panic+0x160/0x390 [ 42.822620] [<ffffffff80020184>] do_exit+0xa70/0xa78 [ 42.828260] [<ffffffff800203a4>] do_group_exit+0x44/0xb0 [ 42.834240] [<ffffffff80031eec>] get_signal+0x9b4/0xa00 [ 42.840140] [<ffffffff80005ca0>] do_work_pending+0x18c/0x610 [ 42.846480] [<ffffffff80003880>] resume_userspace_slow+0x10/0x14 [ 42.853420] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 ]---
2024-06-28 14:36:32 +02:00
#ROOTFS = build.sdImage;
2024-06-25 11:11:05 +02:00
UBOOT_ENV = syspkgs.uboot-env;
shellHook = ''
echo "Here are the current system pieces:"
echo " TOPLEVEL = $TOPLEVEL"
echo " KERNEL = $KERNEL"
echo " OPENSBI = $OPENSBI"
echo " INITRD = $INITRD"
echo " ROOTFS = $ROOTFS"
echo " UBOOT_ENV = $UBOOT_ENV"
'';
};
2024-01-17 18:22:30 +01:00
};
2022-06-25 17:37:18 +02:00
}