Skip to content

Commit

Permalink
Add flash scripts as build result
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Kharin <[email protected]>
  • Loading branch information
remimimimimi committed Dec 11, 2024
1 parent 8938072 commit d5078bf
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
20 changes: 19 additions & 1 deletion targets/laptop/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
let
system = "x86_64-linux";

pkgs = import inputs.nixpkgs { inherit system; };

laptop-configuration = import ./laptop-configuration-builder.nix { inherit lib self inputs; };

targets = [
Expand Down Expand Up @@ -108,12 +110,28 @@ let
}
])
];

flashScript = pkgs.callPackage ../../packages/flash { };
genPkgWithFlashScript =
pkg:
pkgs.linkFarm "ghaf-image" [
{
name = "image";
path = pkg;
}
{
name = "flash-script";
path = flashScript;
}
];
in
{
flake = {
nixosConfigurations = builtins.listToAttrs (
map (t: lib.nameValuePair t.name t.hostConfiguration) targets
);
packages.${system} = builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets);
packages.${system} = builtins.listToAttrs (
map (t: lib.nameValuePair t.name (genPkgWithFlashScript t.package)) targets
);
};
}
18 changes: 16 additions & 2 deletions targets/lenovo-x1-installer/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
let
name = "lenovo-x1-carbon";
system = "x86_64-linux";
pkgs = import self.inputs.nixpkgs { inherit system; };
installer =
generation: variant:
let
imagePath = self.packages.x86_64-linux."${name}-${generation}-${variant}" + "/disk1.raw.zst";
imagePath = self.packages.x86_64-linux."${name}-${generation}-${variant}" + "/image/disk1.raw.zst";
hostConfiguration = lib.nixosSystem {
inherit system;
modules = [
Expand Down Expand Up @@ -72,12 +73,25 @@ let
(installer "gen10" "release")
(installer "gen11" "release")
];
flashScript = pkgs.callPackage ../../packages/flash { };
genPkgWithFlashScript =
pkg:
pkgs.linkFarm "ghaf-image" [
{
name = "image";
path = pkg;
}
{
name = "flash-script";ni
path = flashScript;
}
];
in
{
flake = {
nixosConfigurations = builtins.listToAttrs (
map (t: lib.nameValuePair t.name t.hostConfiguration) targets
);
packages.${system} = builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets);
packages.${system} = builtins.listToAttrs (map (t: lib.nameValuePair t.name (genPkgWithFlashScript t.package)) targets);
};
}
25 changes: 23 additions & 2 deletions targets/nvidia-jetson-orin/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ let
inherit jetpack-nixos;
inherit flash-tools-system;
};

genPkgWithFlashScripts =
t: system:
(import nixpkgs { inherit system; }).linkFarm "ghaf-image" [
{
name = "image";
path = t.package;
}
{
name = "${t.name}-flash-script";
path = generate-flash-script t system;
}
{
name = "${t.name}-flash-qspi";
path = generate-flash-qspi t system;
}
];
in
{
flake = {
Expand All @@ -183,7 +200,9 @@ in

packages = {
aarch64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets)
builtins.listToAttrs (
map (t: lib.nameValuePair t.name (genPkgWithFlashScripts t "aarch64-linux")) targets
)
# EXPERIMENTAL: The aarch64-linux hosted flashing support is experimental
# and it simply might not work. Providing the script anyway
// builtins.listToAttrs (
Expand All @@ -195,7 +214,9 @@ in
map (t: lib.nameValuePair "${t.name}-flash-qspi" (generate-flash-qspi t "aarch64-linux")) targets
);
x86_64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) crossTargets)
builtins.listToAttrs (
map (t: lib.nameValuePair t.name (genPkgWithFlashScripts t "x86_64-linux")) crossTargets
)
// builtins.listToAttrs (
map (t: lib.nameValuePair "${t.name}-flash-script" (generate-flash-script t "x86_64-linux")) (
targets ++ crossTargets
Expand Down

0 comments on commit d5078bf

Please sign in to comment.