From 4e3a152ae990148266768b0be1169d7376d60014 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 17 Jun 2022 19:45:53 -0700 Subject: [PATCH] build an image which can boot from SD if tow-boot is installed to the eMMC temporarily disabled some modules to get a smaller, faster to iterate, image. need to test flashing tow-boot to the start of the SD card --- flake.lock | 15 +++++++-------- flake.nix | 9 ++++----- modules/default.nix | 6 ++++-- modules/fs.nix | 28 ++++++++++++++++++++++++++++ modules/image.nix | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 modules/fs.nix create mode 100644 modules/image.nix diff --git a/flake.lock b/flake.lock index 0067eb5..a430cd5 100644 --- a/flake.lock +++ b/flake.lock @@ -22,17 +22,16 @@ "mobile-nixos": { "flake": false, "locked": { - "lastModified": 1653513225, - "narHash": "sha256-DjIrBfb3cbLG15cWKpSIfBxorXCMWVBeFOc1K7HOzw4=", + "lastModified": 1654281294, + "narHash": "sha256-hT2/u0jUOD4TFU6YyYt+5Gt+hjIeerLTyZG7ru79aDU=", "owner": "nixos", "repo": "mobile-nixos", - "rev": "efbe2c3c5409c868309ae0770852638e623690b5", + "rev": "d798b0b34240b18a08c22f5c0ee1f59a3ce43c01", "type": "github" }, "original": { "owner": "nixos", "repo": "mobile-nixos", - "rev": "efbe2c3c5409c868309ae0770852638e623690b5", "type": "github" } }, @@ -52,16 +51,16 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1653060744, - "narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=", + "lastModified": 1655278232, + "narHash": "sha256-H6s7tnHYiDKFCcLADS4sl1sUq0dDJuRQXCieguk/6SA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dfd82985c273aac6eced03625f454b334daae2e8", + "rev": "8b538fcb329a7bc3d153962f17c509ee49166973", "type": "github" }, "original": { "id": "nixpkgs", - "rev": "dfd82985c273aac6eced03625f454b334daae2e8", + "ref": "nixos-22.05", "type": "indirect" } }, diff --git a/flake.nix b/flake.nix index 96482fd..282cd83 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,9 @@ { inputs = { - # nixpkgs.url = "nixpkgs/nixos-22.05"; - nixpkgs.url = "nixpkgs/dfd82985c273aac6eced03625f454b334daae2e8"; + nixpkgs.url = "nixpkgs/nixos-22.05"; mobile-nixos = { - # url = "github:nixos/mobile-nixos"; - url = "github:nixos/mobile-nixos/efbe2c3c5409c868309ae0770852638e623690b5"; + url = "github:nixos/mobile-nixos"; + # url = "github:nixos/mobile-nixos/efbe2c3c5409c868309ae0770852638e623690b5"; flake = false; }; home-manager.url = "github:nix-community/home-manager/release-22.05"; @@ -21,6 +20,6 @@ ./modules/default.nix ]; }); - pinephone-img = nixosConfigurations.pinephone.config.mobile.outputs.u-boot.disk-image; + pinephone-img = nixosConfigurations.pinephone.config.system.build.raw; }; } diff --git a/modules/default.nix b/modules/default.nix index f3aac89..0893ce3 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,9 +1,11 @@ { ... }: { imports = [ + ./fs.nix ./hardware.nix - ./home-manager.nix - ./phosh.nix + # ./home-manager.nix + ./image.nix + # ./phosh.nix ./users.nix ]; diff --git a/modules/fs.nix b/modules/fs.nix new file mode 100644 index 0000000..3d4a020 --- /dev/null +++ b/modules/fs.nix @@ -0,0 +1,28 @@ +{ lib, ... }: +{ + # boot.initrd.supportedFilesystems = [ "ext4" "btrfs" "ext2" "ext3" "vfat" ]; + # Use the systemd-boot EFI boot loader. + boot.loader.grub.enable = false; + # boot.loader.systemd-boot.enable = true; + # boot.loader.systemd-boot.configurationLimit = 20; # keep this many generations + # boot.loader.efi.canTouchEfiVariables = true; + boot.loader.generic-extlinux-compatible.enable = true; + mobile.bootloader.enable = lib.mkForce false; + + # boot.loader.grub.enable = true; + # boot.loader.grub.efiSupport = true; + # boot.loader.grub.efiInstallAsRemovable = true; + # boot.loader.grub.device = "nodev"; + + hardware.enableRedistributableFirmware = true; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; + + fileSystems."/" = { + device = "/dev/disk/by-label/nixos-img"; + fsType = "ext4"; + }; +} diff --git a/modules/image.nix b/modules/image.nix new file mode 100644 index 0000000..2a7ac23 --- /dev/null +++ b/modules/image.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, modulesPath, ... }: +{ + # fileSystems."/" = { + # # boot by label instead of unpredictable uuid + # device = "/dev/disk/by-label/nixos-img"; + # # make-disk-image only supports ext4 + # fsType = "ext4"; + # }; + # # fileSystems."/boot".device = "/dev/vda1"; + # fileSystems."/boot".device = "/dev/disk/by-label/ESP"; + + system.build.raw = import "${toString modulesPath}/../lib/make-disk-image.nix" { + inherit lib config pkgs; + partitionTableType = "efi"; + label = "nixos-img"; + fsType = config.fileSystems."/".fsType; + diskSize = "auto"; + format = "raw"; + }; +} +