Skip to content

Commit

Permalink
Merge pull request #1 from frederictobiasc/update-sources
Browse files Browse the repository at this point in the history
Reasonable defaults for extension-release
  • Loading branch information
frederictobiasc authored Jan 15, 2025
2 parents f9e76a3 + 54af5b9 commit b22021c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ TODO.MD
# Local debugging
img
*.raw
*.qcow2
mnt/
tree/
43 changes: 13 additions & 30 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
systems = import inputs.systems;
imports = [ inputs.pre-commit-hooks-nix.flakeModule ];
flake.nixosModules = {
naext = import ./nix/module.nix;
dm-verity = import ./nix/dm-verity.nix;
naext = import ./nix/module.nix;
};
perSystem =
{
Expand Down
35 changes: 9 additions & 26 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
...
}:
let
nixosRelease = config.system.nixos.release;
inherit (config.system.nixos) distroId;

mkExt = pkgs.callPackage ./lib/mkExt.nix { };

extensionReleasePath = {
Expand Down Expand Up @@ -47,29 +50,14 @@ let
else
throw "[naext] The string '${str}' must start with ${lib.concatStringsSep " or " prefixes}";

# Helper function to format extension release metadata.
createExtensionReleaseFile =
type: name:
# bash
''
mkdir -p $out${getExtensionReleasePathBy type}
cat >$out${getExtensionReleasePathBy type}/extension-release.${name} <<EOF
ID=nixos
VERSION_ID="24.11"
CONFEXT_SCOPE=system initrd
EOF
'';

# Create the tree for an extension image
mkExtTree =
type: files: name:
type: files:
pkgs.runCommand "tree" { }
# bash
''
set -euo pipefail
${createExtensionReleaseFile type name}
mkFile() {
src="$1"
Expand Down Expand Up @@ -176,14 +164,9 @@ in
description = "Contents of the Extension Release file.";
type = lib.types.lines;
default = ''
ID=nixos
VERSION_ID="24.11"
CONFEXT_SCOPE=system initrd
'';
example = lib.literalExpression ''
ID=nixos
VERSION_ID="24.11"
CONFEXT_SCOPE=system initrd
ID=${distroId}
VERSION_ID="${nixosRelease}"
CONFEXT_SCOPE=system
'';
};
files = lib.mkOption {
Expand Down Expand Up @@ -219,13 +202,13 @@ in
# Add the extension-release to the files.
mergedFiles = self.files // {
"${getExtensionReleasePathBy self.extensionType}extension-release.${name}" = {
source = self.extension-release;
source = pkgs.writeText "extension-release" self.extension-release;
target = "${getExtensionReleasePathBy self.extensionType}extension-release.${name}";

};
};
# The tree to create the extension image from.
tree = mkExtTree self.extensionType mergedFiles self.name;
tree = mkExtTree self.extensionType mergedFiles;
# Determin the function to use for creating the extension image.
mkExtMethod =
if self.imageFormat == "verity" then
Expand Down
6 changes: 4 additions & 2 deletions nix/tests/appliance.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ in
"esp" = {
contents = {
# Necessary for the image to boot
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source = "${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source = "${config.system.build.uki}/${config.system.boot.loader.ukiFile}";
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source =
"${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source =
"${config.system.build.uki}/${config.system.boot.loader.ukiFile}";
};
repartConfig = {
Type = "esp";
Expand Down
2 changes: 1 addition & 1 deletion nix/tests/basic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
...
}:
{
name = "confext-basic";
name = "basic";
nodes = {
machine = _: {
naext = {
Expand Down

0 comments on commit b22021c

Please sign in to comment.