rpi4-nixos-template/flake.nix

68 lines
1.9 KiB
Nix
Raw Permalink Normal View History

2023-12-20 00:28:10 +01:00
{
description = "A very basic flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.nixos-hw.url = "github:NixOS/nixos-hardware";
inputs.agenix.url = "github:ryantm/agenix";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {
self,
nixpkgs,
nixos-hw,
flake-utils,
agenix,
}: let
buildEnv = {
nixpkgs.hostPlatform = "aarch64-linux";
nixpkgs.overlays = [
(final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // {allowMissing = true;});
})
];
};
in
{
nixosConfigurations.rpi4-install = nixpkgs.lib.nixosSystem {
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix"
nixos-hw.nixosModules.raspberry-pi-4
buildEnv
{
networking.hostName = "rpi4-nixos";
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [
# My SSH Key
];
networking.wireless = {
enable = true;
# Don't commit the password!
networks."<MY NETWORK>".psk = "<PASSWORD>";
};
system.stateVersion = "23.11";
}
];
};
nixosConfigurations.rpi4 = nixpkgs.lib.nixosSystem {
modules = [
nixos-hw.nixosModules.raspberry-pi-4
agenix.nixosModules.default
buildEnv
./config.nix
];
};
images.rpi4-install = self.nixosConfigurations.rpi4-install.config.system.build.sdImage;
}
// (flake-utils.lib.eachDefaultSystem (system: {
devShell = nixpkgs.legacyPackages."${system}".mkShell {
nativeBuildInputs = [agenix.packages."${system}".agenix];
};
packages.agenix = agenix.packages.${system}.agenix;
}));
}