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 18, 2024
1 parent 8938072 commit eb33175
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
16 changes: 16 additions & 0 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,21 @@ nixpkgs.lib.extend (
# files beneath withough manually having to list all the subsequent files.
#
path: builtins.attrValues (lib.mapAttrs (_: import) (rakeLeaves path));

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 { };
}
];
}
)
6 changes: 5 additions & 1 deletion targets/generic-x86_64/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ in
map (t: lib.nameValuePair t.name t.hostConfiguration) targets
);
packages = {
x86_64-linux = builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets);
x86_64-linux = builtins.listToAttrs (
map (
t: lib.nameValuePair t.name (self.outputs.lib.genPkgWithFlashScript t.package "x86_64-linux")
) targets
);
};
};
}
4 changes: 3 additions & 1 deletion targets/laptop/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ in
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 (self.outputs.lib.genPkgWithFlashScript t.package system)) 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
);
};
}
6 changes: 5 additions & 1 deletion targets/microchip-icicle-kit/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ in
map (t: lib.nameValuePair t.name t.hostConfiguration) targets
);
packages = {
x86_64-linux = builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets);
x86_64-linux = builtins.listToAttrs (
map (
t: lib.nameValuePair t.name (self.outputs.lib.genPkgWithFlashScript t.package "x86_64-linux")
) targets
);
};
};
}
12 changes: 10 additions & 2 deletions targets/nvidia-jetson-orin/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ in

packages = {
aarch64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets)
builtins.listToAttrs (
map (
t: lib.nameValuePair t.name (self.outputs.lib.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 +199,11 @@ 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 (self.outputs.lib.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 eb33175

Please sign in to comment.