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 16, 2024
1 parent 8938072 commit 3d9d7b3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
21 changes: 20 additions & 1 deletion targets/laptop/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,31 @@ let
}
])
];

genPkgWithFlashScript =
pkg:
let
pkgs = import inputs.nixpkgs { inherit system; };
in

pkgs.linkFarm "ghaf-image" [
{
name = "image";
path = pkg;
}
{
name = "flash-script";
path = pkgs.callPackage ../../packages/flash { };
}
];
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
);
};
}
21 changes: 19 additions & 2 deletions targets/lenovo-x1-installer/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
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 +72,29 @@ let
(installer "gen10" "release")
(installer "gen11" "release")
];
genPkgWithFlashScript =
pkg:
let
pkgs = import self.inputs.nixpkgs { inherit system; };
in
pkgs.linkFarm "ghaf-image" [
{
name = "image";
path = pkg;
}
{
name = "flash-script";
path = pkgs.callPackage ../../packages/flash { };
}
];
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
);
};
}
24 changes: 22 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,22 @@ let
inherit jetpack-nixos;
inherit flash-tools-system;
};

genPkgWithFlashScript =
pkg: system:
let
pkgs = import nixpkgs { inherit system; };
in
pkgs.linkFarm "ghaf-image" [
{
name = "image";
path = pkg;
}
{
name = "flash-script";
path = pkgs.callPackage ../../packages/flash { };
}
];
in
{
flake = {
Expand All @@ -183,7 +199,9 @@ in

packages = {
aarch64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets)
builtins.listToAttrs (
map (t: lib.nameValuePair t.name (genPkgWithFlashScript t.package "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 +213,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 (genPkgWithFlashScript t.package "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 3d9d7b3

Please sign in to comment.