Last active
November 13, 2022 13:52
-
-
Save josqu4red/3bbb5bf62d98881c020a1b2340f140df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultPackage.x86_64-linux = let | |
nixosConfiguration = inputs.nixpkgs.lib.nixosSystem { | |
modules = [ | |
( | |
{ config, lib, pkgs, ... }: { | |
imports = [ | |
"${inputs.nixpkgs}/nixos/modules/profiles/installation-device.nix" | |
"${inputs.nixpkgs}/nixos/modules/profiles/base.nix" | |
"${inputs.nixpkgs}/nixos/modules/installer/sd-card/sd-image.nix" | |
]; | |
installer.cloneConfig = false; | |
boot = { | |
loader.grub.enable = false; | |
loader.generic-extlinux-compatible.enable = true; | |
consoleLogLevel = lib.mkDefault 7; | |
kernelParams = ["console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"]; | |
kernelPackages = pkgs.linuxPackages_latest; | |
supportedFilesystems = lib.mkForce [ "btrfs" "f2fs" "vfat" ]; | |
}; | |
sdImage = { | |
compressImage = false; | |
populateFirmwareCommands = ""; | |
populateRootCommands = '' | |
mkdir -p ./files/boot | |
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot | |
''; | |
#postBuildCommands = '' | |
# dd if=${pkgs.ubootLibreTechCC}/u-boot.gxl.sd.bin of=$img conv=fsync,notrunc bs=512 seek=1 skip=1 | |
# dd if=${pkgs.ubootLibreTechCC}/u-boot.gxl.sd.bin of=$img conv=fsync,notrunc bs=1 count=444 | |
#''; | |
}; | |
# Also tried this but results in infinite recursion | |
# fileSystems = builtins.removeAttrs config.filesystems "/boot/firmware" | |
fileSystems = lib.mkOverride 1 ({ | |
"/" = { | |
device = "/dev/disk/by-label/NIXOS_SD"; | |
fsType = "ext4"; | |
}; | |
}); | |
nixpkgs = { | |
config.allowUnfree = true; | |
localSystem.system = "x86_64-linux"; | |
crossSystem = inputs.nixpkgs.lib.systems.examples.aarch64-multiplatform; | |
}; | |
} | |
) | |
]; | |
}; | |
in | |
nixosConfiguration.config.system.build.sdImage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment