flake: use regexp and flake inputs to automate kernel building
This commit is contained in:
parent
c0cbf6cf02
commit
1aba6fb17a
5
base.nix
5
base.nix
@ -1,10 +1,5 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
{
|
{
|
||||||
# Use the kernel from ./kernel.nix
|
|
||||||
boot.kernelPackages = let
|
|
||||||
linux_VisionFive = pkgs.callPackage ./kernel.nix { };
|
|
||||||
in lib.mkForce (pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_VisionFive));
|
|
||||||
|
|
||||||
# Remove ZFS
|
# Remove ZFS
|
||||||
boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" "ext4" "vfat" ];
|
boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" "ext4" "vfat" ];
|
||||||
|
|
||||||
|
31
flake.lock
31
flake.lock
@ -54,16 +54,16 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1652789813,
|
"lastModified": 1657311595,
|
||||||
"narHash": "sha256-90QPw85Vl9+YWQpM/zRjb0/OYI+IODimC4LZufpCIh4=",
|
"narHash": "sha256-P/uhx5z7pW8OlpJzeShM7iBw7obrgv8CNLRP3G2xcG0=",
|
||||||
"owner": "Madouura",
|
"owner": "matthewcroughan",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "aff8bd5ce0a12ee22402cd9bc6b3c437f0845345",
|
"rev": "6fd612ce3a656b1bcf5a1222c63294dcfcbb5361",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "Madouura",
|
"owner": "matthewcroughan",
|
||||||
"ref": "dev/linux-riscv",
|
"ref": "mc/visionfive-nix",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@ -74,7 +74,24 @@
|
|||||||
"jh7100_recovery_binary": "jh7100_recovery_binary",
|
"jh7100_recovery_binary": "jh7100_recovery_binary",
|
||||||
"jh7100_secondBoot": "jh7100_secondBoot",
|
"jh7100_secondBoot": "jh7100_secondBoot",
|
||||||
"jh71xx-tools": "jh71xx-tools",
|
"jh71xx-tools": "jh71xx-tools",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"vendor-kernel": "vendor-kernel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"vendor-kernel": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1657015117,
|
||||||
|
"narHash": "sha256-WkJBcyAj1sDMZ8s/JqSAOV+CvXHwGYQrs9cLnOv0BkQ=",
|
||||||
|
"owner": "starfive-tech",
|
||||||
|
"repo": "linux",
|
||||||
|
"rev": "943858df470556d0b7f3b31fcc10931603f0f3cc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "starfive-tech",
|
||||||
|
"repo": "linux",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
12
flake.nix
12
flake.nix
@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:matthewcroughan/nixpkgs/mc/visionfive-nix";
|
nixpkgs.url = "github:matthewcroughan/nixpkgs/mc/visionfive-nix";
|
||||||
|
vendor-kernel = {
|
||||||
|
url = "github:starfive-tech/linux";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
jh7100_ddrinit = {
|
jh7100_ddrinit = {
|
||||||
url = "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out";
|
url = "https://github.com/starfive-tech/JH7100_ddrinit/releases/download/ddrinit-2133-211102/ddrinit-2133-211102.bin.out";
|
||||||
flake = false;
|
flake = false;
|
||||||
@ -18,17 +22,21 @@
|
|||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = { self, nixpkgs, jh71xx-tools, jh7100_recovery_binary, jh7100_secondBoot, jh7100_ddrinit }:
|
outputs = { self, nixpkgs, jh71xx-tools, jh7100_recovery_binary, jh7100_secondBoot, jh7100_ddrinit, vendor-kernel }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
|
||||||
modules = [
|
modules = [
|
||||||
|
{ nixpkgs.overlays = [ self.overlay ]; }
|
||||||
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-riscv64-visionfive-installer.nix"
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-riscv64-visionfive-installer.nix"
|
||||||
./base.nix
|
./base.nix
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
overlay = final: prev: {
|
||||||
|
linuxPackages_visionfive = final.linuxPackagesFor ((final.callPackage ./kernel.nix { inherit vendor-kernel; }).override { patches = []; });
|
||||||
|
};
|
||||||
apps.${system} = {
|
apps.${system} = {
|
||||||
flashBootloader =
|
flashBootloader =
|
||||||
let
|
let
|
||||||
|
22
kernel.nix
22
kernel.nix
@ -1,26 +1,33 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, buildLinux
|
, buildLinux
|
||||||
|
, vendor-kernel
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
let
|
let
|
||||||
modDirVersion = "5.18.5";
|
kernelVersion = rec {
|
||||||
|
# Fully constructed string, example: "5.10.0-rc5".
|
||||||
|
string = "${version + "." + patchlevel + "." + sublevel + (lib.optionalString (extraversion != "") extraversion)}";
|
||||||
|
file = "${vendor-kernel}/Makefile";
|
||||||
|
version = toString (builtins.match ".+VERSION = ([0-9]+).+" (builtins.readFile file));
|
||||||
|
patchlevel = toString (builtins.match ".+PATCHLEVEL = ([0-9]+).+" (builtins.readFile file));
|
||||||
|
sublevel = toString (builtins.match ".+SUBLEVEL = ([0-9]+).+" (builtins.readFile file));
|
||||||
|
# rc, next, etc.
|
||||||
|
extraversion = toString (builtins.match ".+EXTRAVERSION = ([a-z0-9-]+).+" (builtins.readFile file));
|
||||||
|
};
|
||||||
|
modDirVersion = "${kernelVersion.string}";
|
||||||
in buildLinux (args // {
|
in buildLinux (args // {
|
||||||
inherit modDirVersion;
|
inherit modDirVersion;
|
||||||
version = "${modDirVersion}-visionfive";
|
version = "${modDirVersion}-visionfive";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = vendor-kernel;
|
||||||
owner = "starfive-tech";
|
|
||||||
repo = "linux";
|
|
||||||
rev = "8fb50a9b3e5d401d4ec169c858e8b7ba0a542955";
|
|
||||||
sha256 = "sha256-kjOoNJhmmQdpmtx0m1ZovH3mj2x4NB6iInEknxZq8Dw=";
|
|
||||||
};
|
|
||||||
|
|
||||||
kernelPatches = [];
|
kernelPatches = [];
|
||||||
|
|
||||||
defconfig = "starfive_jh7100_fedora_defconfig";
|
defconfig = "starfive_jh7100_fedora_defconfig";
|
||||||
|
|
||||||
structuredExtraConfig = with lib.kernel; {
|
structuredExtraConfig = with lib.kernel; {
|
||||||
|
KEXEC = yes;
|
||||||
SERIAL_8250_DW = yes;
|
SERIAL_8250_DW = yes;
|
||||||
PINCTRL_STARFIVE = yes;
|
PINCTRL_STARFIVE = yes;
|
||||||
|
|
||||||
@ -34,7 +41,6 @@ in buildLinux (args // {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extraMeta = {
|
extraMeta = {
|
||||||
branch = "visionfive-5.18.y";
|
|
||||||
description = "Linux kernel for StarFive's JH7100 RISC-V SoC (VisionFive)";
|
description = "Linux kernel for StarFive's JH7100 RISC-V SoC (VisionFive)";
|
||||||
platforms = [ "riscv64-linux" ];
|
platforms = [ "riscv64-linux" ];
|
||||||
hydraPlatforms = [ "riscv64-linux" ];
|
hydraPlatforms = [ "riscv64-linux" ];
|
||||||
|
Loading…
Reference in New Issue
Block a user