This repository has been archived on 2024-06-05. You can view files and clone it, but cannot push or open issues or pull requests.
dtsense/flake.nix

106 lines
3.7 KiB
Nix
Raw Normal View History

{
inputs = {
2023-12-09 05:35:03 +00:00
nixpkgs.url = "github:nixos/nixpkgs/release-23.11";
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;
in (utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs { inherit system; };
makeImage = conf:
(conf.extendModules {
2023-12-09 05:35:03 +00:00
modules = [{ config.nixpkgs.buildPlatform.system = system; }];
}).config.system.build.sdImage;
in {
formatter = pkgs.nixfmt;
packages = lib.mapAttrs'
(name: value: lib.nameValuePair "${name}-sdimage" (makeImage value))
self.nixosConfigurations;
})) // {
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" ];
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 03:54:26 +00:00
users.users.root.initialPassword = "ohnowo";
};
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 {
modules = [
self.nixosModules.minify
2023-12-09 03:54:26 +00:00
self.nixosModules.insecureRemote
"${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;
})
];
})
];
};
};
}