proof of concept

master
Astro 12 months ago
commit b54958b99b
  1. 43
      flake.lock
  2. 46
      flake.nix
  3. 56
      modules/defaults.nix
  4. 20
      modules/minetest.nix
  5. 50
      modules/pi.nix
  6. 7
      modules/pi4.nix

@ -0,0 +1,43 @@
{
"nodes": {
"nixos-hardware": {
"locked": {
"lastModified": 1632990363,
"narHash": "sha256-SNqz+9Vt4yDHqw8u/CMFdzMQTulKoMlVGJdshfcb5O0=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "0a8b8054c9920368a3c15e6d766188fdf04b736f",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1633550479,
"narHash": "sha256-LG9m2A3UMsFGEaY4XL2xqD7gGVTeeYiskjBbubCV9/4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b8f6eb7300e60a9c3b505ec381d0eab9029203e8",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-21.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

@ -0,0 +1,46 @@
{
description = "Image builder for RaspberryPi";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-21.05";
nixos-hardware.url = "github:nixos/nixos-hardware";
};
outputs = { self, nixpkgs, nixos-hardware }: {
nixosModules = {
defaults = import ./modules/defaults.nix;
pi = import ./modules/pi.nix;
pi4 = import ./modules/pi4.nix;
minetest = import ./modules/minetest.nix;
};
nixosConfigurations = {
pi4-minetest = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = with self.nixosModules; [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
nixos-hardware.nixosModules.raspberry-pi-4
defaults pi pi4 minetest
];
};
};
packages =
let
systems =
map (nixos:
nixos.config.system.build.toplevel.system
) (builtins.attrValues self.nixosConfigurations);
in builtins.foldl' (result: system: result // {
"${system}" = nixpkgs.lib.mapAttrs (_: nixos:
nixos.config.system.build.sdImage
) (
nixpkgs.lib.filterAttrs (_: nixos:
nixos.config.system.build.toplevel.system == system
) self.nixosConfigurations
);
}) {} systems;
};
}

@ -0,0 +1,56 @@
{ pkgs, ... }:
{
nix = {
buildCores = 4;
maxJobs = 2;
};
networking = {
useDHCP = false;
interfaces.eth0.useDHCP = true;
firewall.enable = false;
};
security.sudo = {
enable = true;
wheelNeedsPassword = false;
};
users.users.pi = {
isNormalUser = true;
extraGroups = [ "wheel" "audio" "video" ];
initialPassword = "";
};
# Select internationalisation properties.
console = {
font = "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";
keyMap = "de";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver.layout = "de";
services.xserver.xkbOptions = "eurosign:e";
services.xserver.displayManager = {
lightdm = { enable = true; };
autoLogin = {
enable = true;
user = "pi";
};
};
services.xserver.desktopManager = {
xfce.enable = true;
};
documentation = {
enable = false;
dev.enable = false;
doc.enable = false;
info.enable = false;
man.enable = false;
nixos.enable = false;
};
system.stateVersion = "21.05";
}

@ -0,0 +1,20 @@
{ pkgs, ... }:
{
networking.hostName = "minetest";
environment.systemPackages = with pkgs; [
minetest
];
nixpkgs.config.packageOverrides = pkgs: {
irrlicht = pkgs.irrlicht.overrideAttrs (oa: {
CPPFLAGS="-DPNG_ARM_NEON_OPT=0";
buildPhase = ''
make -j$NIX_BUILD_CORES sharedlib NDEBUG=1 "LDFLAGS=-lX11 -lGL -lXxf86vm"
'';
});
minetest = pkgs.minetest.overrideAttrs (oa: {
enableParallelBuilding = true;
});
};
}

@ -0,0 +1,50 @@
{ pkgs, config, lib, ... }:
{
sdImage = {
compressImage = false;
imageBaseName = config.networking.hostName;
firmwareSize = 64;
};
boot = {
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = lib.mkDefault true;
raspberryPi = {
enable = true;
uboot.enable = true;
firmwareConfig = ''
gpu_mem=192
dtparam=audio=on
'';
};
};
kernelPackages = pkgs."linuxPackages_rpi${toString config.boot.loader.raspberryPi.version}";
kernelParams = [
"snd_bcm2835.enable_headphones=1"
];
# Don't build ZFS for aarch64 (broken?)
supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
# Work around missing sun4i-drm.ko
initrd.availableKernelModules = lib.mkForce [ "vc4" ];
tmpOnTmpfs = true;
};
hardware.deviceTree = {
enable = true;
kernelPackage = config.boot.kernelPackages.kernel;
};
hardware.enableRedistributableFirmware = true;
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
environment.systemPackages = with pkgs; [
libraspberrypi
raspberrypi-eeprom
];
# Do not log to sdcard:
services.journald.extraConfig = ''
Storage=volatile
'';
}

@ -0,0 +1,7 @@
{ pkgs, ... }:
{
boot.loader.raspberryPi.version = 4;
hardware.raspberry-pi."4" = {
fkms-3d.enable = true;
};
}
Loading…
Cancel
Save