2023-12-09 02:12:40 +00:00
|
|
|
{
|
|
|
|
inputs = {
|
2023-12-09 05:35:03 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/release-23.11";
|
2023-12-09 02:12:40 +00:00
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, utils }:
|
2023-12-09 05:35:03 +00:00
|
|
|
let
|
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
inherit (nixpkgs) lib;
|
2023-12-09 02:12:40 +00:00
|
|
|
in (utils.lib.eachSystem supportedSystems (system:
|
2023-12-09 03:23:19 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
makeImage = conf:
|
|
|
|
(conf.extendModules {
|
2023-12-09 05:35:03 +00:00
|
|
|
modules = [{ config.nixpkgs.buildPlatform.system = system; }];
|
2023-12-09 03:23:19 +00:00
|
|
|
}).config.system.build.sdImage;
|
2023-12-09 02:12:40 +00:00
|
|
|
in {
|
|
|
|
formatter = pkgs.nixfmt;
|
2023-12-09 03:23:19 +00:00
|
|
|
packages = lib.mapAttrs'
|
|
|
|
(name: value: lib.nameValuePair "${name}-sdimage" (makeImage value))
|
|
|
|
self.nixosConfigurations;
|
2023-12-09 02:12:40 +00:00
|
|
|
})) // {
|
2023-12-09 18:54:49 +00:00
|
|
|
nixosModules.minify = { config, ... }: {
|
2023-12-09 06:37:16 +00:00
|
|
|
disabledModules = [ "profiles/base.nix" "profiles/all-hardware.nix" ];
|
2023-12-09 02:12:40 +00:00
|
|
|
config = {
|
2023-12-09 03:54:26 +00:00
|
|
|
boot.bcache.enable = false;
|
2023-12-09 05:35:03 +00:00
|
|
|
boot.initrd.includeDefaultModules = false;
|
2023-12-09 03:54:26 +00:00
|
|
|
fonts.fontconfig.enable = false;
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
programs.nano.enable = false;
|
|
|
|
services.lvm.enable = false;
|
|
|
|
|
2023-12-09 18:54:49 +00:00
|
|
|
# Disable nix daemon, but sdImage uses nix-env so it's in the closure anyway
|
|
|
|
# Link it in for convenience
|
|
|
|
nix.enable = false;
|
|
|
|
environment.systemPackages = [ config.nix.package.out ];
|
|
|
|
|
|
|
|
# Disable a few default packages, like rsync, but not core stuff, like coreutils
|
2023-12-09 03:54:26 +00:00
|
|
|
# We could theoretically disable system-path.nix so we don't have
|
|
|
|
# requiredPackages, but that seems like a lot of work.
|
2023-12-09 05:35:03 +00:00
|
|
|
# At that point I should just use buildroot...
|
2023-12-09 18:54:49 +00:00
|
|
|
environment.defaultPackages = [ ];
|
2023-12-09 03:54:26 +00:00
|
|
|
|
|
|
|
# Leave networking.useDHCP = true since we would reenable it anyway
|
|
|
|
|
|
|
|
# Just set this to something, we probably don't care
|
|
|
|
system.stateVersion = "23.11";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nixosModules.insecureRemote = { ... }: {
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings.PermitRootLogin = "yes";
|
2023-12-09 02:12:40 +00:00
|
|
|
};
|
2023-12-09 03:54:26 +00:00
|
|
|
users.users.root.initialPassword = "ohnowo";
|
2023-12-09 02:12:40 +00:00
|
|
|
};
|
|
|
|
|
2023-12-09 05:35:03 +00:00
|
|
|
nixosModules.rpiSht3x = { pkgs, lib, ... }: {
|
|
|
|
# Patch doesn't apply on old vendor kernels
|
|
|
|
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
|
|
|
|
|
|
|
|
nixpkgs.overlays = [ (import ./config/overlay.nix) ];
|
|
|
|
boot.kernelPatches = [ pkgs.kernelPatches.sht3x_dt_binding ];
|
|
|
|
|
|
|
|
hardware.deviceTree.overlays = [{
|
|
|
|
name = "sht3x";
|
|
|
|
dtsFile = ./config/dts/rpi-sht3x.dts;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
nixosConfigurations.aarch64-rpi = lib.nixosSystem {
|
2023-12-09 02:12:40 +00:00
|
|
|
modules = [
|
|
|
|
self.nixosModules.minify
|
2023-12-09 03:54:26 +00:00
|
|
|
self.nixosModules.insecureRemote
|
2023-12-09 02:12:40 +00:00
|
|
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
|
2023-12-09 05:35:03 +00:00
|
|
|
{
|
|
|
|
nixpkgs.hostPlatform = lib.systems.examples.aarch64-multiplatform;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
nixosConfigurations.armv6-rpi = lib.nixosSystem {
|
|
|
|
modules = [
|
|
|
|
self.nixosModules.minify
|
|
|
|
self.nixosModules.insecureRemote
|
|
|
|
self.nixosModules.rpiSht3x
|
|
|
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix"
|
|
|
|
({ pkgs, ... }: {
|
2023-12-09 06:37:16 +00:00
|
|
|
boot.initrd.availableKernelModules = [ "mmc_block" ];
|
|
|
|
sdImage.compressImage = false;
|
|
|
|
|
2023-12-09 05:35:03 +00:00
|
|
|
nixpkgs.hostPlatform = lib.systems.examples.raspberryPi;
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
# compiler-rt 16 fails, 14 has a patch
|
|
|
|
llvmPackages = final.llvmPackages_14;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
})
|
2023-12-09 02:12:40 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|