Generalise machine definitions, fix pi4 config

This commit is contained in:
Erwin Boskma 2022-10-13 14:14:30 +02:00
parent 68b5d1d151
commit 31c676eabd
Signed by: erwin
GPG key ID: 02C3C0D914C0012B
6 changed files with 67 additions and 74 deletions

View file

@ -71,6 +71,7 @@
, ... , ...
} @ inputs: } @ inputs:
with inputs; let with inputs; let
machines = import ./machines inputs;
defSystem = system: baseConfig: defSystem = system: baseConfig:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
system = "${system}"; system = "${system}";
@ -87,7 +88,11 @@
self.overlays.default self.overlays.default
ha-now-playing.overlays.${system} ha-now-playing.overlays.${system}
pamedia.overlays.${system} pamedia.overlays.${system}
]; ] ++ nixpkgs.lib.optional (system == "aarch64-linux")
(final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
});
} }
baseConfig baseConfig
@ -104,6 +109,7 @@
}; };
in in
{ {
overlays.default = import ./overlays; overlays.default = import ./overlays;
# overlay = final: prev: { # overlay = final: prev: {
# unstable = import nixpkgs { # unstable = import nixpkgs {
@ -119,59 +125,18 @@
}) })
(builtins.attrNames (builtins.readDir ./modules))); (builtins.attrNames (builtins.readDir ./modules)));
nixosConfigurations = { inherit machines;
vm1 = defSystem "x86_64-linux" {
imports = [
(import ./machines/vm1/configuration.nix { inherit self; })
];
};
vm2 = defSystem "x86_64-linux" {
imports = [
(import ./machines/vm2/configuration.nix { inherit self; })
];
};
loki = defSystem "x86_64-linux" { nixosConfigurations = builtins.listToAttrs (map
(machine: {
name = machine;
value = (defSystem (machines.${machine}.system or "x86_64-linux") {
imports = [ imports = [
(import ./machines/loki/configuration.nix { inherit self nixpkgs; }) machines.${machine}.config
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-gpu-amd
nixos-hardware.nixosModules.common-pc-ssd
]; ];
}; });
})
drone = defSystem "x86_64-linux" { (builtins.attrNames machines));
imports = [
(import ./machines/drone/configuration.nix { inherit self; })
];
};
proxy = defSystem "x86_64-linux" {
imports = [
(import ./machines/proxy/configuration.nix { inherit self; })
];
};
gitea = defSystem "x86_64-linux" {
imports = [
(import ./machines/gitea/configuration.nix { inherit self; })
];
};
heimdall = defSystem "x86_64-linux" {
imports = [
(import ./machines/heimdall/configuration.nix { inherit self; })
];
};
eitri = defSystem "aarch64-linux" {
imports = [
(import ./machines/eitri/configuration.nix { inherit self nixpkgs; })
nixos-hardware.nixosModules.raspberry-pi-4
];
};
};
} }
// (flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ]) // (flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ])
( (

27
machines/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ ... }@inputs: {
drone = {
config = (import ./drone/configuration.nix inputs);
};
eitri = {
system = "aarch64-linux";
config = (import ./eitri/configuration.nix inputs);
};
gitea = {
config = (import ./gitea/configuration.nix inputs);
};
heimdall = {
config = (import ./heimdall/configuration.nix inputs);
};
loki = {
config = (import ./loki/configuration.nix inputs);
};
proxy = {
config = (import ./proxy/configuration.nix inputs);
};
vm1 = {
config = (import ./vm1/configuration.nix inputs);
};
vm2 = {
config = (import ./vm2/configuration.nix inputs);
};
}

View file

@ -1,9 +1,12 @@
{ self, nixpkgs, ... }: { self, nixpkgs, nixos-hardware, ... }:
let let
pkgs = import nixpkgs { system = "aarch64-linux"; }; pkgs = import nixpkgs {
system = "aarch64-linux";
};
in in
{ {
imports = [ imports = [
nixos-hardware.nixosModules.raspberry-pi-4
../../users/root ../../users/root
../../users/erwin ../../users/erwin
]; ];
@ -12,6 +15,7 @@ in
users.erwin = { users.erwin = {
enable = true; enable = true;
}; };
base.kernel = pkgs.linuxPackages_rpi4;
desktop.enable = true; desktop.enable = true;
fonts.enable = true; fonts.enable = true;
gnome.enable = true; gnome.enable = true;
@ -22,14 +26,6 @@ in
systemd.enable = true; systemd.enable = true;
}; };
boot = {
loader.raspberryPi = {
enable = true;
version = 4;
};
loader.generic-extlinux-compatible.enable = nixpkgs.lib.mkForce false;
};
hardware = { hardware = {
enableRedistributableFirmware = true; enableRedistributableFirmware = true;
raspberry-pi."4" = { raspberry-pi."4" = {

View file

@ -1,9 +1,18 @@
{ self, nixpkgs, ... }: { self, nixpkgs, nixos-hardware, ... }:
let let
pkgs = import nixpkgs { system = "x86_64-linux"; }; pkgs = import nixpkgs { system = "x86_64-linux"; };
in in
{ {
imports = [ ./hardware-configuration.nix ../../users/erwin ../../users/root ../../users/builder ]; imports = [
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-gpu-amd
nixos-hardware.nixosModules.common-pc-ssd
./hardware-configuration.nix
../../users/erwin
../../users/root
../../users/builder
];
eboskma = { eboskma = {
users = { users = {

View file

@ -1,16 +1,9 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config { config
, lib , lib
, pkgs , pkgs
, modulesPath , modulesPath
, ... , ...
}: { }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" "apple-mfi-fastcharge" "zenpower" "nf_nat_ftp" ]; boot.kernelModules = [ "kvm-amd" "apple-mfi-fastcharge" "zenpower" "nf_nat_ftp" ];
@ -37,4 +30,7 @@
# high-resolution display # high-resolution display
hardware.video.hidpi.enable = lib.mkDefault true; hardware.video.hidpi.enable = lib.mkDefault true;
# Enable firmware
hardware.enableAllFirmware = true;
} }

View file

@ -13,7 +13,7 @@ in
cross-systems = mkOption { cross-systems = mkOption {
description = "list of systems to cross compile for"; description = "list of systems to cross compile for";
type = with types; listOf str; type = with types; listOf str;
default = []; default = [ ];
}; };
}; };