nixos-riscv/flake.nix

102 lines
3.9 KiB
Nix
Raw Normal View History

2022-06-25 17:37:18 +02:00
{
inputs = {
nixpkgs.url = "github:matthewcroughan/nixpkgs/mc/riscv-testing";
2023-02-16 11:57:52 +01:00
# VisionFive ("v1")
vendor-kernel = {
url = "github:starfive-tech/linux";
flake = false;
};
2022-06-25 17:37:18 +02:00
jh7100_ddrinit = {
url = "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out";
flake = false;
};
jh7100_secondBoot = {
url = "https://github.com/starfive-tech/JH7100_secondBoot/releases/download/bootloader-211102_VisionFive_JH7100/bootloader-JH7100-211102.bin.out";
flake = false;
};
jh7100_recovery_binary = {
url = "https://github.com/starfive-tech/bootloader_recovery/releases/download/JH7100_recovery_binary/jh7100_recovery_boot.bin";
flake = false;
};
jh71xx-tools = {
url = "github:xypron/jh71xx-tools";
flake = false;
};
2023-02-16 11:57:52 +01:00
# VisionFive 2
jh7110-kernel = {
# url = "github:starfive-tech/linux/50a831018ed997c9fb3b603574176b221a28aa12"; # JH7110_VisionFive2_devel via VisionFive2 project submodule about two revisions back.
url = "github:starfive-tech/linux/JH7110_VisionFive2_devel";
flake = false;
};
jh7110_recovery_binary = {
url = "https://github.com/starfive-tech/Tools/blob/bc6dc7e33e0c2466db0476b5043f0f77842f98f0/recovery/jh7110-recovery-20221205.bin?raw=true";
flake = false;
};
# Should be possible to build from https://github.com/starfive-tech/VisionFive2
jh7110_u-boot-spl-bin = {
url = https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/u-boot-spl.bin.normal.out;
flake = false;
};
jh7110_u-boot-bin = {
url = https://github.com/starfive-tech/VisionFive2/releases/download/VF2_v2.8.0/visionfive2_fw_payload.img;
flake = false;
};
2022-06-25 17:37:18 +02:00
};
2023-02-16 12:49:58 +01:00
outputs = inputs@{ self, nixpkgs, jh71xx-tools, jh7100_recovery_binary, jh7100_secondBoot, jh7100_ddrinit, vendor-kernel, ... }:
2022-06-25 17:37:18 +02:00
let
2023-02-16 12:49:58 +01:00
inherit (nixpkgs) lib;
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
2022-06-25 17:37:18 +02:00
modules = [
{ nixpkgs.overlays = [ self.overlay ]; }
2022-06-25 17:37:18 +02:00
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-riscv64-visionfive-installer.nix"
./base.nix
./configuration.nix
];
2023-02-16 12:49:58 +01:00
# Pass arguments to a module inside a function inside a file, while preserving
# the file name behavior of the module system.
importApply =
modulePath: staticArgs:
lib.setDefaultModuleLocation modulePath (import modulePath staticArgs);
2022-06-25 17:37:18 +02:00
in
{
overlay = final: prev: {
linuxPackages_visionfive = final.linuxPackagesFor ((final.callPackage ./kernel.nix { inherit vendor-kernel; }).override { patches = []; });
};
legacyPackages.${system} =
{
inherit (pkgs.pkgsCross.riscv64.linux) linuxPackages_visionfive;
};
2022-06-25 17:37:18 +02:00
images = {
visionfive-cross = self.nixosConfigurations.visionfive-cross.config.system.build.sdImage;
visionfive-native = self.nixosConfigurations.visionfive-native.config.system.build.sdImage;
2023-02-16 12:49:58 +01:00
visionfive2-cross = self.nixosConfigurations.visionfive2-cross.config.system.build.sdImage;
visionfive2-native = self.nixosConfigurations.visionfive2-native.config.system.build.sdImage;
2022-06-25 17:37:18 +02:00
};
2023-02-16 12:49:58 +01:00
nixosModules = {
visionfive2-sd-image = importApply ./visionfive2/sd-image.nix { inherit inputs importApply; };
visionfive2-kernel = importApply ./visionfive2/kernel/nixos-module.nix { inherit inputs importApply; };
};
2023-11-27 11:41:05 +01:00
nixosConfigurations = {
visionfive-cross = nixpkgs.lib.nixosSystem {
system = "${system}";
2022-06-25 17:37:18 +02:00
modules = modules ++ [
{
nixpkgs.crossSystem = {
system = "riscv64-linux";
};
}
];
};
visionfive-native = nixpkgs.lib.nixosSystem {
system = "riscv64-linux";
modules = modules;
};
};
};
}