chore: format repo using treefmt-nix and nixfmt-rfc-style

This commit is contained in:
Andre 2025-06-04 12:11:03 -04:00
parent fc7c471412
commit 51e51e6014
266 changed files with 3721 additions and 2733 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ...}:
{
config,
lib,
pkgs,
...
}:
{
hardware.deviceTree.name = lib.mkDefault "starfive/jh7100-starfive-visionfive-v1.dtb";
@ -7,9 +12,19 @@
boot = {
# Force no ZFS (from nixos/modules/profiles/base.nix) until updated to kernel 6.0
supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
supportedFilesystems = lib.mkForce [
"btrfs"
"reiserfs"
"vfat"
"f2fs"
"xfs"
"ntfs"
"cifs"
];
consoleLogLevel = lib.mkDefault 7;
kernelPackages = lib.mkDefault (pkgs.callPackage ./linux.nix { inherit (config.boot) kernelPatches; });
kernelPackages = lib.mkDefault (
pkgs.callPackage ./linux.nix { inherit (config.boot) kernelPatches; }
);
kernelParams = lib.mkDefault [
"console=tty0"

View file

@ -1,6 +1,7 @@
{ runCommand
, buildPackages
, pkgs
{
runCommand,
buildPackages,
pkgs,
}:
let
@ -10,26 +11,29 @@ let
withPayload = "${uboot}/u-boot.bin";
withFDT = "${uboot}/u-boot.dtb";
};
in runCommand "firmware-starfive-visionfive-v1" {
nativeBuildInputs = with buildPackages; [ xxd ];
} ''
function handle_file {
inFile=$1
echo inFile: $inFile
outFile=$2
inSize=`stat -c "%s" $inFile`
inSize32HexBe=`printf "%08x\n" $inSize`
inSize32HexLe=''${inSize32HexBe:6:2}''${inSize32HexBe:4:2}''${inSize32HexBe:2:2}''${inSize32HexBe:0:2}
echo "inSize: $inSize (0x$inSize32HexBe, LE:0x$inSize32HexLe)"
echo $inSize32HexLe | xxd -r -ps > $outFile
cat $inFile >> $outFile
echo outFile: $outFile
outSize=`stat -c "%s" $outFile`
outSize32HexBe=`printf "%08x\n" $outSize`
echo "outSize: $outSize (0x$outSize32HexBe)"
in
runCommand "firmware-starfive-visionfive-v1"
{
nativeBuildInputs = with buildPackages; [ xxd ];
}
''
function handle_file {
inFile=$1
echo inFile: $inFile
outFile=$2
inSize=`stat -c "%s" $inFile`
inSize32HexBe=`printf "%08x\n" $inSize`
inSize32HexLe=''${inSize32HexBe:6:2}''${inSize32HexBe:4:2}''${inSize32HexBe:2:2}''${inSize32HexBe:0:2}
echo "inSize: $inSize (0x$inSize32HexBe, LE:0x$inSize32HexLe)"
echo $inSize32HexLe | xxd -r -ps > $outFile
cat $inFile >> $outFile
echo outFile: $outFile
outSize=`stat -c "%s" $outFile`
outSize32HexBe=`printf "%08x\n" $outSize`
echo "outSize: $outSize (0x$outSize32HexBe)"
}
mkdir -p "$out/nix-support"
echo "file bin \"$out/opensbi_u-boot_starfive_visionfive_v1.bin\"" >> "$out/nix-support/hydra-build-products"
handle_file ${opensbi}/share/opensbi/lp64/generic/firmware/fw_payload.bin $out/opensbi_u-boot_starfive_visionfive_v1.bin
''
mkdir -p "$out/nix-support"
echo "file bin \"$out/opensbi_u-boot_starfive_visionfive_v1.bin\"" >> "$out/nix-support/hydra-build-products"
handle_file ${opensbi}/share/opensbi/lp64/generic/firmware/fw_payload.bin $out/opensbi_u-boot_starfive_visionfive_v1.bin
''

View file

@ -1,36 +1,44 @@
{ lib
, callPackage
, linuxPackagesFor
, kernelPatches
, ... }:
{
lib,
callPackage,
linuxPackagesFor,
kernelPatches,
...
}:
let
modDirVersion = "6.0.0";
linuxPkg = { fetchFromGitHub, buildLinux, ... } @ args:
buildLinux (args // {
inherit modDirVersion kernelPatches;
version = "${modDirVersion}-starfive-visionfive-v1";
linuxPkg =
{ fetchFromGitHub, buildLinux, ... }@args:
buildLinux (
args
// {
inherit modDirVersion kernelPatches;
version = "${modDirVersion}-starfive-visionfive-v1";
src = fetchFromGitHub {
owner = "starfive-tech";
repo = "linux";
rev = "cfcb617265422c0af0ae5bc9688dceba2d10b27a";
sha256 = "sha256-EAMCOtJZ51xSLySQPaZyomfa/1Xs9kNedz04tIbELqg=";
};
src = fetchFromGitHub {
owner = "starfive-tech";
repo = "linux";
rev = "cfcb617265422c0af0ae5bc9688dceba2d10b27a";
sha256 = "sha256-EAMCOtJZ51xSLySQPaZyomfa/1Xs9kNedz04tIbELqg=";
};
defconfig = "starfive_jh7100_fedora_defconfig";
defconfig = "starfive_jh7100_fedora_defconfig";
structuredExtraConfig = with lib.kernel; {
KEXEC = yes;
SERIAL_8250_DW = yes;
PINCTRL_STARFIVE = yes;
DW_AXI_DMAC_STARFIVE = yes;
PTP_1588_CLOCK = yes;
STMMAC_ETH = yes;
STMMAC_PCI = yes;
};
structuredExtraConfig = with lib.kernel; {
KEXEC = yes;
SERIAL_8250_DW = yes;
PINCTRL_STARFIVE = yes;
DW_AXI_DMAC_STARFIVE = yes;
PTP_1588_CLOCK = yes;
STMMAC_ETH = yes;
STMMAC_PCI = yes;
};
extraMeta.branch = "visionfive";
} // (args.argsOverride or { }));
in lib.recurseIntoAttrs (linuxPackagesFor (callPackage linuxPkg { }))
extraMeta.branch = "visionfive";
}
// (args.argsOverride or { })
);
in
lib.recurseIntoAttrs (linuxPackagesFor (callPackage linuxPkg { }))

View file

@ -1,10 +1,16 @@
# To build, use:
# nix-build "<nixpkgs/nixos>" -I nixos-config=starfive/visionfive/v1/sd-image.nix -A config.system.build.sdImage
{ config, pkgs, modulesPath, ... }:
{
config,
pkgs,
modulesPath,
...
}:
let
firmware = pkgs.callPackage ./firmware.nix { };
in {
in
{
imports = [
"${modulesPath}/profiles/base.nix"
"${modulesPath}/installer/sd-card/sd-image.nix"

View file

@ -1,5 +1,6 @@
{ fetchFromGitHub
, buildUBoot
{
fetchFromGitHub,
buildUBoot,
}:
buildUBoot {
@ -13,5 +14,8 @@ buildUBoot {
};
defconfig = "starfive_jh7100_visionfive_smode_defconfig";
filesToInstall = [ "u-boot.bin" "u-boot.dtb" ];
filesToInstall = [
"u-boot.bin"
"u-boot.dtb"
];
}

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.hardware.visionfive2;
in
@ -34,15 +39,19 @@ in
config = {
system.build = {
opensbi = (pkgs.callPackage ./opensbi.nix {}).overrideAttrs (f: p: {
src = if cfg.opensbi.src != null then cfg.opensbi.src else p.src;
patches = if cfg.opensbi.patches != null then cfg.opensbi.patches else (p.patches or []);
});
opensbi = (pkgs.callPackage ./opensbi.nix { }).overrideAttrs (
_f: p: {
src = if cfg.opensbi.src != null then cfg.opensbi.src else p.src;
patches = if cfg.opensbi.patches != null then cfg.opensbi.patches else (p.patches or [ ]);
}
);
uboot = (pkgs.callPackage ./uboot.nix { inherit (config.system.build) opensbi; }).overrideAttrs (f: p: {
src = if cfg.uboot.src != null then cfg.uboot.src else p.src;
patches = if cfg.uboot.patches != null then cfg.uboot.patches else (p.patches or []);
});
uboot = (pkgs.callPackage ./uboot.nix { inherit (config.system.build) opensbi; }).overrideAttrs (
_f: p: {
src = if cfg.uboot.src != null then cfg.uboot.src else p.src;
patches = if cfg.uboot.patches != null then cfg.uboot.patches else (p.patches or [ ]);
}
);
updater-flash = pkgs.writeShellApplication {
name = "visionfive2-firmware-update-flash";

View file

@ -1,4 +1,9 @@
{ config, pkgs, modulesPath, ... }:
{
config,
pkgs,
modulesPath,
...
}:
{
imports = [
"${modulesPath}/profiles/base.nix"
@ -7,8 +12,7 @@
];
sdImage = {
imageName =
"${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}-starfive-visionfive2.img";
imageName = "${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}-starfive-visionfive2.img";
# Overridden by postBuildCommands
populateFirmwareCommands = "";

View file

@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub }:
stdenv.mkDerivation (finalAttrs: {
stdenv.mkDerivation (_finalAttrs: {
pname = "spi_tool";
version = "0x01010101";
src = fetchFromGitHub {

View file

@ -1,5 +1,6 @@
{ buildUBoot
, opensbi
{
buildUBoot,
opensbi,
}:
buildUBoot {