image building: enable impermanence
note that it still needs an interactive `mkdir /mnt-root/nix/var/{lib,log}` in the initrd.
This commit is contained in:
parent
0579faaf89
commit
0acb2e138b
26
image.nix
26
image.nix
|
@ -1,5 +1,15 @@
|
||||||
{ config, lib, pkgs, mobile-nixos, ... }:
|
{ config, lib, pkgs, mobile-nixos, utils, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# fileSystems = lib.filter utils.fsNeededForBoot config.system.build.fileSystems;
|
||||||
|
fileSystems = config.fileSystems;
|
||||||
|
bootFs = fileSystems."/boot";
|
||||||
|
storeFs = fileSystems."/nix/store" or fileSystems."/nix" or fileSystems."/";
|
||||||
|
# yield e.g. "nix/store", "/store" or ""
|
||||||
|
storeRelPath = builtins.head (builtins.match "^${storeFs.mountPoint}(.+)" "/nix/store");
|
||||||
|
uuidFromFs = fs: builtins.head (builtins.match "/dev/disk/by-uuid/(.+)" fs.device);
|
||||||
|
vfatUuidFromFs = fs: builtins.replaceStrings ["-"] [""] (uuidFromFs fs);
|
||||||
|
in
|
||||||
{
|
{
|
||||||
system.build.img-without-firmware = with pkgs; imageBuilder.diskImage.makeGPT {
|
system.build.img-without-firmware = with pkgs; imageBuilder.diskImage.makeGPT {
|
||||||
name = "nixos";
|
name = "nixos";
|
||||||
|
@ -9,7 +19,8 @@
|
||||||
(imageBuilder.fileSystem.makeESP {
|
(imageBuilder.fileSystem.makeESP {
|
||||||
name = "ESP";
|
name = "ESP";
|
||||||
partitionLabel = "ESP";
|
partitionLabel = "ESP";
|
||||||
partitionID = "43021685";
|
partitionID = vfatUuidFromFs bootFs;
|
||||||
|
# TODO: should this even have a part uuid?
|
||||||
partitionUUID = "CFB21B5C-A580-DE40-940F-B9644B4466E3";
|
partitionUUID = "CFB21B5C-A580-DE40-940F-B9644B4466E3";
|
||||||
size = imageBuilder.size.MiB 256;
|
size = imageBuilder.size.MiB 256;
|
||||||
|
|
||||||
|
@ -19,23 +30,24 @@
|
||||||
echo "ran installBootLoader"
|
echo "ran installBootLoader"
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
# TODO: make format-aware
|
||||||
(imageBuilder.fileSystem.makeExt4 {
|
(imageBuilder.fileSystem.makeExt4 {
|
||||||
name = "NIXOS_SYSTEM";
|
name = "NIXOS_SYSTEM";
|
||||||
partitionLabel = "NIXOS_SYSTEM";
|
partitionLabel = "NIXOS_SYSTEM";
|
||||||
partitionID = "5A7FA69C-9394-8144-A74C-6726048B129F";
|
partitionID = uuidFromFs storeFs;
|
||||||
partitionUUID = "5A7FA69C-9394-8144-A74C-6726048B129F";
|
partitionUUID = uuidFromFs storeFs;
|
||||||
|
# TODO: what's this?
|
||||||
partitionType = "EBC597D0-2053-4B15-8B64-E0AAC75F4DB1";
|
partitionType = "EBC597D0-2053-4B15-8B64-E0AAC75F4DB1";
|
||||||
# size = imagBuilder.size.GiB 6;
|
|
||||||
populateCommands =
|
populateCommands =
|
||||||
let
|
let
|
||||||
closureInfo = buildPackages.closureInfo { rootPaths = config.system.build.toplevel; };
|
closureInfo = buildPackages.closureInfo { rootPaths = config.system.build.toplevel; };
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
mkdir -p ./nix/store
|
mkdir -p ./${storeRelPath}
|
||||||
echo "Copying system closure..."
|
echo "Copying system closure..."
|
||||||
while IFS= read -r path; do
|
while IFS= read -r path; do
|
||||||
echo " Copying $path"
|
echo " Copying $path"
|
||||||
cp -prf "$path" ./nix/store
|
cp -prf "$path" ./${storeRelPath}
|
||||||
done < "${closureInfo}/store-paths"
|
done < "${closureInfo}/store-paths"
|
||||||
echo "Done copying system closure..."
|
echo "Done copying system closure..."
|
||||||
cp -v ${closureInfo}/registration ./nix-path-registration
|
cp -v ${closureInfo}/registration ./nix-path-registration
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
# colinsane.gui.sway.enable = true;
|
# colinsane.gui.sway.enable = true;
|
||||||
# colinsane.impermanence.enable = true;
|
colinsane.impermanence.enable = true;
|
||||||
colinsane.extlinux.enable = true;
|
colinsane.extlinux.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = false;
|
boot.loader.efi.canTouchEfiVariables = false;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
# fsType = "vfat";
|
# fsType = "vfat";
|
||||||
# };
|
# };
|
||||||
|
|
||||||
fileSystems."/" = {
|
fileSystems."/nix" = {
|
||||||
device = "/dev/disk/by-uuid/5a7fa69c-9394-8144-a74c-6726048b129f";
|
device = "/dev/disk/by-uuid/5a7fa69c-9394-8144-a74c-6726048b129f";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
};
|
};
|
||||||
|
@ -34,4 +34,14 @@
|
||||||
device = "/dev/disk/by-uuid/4302-1685";
|
device = "/dev/disk/by-uuid/4302-1685";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "none";
|
||||||
|
fsType = "tmpfs";
|
||||||
|
options = [
|
||||||
|
"mode=755"
|
||||||
|
"size=1G"
|
||||||
|
"defaults"
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user