diff --git a/base.nix b/base.nix index 8cb1c65..c63c7a2 100644 --- a/base.nix +++ b/base.nix @@ -12,8 +12,6 @@ boot.tmp.cleanOnBoot = true; - boot.loader.generic-extlinux-compatible.enable = false; - # Set root password to a secure password users.users.root.password = "asecurepassword"; @@ -36,8 +34,6 @@ networking.hostName = "kiosk"; time.timeZone = "America/New_York"; - raspberry-pi-nix.board = "bcm2711"; - environment.systemPackages = with pkgs; [ vim git diff --git a/flake.nix b/flake.nix index d6f5c7a..4b2c1db 100644 --- a/flake.nix +++ b/flake.nix @@ -7,24 +7,27 @@ nixos-hardware.url = "github:NixOS/nixos-hardware"; }; - outputs = { nixpkgs, rpi-nix, nixos-hardware, ... }: { - - nixosConfigurations.kiosk = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ - ./base.nix - ./kiosk.nix + outputs = inputs@{ nixpkgs, rpi-nix, nixos-hardware, ... }: + let + rpi = [ ./sd-image - rpi-nix.nixosModules.raspberry-pi - nixos-hardware.nixosModules.raspberry-pi-4 - ({ lib, pkgs, ... }: { - sdImage.compressImage = false; - - nixpkgs.buildPlatform = "x86_64-linux"; - boot.kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_rpi4; - }) ]; + mkKiosk = system: modules: nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit inputs; }; + modules = nixpkgs.lib.flatten modules ++ [ + ./base.nix + ./kiosk.nix + ]; + + }; + in + { + nixosConfigurations = { + kiosk-rpi3 = mkKiosk "aarch64-linux" [ rpi ./rpi3.nix ]; + kiosk-rpi4 = mkKiosk "aarch64-linux" [ rpi ./rpi4.nix ]; + pc = mkKiosk "x86_64-linux" [ ./pc.nix ]; + }; }; - }; } diff --git a/rpi3.nix b/rpi3.nix new file mode 100644 index 0000000..f811e1a --- /dev/null +++ b/rpi3.nix @@ -0,0 +1,13 @@ +{ inputs, lib, pkgs, ... }: +{ + imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-3 + ]; + + nixpkgs.buildPlatform = "x86_64-linux"; + + boot.kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_rpi3; + + raspberry-pi-nix.board = "bcm2711"; + raspberry-pi-nix.uboot.enable = true; +} diff --git a/rpi4.nix b/rpi4.nix new file mode 100644 index 0000000..5a54471 --- /dev/null +++ b/rpi4.nix @@ -0,0 +1,30 @@ +{ inputs, lib, pkgs, ... }: +{ + imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 + ]; + + nixpkgs.buildPlatform = "x86_64-linux"; + + raspberry-pi-nix.board = "bcm2711"; + + boot.kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_rpi4; + + # nixos-hardware and raspberry-pi-nix conflict, set explicitly + boot.loader.generic-extlinux-compatible.enable = false; + + boot.extraModprobeConfig = '' + options snd_bcm2835 enable_headphones=1 enable_hdmi=1 enable_compat_alsa=0 + ''; + + hardware.raspberry-pi."4" = { + fkms-3d.enable = true; + }; + + hardware.raspberry-pi.config.all.base-dt-params = { + audio = { + enable = true; + value = true; + }; + }; +}