Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flash scripts as build result #927

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading