[raspberry] add base image

i currently try building it and then check if it works
This commit is contained in:
2022-11-08 19:16:43 +01:00
parent e27351d1c3
commit b34e473865
3 changed files with 36 additions and 1 deletions

View File

@@ -53,6 +53,22 @@ to build a configuration run the following command (replace ```<hostname>``` wit
nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel
```
### building raspberry image
for the raspberry it is possible to build the whole configuration as an sd-card image which then can be flashed directly. more information about building arm on nixos can be found [here](https://nixos.wiki/wiki/NixOS_on_ARM).
to be able to build the image you need to enable qemu emulation on the machine you are building with. therefore it is necessary to add the following to your configuration.nix:
``` nix
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
```
then you can build the image with:
``` shell
nix build .#nixosConfigurations.rpi1_base_image.config.system.build.sdImage
```
### run a configuration as vm
to run a vm we have to build it first using the following command (replace ```<hostname>``` with the actual hostname):

View File

@@ -36,4 +36,21 @@ in
./moderatio/configuration.nix
];
};
rpi1_base_image = nixosSystem {
system = "aarch64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix"
./modules/sshd.nix
{
nixpkgs.config.allowUnsupportedSystem = true;
nixpkgs.crossSystem.system = "aarch64-linux";
networking.hostName = "rp1_base_image";
networking.networkmanager.enable = true;
system.stateVersion = "22.05";
}
];
};
}

View File

@@ -17,8 +17,10 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
devShells.default = pkgs.callPackage ./shell.nix {
inherit (sops-nix.packages."${pkgs.system}") sops-import-keys-hook ssh-to-pgp sops-init-gpg-key;
};
})) // {
})) // rec {
nixosConfigurations = import ./machines/configuration.nix (inputs // {
inherit inputs;
});
images.rpi1_base_image = nixosConfigurations.rpi1_base_image.config.system.build.sdImage;
}