Format all files

This commit is contained in:
Waldemar Tomme
2025-04-27 11:18:21 +02:00
parent f76f7232fd
commit b8405bd22b
30 changed files with 452 additions and 392 deletions

View File

@@ -13,18 +13,26 @@
}; };
}; };
outputs = { self, deploy-rs, ... } @ inputs: { outputs =
packages = import ./pkgs inputs; {
overlays = import ./overlays inputs; self,
nixosConfigurations = import ./nixosConfigurations inputs; deploy-rs,
nixosModules = import ./nixosModules inputs; nixpkgs,
...
}@inputs:
{
packages = import ./pkgs inputs;
overlays = import ./overlays inputs;
nixosConfigurations = import ./nixosConfigurations inputs;
nixosModules = import ./nixosModules inputs;
deploy.nodes.default = { formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-tree;
hostname = "nintendo-switch"; deploy.nodes.default = {
profiles.system = { hostname = "nintendo-switch";
sshUser = "root"; profiles.system = {
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.example; sshUser = "root";
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.example;
};
}; };
}; };
};
} }

View File

@@ -1,4 +1,3 @@
inputs: inputs: {
{
example = import ./example.nix inputs; example = import ./example.nix inputs;
} }

View File

@@ -3,17 +3,24 @@ inputs.nixpkgs.lib.nixosSystem {
modules = [ modules = [
inputs.self.nixosModules.switchroot-nixos inputs.self.nixosModules.switchroot-nixos
( (
{ lib, pkgs, config, ... }: {
lib,
pkgs,
config,
...
}:
{ {
nixpkgs = { nixpkgs = {
# buildPlatform = system; # buildPlatform = system;
# buildPlatform = "x86_64-linux"; # TODO: for now only cross compilation # buildPlatform = "x86_64-linux"; # TODO: for now only cross compilation
# hostPlatform = "aarch64-linux"; # hostPlatform = "aarch64-linux";
system = "aarch64-linux"; system = "aarch64-linux";
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ config.allowUnfreePredicate =
"nvidia-x11" pkg:
"nvidia-settings" builtins.elem (lib.getName pkg) [
]; "nvidia-x11"
"nvidia-settings"
];
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@@ -1,5 +1,4 @@
inputs: inputs: rec {
rec {
switchroot-nixos = import ./switchroot-nixos.nix inputs; switchroot-nixos = import ./switchroot-nixos.nix inputs;
default = switchroot-nixos; default = switchroot-nixos;
} }

View File

@@ -13,7 +13,8 @@
enable = true; enable = true;
installHook = installHook =
let let
switchroot-boot = (pkgs.switchroot-nixos { switchroot-boot =
(pkgs.switchroot-nixos {
inherit (config.system.build) kernel initialRamdisk toplevel; inherit (config.system.build) kernel initialRamdisk toplevel;
}).boot; }).boot;
installApplication = pkgs.writeShellApplication { installApplication = pkgs.writeShellApplication {
@@ -27,7 +28,7 @@
''; '';
}; };
in in
pkgs.lib.getExe installApplication; pkgs.lib.getExe installApplication;
}; };
system.build.switchrootImage = pkgs.switchroot-nixos { system.build.switchrootImage = pkgs.switchroot-nixos {
inherit (config.system.build) kernel initialRamdisk toplevel; inherit (config.system.build) kernel initialRamdisk toplevel;

View File

@@ -3,78 +3,80 @@
services = { services = {
xserver = { xserver = {
displayManager.lightdm.extraConfig = '' displayManager.lightdm.extraConfig = ''
logind-check-graphical=false logind-check-graphical=false
''; '';
videoDrivers = [ "nvidia" ]; videoDrivers = [ "nvidia" ];
drivers = [ drivers = [
{ {
name = "nvidia"; name = "nvidia";
modules = [ pkgs.nvidiaPackages-l4t.x11-module ]; modules = [ pkgs.nvidiaPackages-l4t.x11-module ];
# driverName = "nvidia"; # driverName = "nvidia";
display = true; display = true;
screenSection = '' screenSection = ''
Option "metamodes" "DSI-0: nvidia-auto-select @1280x720 +0+0 {ViewPortIn=1280x720, ViewPortOut=720x1280+0+0, Rotation=90}" Option "metamodes" "DSI-0: nvidia-auto-select @1280x720 +0+0 {ViewPortIn=1280x720, ViewPortOut=720x1280+0+0, Rotation=90}"
''; '';
} }
]; ];
monitorSection = '' monitorSection = ''
ModelName "DFP-0" ModelName "DFP-0"
#DisplaySize 77 137 #DisplaySize 77 137
''; '';
deviceSection = '' deviceSection = ''
Option "AllowUnofficialGLXProtocol" "true" Option "AllowUnofficialGLXProtocol" "true"
Option "DPMS" "false" Option "DPMS" "false"
# Allow X server to be started even if no display devices are connected. # Allow X server to be started even if no display devices are connected.
Option "AllowEmptyInitialConfiguration" "true" Option "AllowEmptyInitialConfiguration" "true"
Option "Monitor-DSI-0" "Monitor[0]" Option "Monitor-DSI-0" "Monitor[0]"
# Option "Monitor-DP-0" "Monitor1" # Option "Monitor-DP-0" "Monitor1"
''; '';
}; };
udev.packages = with pkgs; [ udev.packages = with pkgs; [
nvidiaPackages-l4t.udev-rules nvidiaPackages-l4t.udev-rules
]; ];
}; };
boot.blacklistedKernelModules = [ boot.blacklistedKernelModules = [
"nouveau" "nouveau"
"nvidiafb" "nvidiafb"
]; ];
boot.kernelModules = [ boot.kernelModules = [
"nvgpu" "nvgpu"
]; ];
# hardware.nvidia.enabled = true; # hardware.nvidia.enabled = true;
hardware.nvidia.open = false; hardware.nvidia.open = false;
hardware.nvidia.package = null; hardware.nvidia.package = null;
nixpkgs.config.nvidia.acceptLicense = true; nixpkgs.config.nvidia.acceptLicense = true;
hardware.graphics = { hardware.graphics = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
nvidiaPackages-l4t.tegra-lib nvidiaPackages-l4t.tegra-lib
]; ];
}; };
boot.initrd.postDeviceCommands = '' boot.initrd.postDeviceCommands = ''
echo 0 > /sys/class/graphics/fb0/state echo 0 > /sys/class/graphics/fb0/state
''; '';
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (final: prev: {
xorg = prev.xorg.overrideScope (final': prev': { xorg = prev.xorg.overrideScope (
xorgserver = prev'.xorgserver.overrideAttrs (prevAttrs: { final': prev': {
version = "1.20.14"; xorgserver = prev'.xorgserver.overrideAttrs (prevAttrs: {
src = prev.fetchurl { version = "1.20.14";
url = "mirror://xorg/individual/xserver/xorg-server-1.20.14.tar.gz"; src = prev.fetchurl {
hash = "sha256-VLGZySgP+L8Pc6VKdZZFvQ7u2nJV0cmTENW3WV86wGY="; url = "mirror://xorg/individual/xserver/xorg-server-1.20.14.tar.gz";
}; hash = "sha256-VLGZySgP+L8Pc6VKdZZFvQ7u2nJV0cmTENW3WV86wGY=";
patches = prevAttrs.patches ++ [ };
# https://github.com/NixOS/nixpkgs/pull/147238 patches = prevAttrs.patches ++ [
(prev.fetchpatch { # https://github.com/NixOS/nixpkgs/pull/147238
name = "stdbool.patch"; (prev.fetchpatch {
url = "https://gitlab.freedesktop.org/xorg/xserver/-/commit/454b3a826edb5fc6d0fea3a9cfd1a5e8fc568747.diff"; name = "stdbool.patch";
sha256 = "1l9qg905jvlw3r0kx4xfw5m12pbs0782v2g3267d1m6q4m6fj1zy"; url = "https://gitlab.freedesktop.org/xorg/xserver/-/commit/454b3a826edb5fc6d0fea3a9cfd1a5e8fc568747.diff";
}) sha256 = "1l9qg905jvlw3r0kx4xfw5m12pbs0782v2g3267d1m6q4m6fj1zy";
]; })
}); ];
}); });
}) }
]; );
})
];
} }

View File

@@ -1,9 +1,9 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
{ {
hardware.firmware = with pkgs; [ hardware.firmware = with pkgs; [
config.boot.kernelPackages.kernel config.boot.kernelPackages.kernel
nvidiaPackages-l4t.tegra-firmware nvidiaPackages-l4t.tegra-firmware
]; ];
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
} }

View File

@@ -1,58 +1,60 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
set-alsa-config = (pkgs.writeShellScriptBin "set-alsa-config" '' set-alsa-config = (
${pkgs.alsa-utils}/bin/amixer -c1 cset name="I2S1 Sample Rate" 48000 pkgs.writeShellScriptBin "set-alsa-config" ''
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPK MIXL DAC L1 Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="I2S1 Sample Rate" 48000
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPK MIXR DAC R1 Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPK MIXL DAC L1 Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPOL MIX SPKVOL L Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPK MIXR DAC R1 Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPOR MIX SPKVOL R Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPOL MIX SPKVOL L Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker Channel Switch" on,on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x SPOR MIX SPKVOL R Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker L Playback Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker Channel Switch" on,on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker R Playback Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker L Playback Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Stereo DAC MIXL DAC L1 Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker R Playback Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Stereo DAC MIXR DAC R1 Switch" on ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Stereo DAC MIXL DAC L1 Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="I2S1 Mux" 1 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Stereo DAC MIXR DAC R1 Switch" on
${pkgs.alsa-utils}/bin/amixer -c1 cset name="ADMAIF1 Mux" 11 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="I2S1 Mux" 1
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 HP Playback Volume" 126,126 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="ADMAIF1 Mux" 11
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 Playback Volume" 126,126 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 HP Playback Volume" 126,126
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 Speaker Playback Volume" 126,126 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 Playback Volume" 126,126
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x HP Playback Volume" 0,0 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x DAC1 Speaker Playback Volume" 126,126
${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker Playback Volume" 35,35 ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x HP Playback Volume" 0,0
echo "Internal audio initialized." ${pkgs.alsa-utils}/bin/amixer -c1 cset name="x Speaker Playback Volume" 35,35
''); echo "Internal audio initialized."
in ''
);
in
{ {
environment.systemPackages = [ environment.systemPackages = [
set-alsa-config set-alsa-config
]; ];
services.pipewire = { services.pipewire = {
# package = pkgs.pipewire-with-tegra; # package = pkgs.pipewire-with-tegra;
wireplumber = { wireplumber = {
extraConfig = { extraConfig = {
tegra-nx = { tegra-nx = {
"monitor.alsa.rules" = [ "monitor.alsa.rules" = [
{ {
matches = [ matches = [
{ "device.nick" = "tegra-snd-t210ref-mobile-rt565x"; } { "device.nick" = "tegra-snd-t210ref-mobile-rt565x"; }
]; ];
actions = { actions = {
update-props = { update-props = {
"audio.format" = "S16LE"; "audio.format" = "S16LE";
"audio.rate" = 48000; "audio.rate" = 48000;
}; };
};
}
];
}; };
}; }
}; ];
};
systemd.services.tegra-speaker-init = {
wantedBy = [ "sound.target" ];
script = ''
${lib.getExe set-alsa-config}
'';
}; };
};
};
};
systemd.services.tegra-speaker-init = {
wantedBy = [ "sound.target" ];
script = ''
${lib.getExe set-alsa-config}
'';
};
} }

View File

@@ -1,5 +1,4 @@
inputs: inputs: {
{
imports = [ imports = [
./modules/boot.nix ./modules/boot.nix
./modules/graphics.nix ./modules/graphics.nix

View File

@@ -1,5 +1,4 @@
inputs: inputs: rec {
rec {
switchroot-nixos = import ./switchroot-nixos.nix inputs; switchroot-nixos = import ./switchroot-nixos.nix inputs;
default = switchroot-nixos; default = switchroot-nixos;
} }

View File

@@ -1,5 +1,4 @@
inputs: inputs: final: prev:
final: prev:
let let
callPackage' = prev.lib.callPackageWith (final // { inherit inputs; }); callPackage' = prev.lib.callPackageWith (final // { inherit inputs; });
alsa-lib = prev.alsa-lib.overrideAttrs (prev': { alsa-lib = prev.alsa-lib.overrideAttrs (prev': {
@@ -14,7 +13,8 @@ in
prev.lib.packagesFromDirectoryRecursive { prev.lib.packagesFromDirectoryRecursive {
callPackage = callPackage'; callPackage = callPackage';
directory = ../pkgs/by-name; directory = ../pkgs/by-name;
} // { }
// {
# alsa-lib = prev.alsa-lib.overrideAttrs (prev': { # alsa-lib = prev.alsa-lib.overrideAttrs (prev': {
# pname = "${prev'.pname}-with-tegra"; # pname = "${prev'.pname}-with-tegra";
# postInstall = '' # postInstall = ''
@@ -25,4 +25,3 @@ prev.lib.packagesFromDirectoryRecursive {
# }); # });
pipewire-with-tegra = prev.pipewire.override { inherit alsa-lib; }; pipewire-with-tegra = prev.pipewire.override { inherit alsa-lib; };
} }

View File

@@ -1,11 +1,13 @@
{ linuxPackagesFor {
, recurseIntoAttrs linuxPackagesFor,
, linux_4_9-l4t recurseIntoAttrs,
linux_4_9-l4t,
}: }:
let let
packages = recurseIntoAttrs (linuxPackagesFor linux_4_9-l4t); packages = recurseIntoAttrs (linuxPackagesFor linux_4_9-l4t);
crossCompiledPackages = recurseIntoAttrs (linuxPackagesFor linux_4_9-l4t.cross-compiled); crossCompiledPackages = recurseIntoAttrs (linuxPackagesFor linux_4_9-l4t.cross-compiled);
in in
packages // { packages
// {
cross-compiled = crossCompiledPackages; cross-compiled = crossCompiledPackages;
} }

View File

@@ -1,82 +1,87 @@
{ sources {
, callPackage sources,
, inputs callPackage,
, buildLinux inputs,
, fetchurl buildLinux,
, lib fetchurl,
lib,
, ... ...
} @ args: }@args:
buildLinux (args // rec { buildLinux (
version = "4.9.140-l4t"; args
modDirVersion = version; // rec {
src = "${sources.combined-src}/kernel"; version = "4.9.140-l4t";
modDirVersion = version;
enableCommonConfig = false; src = "${sources.combined-src}/kernel";
defconfig = "tegra_linux_defconfig";
structuredExtraConfig = with lib.kernel; {
AHCI_TEGRA = no;
BATTERY_BQ27441 = no;
BLK_DEV_DRBD = no;
BLK_DEV_PCIESSD_MTIP32XX = no;
BT_HCIBFUSB = no;
BT_HCIBPA10X = no;
BT_HCIUART_NOKIA = no;
BT_HCIVHCI = no;
BT_MRVL = no;
BT_MTKUART = no;
CPU_IDLE_TEGRA19X = no;
CRYPTO_LRW = no;
DRM_NOUVEAU = no;
DRM_TEGRA = no;
EVENTLIB = no;
EXTCON_ADC_JACK = no;
HMM_DMIRROR = no;
I2C_TEGRA194_SLAVE = no;
INV_ICM42600_I2C = no;
MTTCAN = no;
MTTCAN_IVC = no;
NVI_MPU_IIO = no;
NVI_MPU_INPUT = no;
NVI_MPU_RELAY = no;
NVS = no;
NVS_BMI160_IIO = no;
NVS_BMI160_INPUT = no;
NVS_BMI160_RELAY = no;
NVS_LED_TEST = no;
PCIE_TEGRA = no;
PWM_TEGRA_DFLL = no;
QCOM_SPMI_IADC = no;
QCOM_SPMI_TEMP_ALARM = no;
QCOM_SPMI_VADC = no;
REGULATOR_TPS61280 = no;
RTC_DRV_RX6110 = no;
SCSI_UFSHCD = no;
SND_SOC_TEGRA = no;
SND_SOC_TEGRA_T210REF_ALT = no;
SND_SOC_TEGRA_T210REF_P2382_ALT = no;
TEGRA_BOOTLOADER_BOOT_CFG = no;
TEGRA_HOST1X = no;
SND_SOC_TEGRA210_IQC_ALT = yes; enableCommonConfig = false;
# SND_SOC_TEGRA210_ADSP_ALT = no; defconfig = "tegra_linux_defconfig";
SND_SOC_TEGRA_T186REF_ALT = no; structuredExtraConfig = with lib.kernel; {
}; AHCI_TEGRA = no;
kernelPatches = [ BATTERY_BQ27441 = no;
{ BLK_DEV_DRBD = no;
name = "01-unify_l4t_sources.patch"; BLK_DEV_PCIESSD_MTIP32XX = no;
patch = fetchurl { BT_HCIBFUSB = no;
url = "https://raw.githubusercontent.com/libretro/Lakka-LibreELEC/refs/heads/devel/projects/L4T/devices/Switch/patches/l4t-kernel-sources/01-unify_l4t_sources.patch"; BT_HCIBPA10X = no;
hash = "sha256-RQPFgWWeDJNceKYGJ7bu/ElIyIU1uf2hf3KkUzTsjLE="; BT_HCIUART_NOKIA = no;
}; BT_HCIVHCI = no;
} BT_MRVL = no;
{ BT_MTKUART = no;
name = "02-set_kcflags.patch"; CPU_IDLE_TEGRA19X = no;
patch = ./patches/02-set_kcflags.patch; CRYPTO_LRW = no;
} DRM_NOUVEAU = no;
{ DRM_TEGRA = no;
name = "03-add_dtbs_install_target.patch"; EVENTLIB = no;
patch = ./patches/03-add_dtbs_install_target.patch; EXTCON_ADC_JACK = no;
} HMM_DMIRROR = no;
]; I2C_TEGRA194_SLAVE = no;
} // (args.argsOverride or {})) INV_ICM42600_I2C = no;
MTTCAN = no;
MTTCAN_IVC = no;
NVI_MPU_IIO = no;
NVI_MPU_INPUT = no;
NVI_MPU_RELAY = no;
NVS = no;
NVS_BMI160_IIO = no;
NVS_BMI160_INPUT = no;
NVS_BMI160_RELAY = no;
NVS_LED_TEST = no;
PCIE_TEGRA = no;
PWM_TEGRA_DFLL = no;
QCOM_SPMI_IADC = no;
QCOM_SPMI_TEMP_ALARM = no;
QCOM_SPMI_VADC = no;
REGULATOR_TPS61280 = no;
RTC_DRV_RX6110 = no;
SCSI_UFSHCD = no;
SND_SOC_TEGRA = no;
SND_SOC_TEGRA_T210REF_ALT = no;
SND_SOC_TEGRA_T210REF_P2382_ALT = no;
TEGRA_BOOTLOADER_BOOT_CFG = no;
TEGRA_HOST1X = no;
SND_SOC_TEGRA210_IQC_ALT = yes;
# SND_SOC_TEGRA210_ADSP_ALT = no;
SND_SOC_TEGRA_T186REF_ALT = no;
};
kernelPatches = [
{
name = "01-unify_l4t_sources.patch";
patch = fetchurl {
url = "https://raw.githubusercontent.com/libretro/Lakka-LibreELEC/refs/heads/devel/projects/L4T/devices/Switch/patches/l4t-kernel-sources/01-unify_l4t_sources.patch";
hash = "sha256-RQPFgWWeDJNceKYGJ7bu/ElIyIU1uf2hf3KkUzTsjLE=";
};
}
{
name = "02-set_kcflags.patch";
patch = ./patches/02-set_kcflags.patch;
}
{
name = "03-add_dtbs_install_target.patch";
patch = ./patches/03-add_dtbs_install_target.patch;
}
];
}
// (args.argsOverride or { })
)

View File

@@ -1,22 +1,24 @@
{ callPackage {
, system callPackage,
, inputs system,
inputs,
, ... ...
} @ args: }@args:
let let
sources = callPackage ./sources.nix {}; sources = callPackage ./sources.nix { };
kernel = callPackage ./kernel.nix ({ inherit sources; } // args); kernel = callPackage ./kernel.nix ({ inherit sources; } // args);
kernelCross = kernelCross =
let let
pkgsCross = import inputs.nixpkgs { pkgsCross = import inputs.nixpkgs {
localSystem = "x86_64-linux"; localSystem = "x86_64-linux";
crossSystem = system; crossSystem = system;
}; };
in in
pkgsCross.callPackage ./kernel.nix ({ inherit sources; } // args); pkgsCross.callPackage ./kernel.nix ({ inherit sources; } // args);
in in
kernel // { kernel
cross-compiled = kernelCross; // {
} cross-compiled = kernelCross;
# sources.combined-src }
# sources.combined-src

View File

@@ -1,6 +1,7 @@
{ fetchFromGitHub {
, fetchFromGitLab fetchFromGitHub,
, runCommand fetchFromGitLab,
runCommand,
}: }:
let let
kernel_rev = "linux-dev"; kernel_rev = "linux-dev";
@@ -8,7 +9,8 @@ let
nx_rev = "linux-dev"; nx_rev = "linux-dev";
nv_rev = "linux-dev"; nv_rev = "linux-dev";
nvgpu_rev = "linux-3.4.0-r32.5"; nvgpu_rev = "linux-3.4.0-r32.5";
in rec { in
rec {
# https://github.com/theofficialgman/l4t-image-buildscripts # https://github.com/theofficialgman/l4t-image-buildscripts
# kernel sources # kernel sources
switch-l4t-kernel-4_9-src = fetchFromGitHub { switch-l4t-kernel-4_9-src = fetchFromGitHub {
@@ -68,7 +70,7 @@ in rec {
hash = "sha256-sEZ51GyLvtS8pYP3jxATZDCJ7mpUI02VL3zFeWN1w1M="; hash = "sha256-sEZ51GyLvtS8pYP3jxATZDCJ7mpUI02VL3zFeWN1w1M=";
}; };
combined-src = runCommand "combined-src" {} '' combined-src = runCommand "combined-src" { } ''
mkdir -p $out/kernel mkdir -p $out/kernel
cp --no-preserve=mode -r ${switch-l4t-kernel-4_9-src}/* $out/kernel/ cp --no-preserve=mode -r ${switch-l4t-kernel-4_9-src}/* $out/kernel/
sed -i 's/\/bin\/pwd/pwd/' $out/kernel/Makefile sed -i 's/\/bin\/pwd/pwd/' $out/kernel/Makefile

View File

@@ -1,7 +1,8 @@
{ config {
, runCommand config,
runCommand,
}: }:
runCommand "nvidia-l4t-alsa-config" {} '' runCommand "nvidia-l4t-alsa-config" { } ''
mkdir -p -p $out/share mkdir -p -p $out/share
ln -s ${config}/usr/share/alsa $out/share/ ln -s ${config}/usr/share/alsa $out/share/
'' ''

View File

@@ -1,6 +1,6 @@
{ callPackage }: { callPackage }:
let let
sources = callPackage ./sources.nix {}; sources = callPackage ./sources.nix { };
tegra-lib = callPackage ./tegra-lib.nix { tegra-lib = callPackage ./tegra-lib.nix {
inherit (sources) nvidia-drivers; inherit (sources) nvidia-drivers;
}; };

View File

@@ -1,5 +1,6 @@
{ fetchzip {
, runCommand fetchzip,
runCommand,
}: }:
let let
# https://developer.nvidia.com/embedded/l4t-3231-archive # https://developer.nvidia.com/embedded/l4t-3231-archive
@@ -8,27 +9,36 @@ let
url = "https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/t210ref_release_aarch64/Tegra210_Linux_R32.3.1_aarch64.tbz2"; url = "https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/t210ref_release_aarch64/Tegra210_Linux_R32.3.1_aarch64.tbz2";
hash = "sha256-UfPjgonDPMhxQMp/tlwo9NODIDd6rmXfwFJGNarQyMk="; hash = "sha256-UfPjgonDPMhxQMp/tlwo9NODIDd6rmXfwFJGNarQyMk=";
}; };
nvidia-drivers = runCommand "nvidia_drivers" { nvidia-drivers =
passthru.version = version; runCommand "nvidia_drivers"
} '' {
mkdir $out passthru.version = version;
cd $out }
tar -xjf ${driver-package}/nv_tegra/nvidia_drivers.tbz2 ''
''; mkdir $out
nv-tools = runCommand "nvidia_tools" { cd $out
passthru.version = version; tar -xjf ${driver-package}/nv_tegra/nvidia_drivers.tbz2
} '' '';
mkdir $out nv-tools =
cd $out runCommand "nvidia_tools"
tar -xjf ${driver-package}/nv_tegra/nv_tools.tbz2 {
''; passthru.version = version;
config = runCommand "config" { }
passthru.version = version; ''
} '' mkdir $out
mkdir $out cd $out
cd $out tar -xjf ${driver-package}/nv_tegra/nv_tools.tbz2
tar -xjf ${driver-package}/nv_tegra/config.tbz2 '';
''; config =
runCommand "config"
{
passthru.version = version;
}
''
mkdir $out
cd $out
tar -xjf ${driver-package}/nv_tegra/config.tbz2
'';
in in
{ {
inherit inherit

View File

@@ -1,7 +1,8 @@
{ nvidia-drivers {
, runCommand nvidia-drivers,
runCommand,
}: }:
runCommand "nvidia-l4t-tegra-firmware" {} '' runCommand "nvidia-l4t-tegra-firmware" { } ''
mkdir -p $out mkdir -p $out
cp --no-preserve=mode -r ${nvidia-drivers}/lib $out/ cp --no-preserve=mode -r ${nvidia-drivers}/lib $out/
cd $out/lib/firmware/gm20b cd $out/lib/firmware/gm20b

View File

@@ -1,19 +1,20 @@
{ nvidia-drivers {
, runCommand nvidia-drivers,
, writers runCommand,
, stdenv writers,
, autoPatchelfHook stdenv,
, libgcc autoPatchelfHook,
, libglvnd libgcc,
, glib libglvnd,
, alsa-lib glib,
, cairo alsa-lib,
, pango cairo,
, gtk3 pango,
, libv4l gtk3,
, gst_all_1 libv4l,
, wayland-scanner gst_all_1,
, egl-wayland wayland-scanner,
egl-wayland,
}: }:
let let
library-files = stdenv.mkDerivation { library-files = stdenv.mkDerivation {
@@ -71,11 +72,11 @@ let
library_path = "${library-files}/lib/libEGL_nvidia.so.0"; library_path = "${library-files}/lib/libEGL_nvidia.so.0";
}; };
}; };
combined-files = runCommand "nvidia-l4t-tegra-lib-${nvidia-drivers.version}" {} '' combined-files = runCommand "nvidia-l4t-tegra-lib-${nvidia-drivers.version}" { } ''
mkdir -p $out/share/{glvnd/egl_vendor.d,vulkan/icd.d} mkdir -p $out/share/{glvnd/egl_vendor.d,vulkan/icd.d}
ln -s ${library-files}/lib $out/ ln -s ${library-files}/lib $out/
ln -s ${nvidia-json} $out/share/glvnd/egl_vendor.d/nvidia.json ln -s ${nvidia-json} $out/share/glvnd/egl_vendor.d/nvidia.json
ln -s ${nvidia-icd-json} $out/share/vulkan/icd.d/nvidia_icd.json ln -s ${nvidia-icd-json} $out/share/vulkan/icd.d/nvidia_icd.json
''; '';
in in
combined-files combined-files

View File

@@ -1,6 +1,7 @@
{ nv-tools {
, stdenv nv-tools,
, autoPatchelfHook stdenv,
autoPatchelfHook,
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "nvidia-l4t-tools"; name = "nvidia-l4t-tools";

View File

@@ -1,7 +1,8 @@
{ config {
, runCommand config,
runCommand,
}: }:
runCommand "nvidia-l4t-udev-rules" {} '' runCommand "nvidia-l4t-udev-rules" { } ''
mkdir -p $out/etc/udev/rules.d mkdir -p $out/etc/udev/rules.d
cp ${config}/etc/udev/rules.d/99-tegra-devices.rules $out/etc/udev/rules.d/ cp ${config}/etc/udev/rules.d/99-tegra-devices.rules $out/etc/udev/rules.d/
sed '/\/usr\/sbin\/camera_device_detect/d' -i $out/etc/udev/rules.d/99-tegra-devices.rules sed '/\/usr\/sbin\/camera_device_detect/d' -i $out/etc/udev/rules.d/99-tegra-devices.rules

View File

@@ -1,10 +1,11 @@
{ nvidia-drivers {
, runCommand nvidia-drivers,
runCommand,
, tegra-lib tegra-lib,
, iconv iconv,
}: }:
runCommand "nvidia-l4t-x11-module" {} '' runCommand "nvidia-l4t-x11-module" { } ''
mkdir -p $out/lib mkdir -p $out/lib
cp --no-preserve=mode -r ${nvidia-drivers}/usr/lib/xorg $out/lib cp --no-preserve=mode -r ${nvidia-drivers}/usr/lib/xorg $out/lib
patchelf \ patchelf \

View File

@@ -1,9 +1,10 @@
{ toplevel {
toplevel,
, writeTextFile writeTextFile,
, runCommand runCommand,
, writeShellApplication writeShellApplication,
, ubootTools ubootTools,
}: }:
let let
boot-cmd-main = writeTextFile { boot-cmd-main = writeTextFile {
@@ -430,10 +431,13 @@ let
mkimage -A arm64 -C none -T script -d "$boot_scr" "$OUT" mkimage -A arm64 -C none -T script -d "$boot_scr" "$OUT"
''; '';
}; };
boot-scr = runCommand "boot.scr" { boot-scr =
passthru.buildScript = build-boot-scr; runCommand "boot.scr"
} '' {
${build-boot-scr}/bin/build-boot-scr ${toplevel} $out passthru.buildScript = build-boot-scr;
''; }
''
${build-boot-scr}/bin/build-boot-scr ${toplevel} $out
'';
in in
boot-scr boot-scr

View File

@@ -1,8 +1,9 @@
{ kernel {
, runCommand kernel,
, android-tools runCommand,
android-tools,
}: }:
runCommand "nx-plat.dtimg" {} '' runCommand "nx-plat.dtimg" { } ''
${android-tools}/bin/mkdtboimg create $out --page_size=1000 \ ${android-tools}/bin/mkdtboimg create $out --page_size=1000 \
${kernel}/dtbs/tegra210-odin.dtb --id=0x4F44494E \ ${kernel}/dtbs/tegra210-odin.dtb --id=0x4F44494E \
${kernel}/dtbs/tegra210b01-odin.dtb --id=0x4F44494E --rev=0xb01 \ ${kernel}/dtbs/tegra210b01-odin.dtb --id=0x4F44494E --rev=0xb01 \

View File

@@ -1,15 +1,16 @@
{ pkgs {
, inputs pkgs,
, runCommand inputs,
, imagemagick runCommand,
imagemagick,
}: }:
let let
# icons = (import inputs.nixos-artwork { inherit pkgs; }).icons; # icons = (import inputs.nixos-artwork { inherit pkgs; }).icons;
base-svg = "${inputs.nixos-artwork}/logo/nix-snowflake-rainbow.svg"; base-svg = "${inputs.nixos-artwork}/logo/nix-snowflake-rainbow.svg";
icon-bmp = runCommand "icon.bmp" {} '' icon-bmp = runCommand "icon.bmp" { } ''
${imagemagick}/bin/magick \ ${imagemagick}/bin/magick \
${base-svg} -channel rgba -alpha on -resize 192x192 \ ${base-svg} -channel rgba -alpha on -resize 192x192 \
BMP3:$out BMP3:$out
''; '';
in in
icon-bmp icon-bmp

View File

@@ -1,11 +1,12 @@
{ callPackage {
, runCommand callPackage,
, writeShellApplication runCommand,
, closureInfo writeShellApplication,
, inputs closureInfo,
inputs,
, rsync rsync,
, openssh openssh,
}: }:
{ {
kernel, kernel,
@@ -50,28 +51,40 @@ let
''; '';
}; };
switchroot-boot = runCommand "switchroot-boot" { switchroot-boot =
passthru = { runCommand "switchroot-boot"
inherit icon uInitrd uImage boot-scr dtb-image; {
}; passthru = {
} '' inherit
mkdir -p $out icon
uInitrd
uImage
boot-scr
dtb-image
;
};
}
''
mkdir -p $out
cp ${icon} $out/icon.bmp cp ${icon} $out/icon.bmp
cp ${uInitrd} $out/initramfs cp ${uInitrd} $out/initramfs
cp ${uImage} $out/uImage cp ${uImage} $out/uImage
cp ${boot-scr} $out/boot.scr cp ${boot-scr} $out/boot.scr
cp ${dtb-image} $out/nx-plat.dtimg cp ${dtb-image} $out/nx-plat.dtimg
''; '';
package = runCommand "switchroot-pkg" { package =
passthru.boot = switchroot-boot; runCommand "switchroot-pkg"
} '' {
mkdir -p $out/{misc,switchroot} passthru.boot = switchroot-boot;
ln -s ${closure-info} $out/misc/closure-info }
ln -s ${copy-closure}/bin/copy-closure-to $out/misc/ ''
ln -s ${copy-via-ssh}/bin/copy-via-ssh $out/misc/ mkdir -p $out/{misc,switchroot}
ln -s ${switchroot-boot} $out/switchroot/nixos ln -s ${closure-info} $out/misc/closure-info
''; ln -s ${copy-closure}/bin/copy-closure-to $out/misc/
ln -s ${copy-via-ssh}/bin/copy-via-ssh $out/misc/
ln -s ${switchroot-boot} $out/switchroot/nixos
'';
in in
package package

View File

@@ -1,14 +1,15 @@
{ kernel {
, ubootTools kernel,
, gzip ubootTools,
, runCommand gzip,
runCommand,
}: }:
let let
image-gz = runCommand "Image.gz" {} '' image-gz = runCommand "Image.gz" { } ''
${gzip}/bin/gzip -c ${kernel}/Image > $out ${gzip}/bin/gzip -c ${kernel}/Image > $out
''; '';
uimage = runCommand "uImage" {} '' uimage = runCommand "uImage" { } ''
${ubootTools}/bin/mkimage -A arm64 -a 0x80200000 -e 0x80200000 -n "NixOS kernel" -d ${image-gz} $out ${ubootTools}/bin/mkimage -A arm64 -a 0x80200000 -e 0x80200000 -n "NixOS kernel" -d ${image-gz} $out
''; '';
in in
uimage uimage

View File

@@ -1,8 +1,9 @@
{ initialRamdisk {
, ubootTools initialRamdisk,
, runCommand ubootTools,
runCommand,
}: }:
runCommand "uInitrd" {} '' runCommand "uInitrd" { } ''
initrdFile="${initialRamdisk}/initrd" initrdFile="${initialRamdisk}/initrd"
${ubootTools}/bin/mkimage -A arm64 -T ramdisk -C gzip -n "NixOS initrd" -d $initrdFile $out ${ubootTools}/bin/mkimage -A arm64 -T ramdisk -C gzip -n "NixOS initrd" -d $initrdFile $out
'' ''

View File

@@ -1,4 +1,4 @@
{ nixpkgs, ... } @ inputs: { nixpkgs, ... }@inputs:
let let
supportedSystems = [ supportedSystems = [
"aarch64-linux" "aarch64-linux"
@@ -10,7 +10,8 @@ let
packagesFromDirectoryRecursive packagesFromDirectoryRecursive
callPackageWith callPackageWith
; ;
pkgsForSystem = system: pkgsForSystem =
system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
# inherit system; # inherit system;
@@ -25,16 +26,12 @@ let
directory = ./by-name; directory = ./by-name;
}; };
in in
localPkgs; localPkgs;
pkgsSets = pkgsSets = listToAttrs (
listToAttrs map (system: {
( name = system;
map value = pkgsForSystem system;
(system: { }) supportedSystems
name = system; );
value = pkgsForSystem system;
})
supportedSystems
);
in in
pkgsSets pkgsSets