Last active
December 23, 2018 22:42
-
-
Save petersjt014/121250e4eb99c0f5ef8b2094cac76795 to your computer and use it in GitHub Desktop.
aarch64 image with f2fs as main filesystem
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
{ nixpkgs ? <nixpkgs>, system ? "aarch64-linux" } : | |
let | |
myisoconfig = { pkgs, config, ...}: { | |
imports = [ | |
"${nixpkgs}/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix" | |
]; | |
boot = { | |
kernelParams = [ "cma=32M" ]; | |
supportedFilesystems = [ "f2fs" ]; | |
# I think this is how mkForce works | |
postBootCommands = pkgs.lib.mkForce '' | |
# On the first boot do some maintenance tasks | |
if [ -f /nix-path-registration ]; then | |
# Figure out device names for the boot device and root filesystem. | |
rootPart=$(readlink -f /dev/disk/by-label/NIXOS_SD) | |
bootDevice=$(lsblk -npo PKNAME $rootPart) | |
# Not resizing because f2fs's resize tools are different (?), see also: | |
# https://github.com/NixOS/nixpkgs/pull/42183 | |
# https://github.com/NixOS/nixpkgs/issues/42242 | |
# Resize the root partition and the filesystem to fit the disk | |
# echo ",+," | sfdisk -N2 --no-reread $bootDevice | |
# ${pkgs.parted}/bin/partprobe | |
# ${pkgs.e2fsprogs}/bin/resize2fs $rootPart | |
# Register the contents of the initial Nix store | |
${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration | |
# nixos-rebuild also requires a "system" profile and an /etc/NIXOS tag. | |
touch /etc/NIXOS | |
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system | |
# Prevents this from running on later boots. | |
rm -f /nix-path-registration | |
fi | |
''; | |
}; | |
environment.systemPackages = with pkgs; [ vim ]; | |
users.extraUsers.root = { | |
packages = with pkgs; [ f2fs-tools lynx vim w3m ]; | |
initialPassword = "nixos"; | |
}; | |
fileSystems = { | |
"/boot" = { | |
#device = "/dev/disk/by-label/NIXOS_BOOT"; | |
#fsType = "vfat"; | |
}; | |
"/" = { | |
#device = "/dev/disk/by-label/NIXOS_SD"; | |
fsType = pkgs.lib.mkForce "f2fs"; | |
}; | |
}; | |
}; | |
evalNixos = configuration: import "${nixpkgs}/nixos" { | |
inherit system configuration; | |
}; | |
in { sd = (evalNixos myisoconfig).config.system.build.sdImage; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment