forked from tiiuae/ghaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ganga Ram <[email protected]>
- Loading branch information
1 parent
9abbd1e
commit c2c8dca
Showing
11 changed files
with
238 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Support for Microchip Polarfire Icicle-Kit | ||
# | ||
{ | ||
imports = [ | ||
./imx8mp-sdimage.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# SPDX-FileCopyrightText: 2023-2024 TII (SSRC) and the Ghaf contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
config, | ||
pkgs, | ||
modulesPath, | ||
... | ||
}: { | ||
imports = [ | ||
(modulesPath + "/installer/sd-card/sd-image.nix") | ||
]; | ||
|
||
disabledModules = [(modulesPath + "/profiles/all-hardware.nix")]; | ||
sdImage = { | ||
compressImage = false; | ||
|
||
populateFirmwareCommands = '' | ||
cp ${pkgs.imx8m-boot}/image/flash.bin firmware/ | ||
''; | ||
|
||
populateRootCommands = '' | ||
mkdir -p ./files/boot | ||
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot | ||
''; | ||
|
||
postBuildCommands = '' | ||
sdimage="$out/nixos.img" | ||
fwoffset=64 | ||
blocksize=512 | ||
fwsize=20400 | ||
rootoffset=20800 | ||
sfdisk --list $img | grep Linux | ||
rootstart=$(sfdisk --list $img | grep Linux | awk '{print $3}') | ||
rootsize=$(sfdisk --list $img | grep Linux | awk '{print $5}') | ||
imagesize=$(((rootoffset + rootsize)*blocksize)) | ||
touch $sdimage | ||
truncate -s $imagesize $sdimage | ||
echo -e " | ||
label: dos | ||
label-id: 0x2178694e | ||
unit: sectors | ||
sector-size: 512 | ||
start=$fwoffset, size=$fwsize, type=60 | ||
start=$rootoffset, size=$rootsize, type=83, bootable" > "$out/partition.txt" | ||
sfdisk -d $img | ||
sfdisk $sdimage < "$out/partition.txt" | ||
dd conv=notrunc if=${pkgs.imx8m-boot}/image/flash.bin of=$sdimage seek=$fwoffset | ||
dd conv=notrunc if=$img of=$sdimage seek=$rootoffset skip=$rootstart count=$rootsize | ||
sfdisk --list $sdimage | ||
rm -rf $out/sd-image | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# i.MX8M Plus Evaluation Kit | ||
{ | ||
self, | ||
lib, | ||
inputs, | ||
... | ||
}: let | ||
inherit (inputs) nixos-hardware nixpkgs; | ||
name = "nxp-imx8mp-evk"; | ||
system = "aarch64-linux"; | ||
nxp-imx8mp-evk = variant: extraModules: let | ||
hostConfiguration = lib.nixosSystem { | ||
inherit system; | ||
specialArgs = {inherit lib;}; | ||
modules = | ||
[ | ||
nixos-hardware.nixosModules.nxp-imx8mp-evk | ||
self.nixosModules.common | ||
self.nixosModules.host | ||
self.nixosModules.imx8 | ||
{ | ||
boot = { | ||
kernelParams = lib.mkForce ["root=/dev/mmcblk0p2"]; | ||
loader = { | ||
grub.enable = false; | ||
generic-extlinux-compatible.enable = true; | ||
}; | ||
}; | ||
|
||
# Disable all the default UI applications | ||
ghaf = { | ||
profiles = { | ||
release.enable = variant == "release"; | ||
debug.enable = variant == "debug"; | ||
}; | ||
development = { | ||
debug.tools.enable = variant == "debug"; | ||
ssh.daemon.enable = true; | ||
}; | ||
firewall.kernel-modules.enable = true; | ||
}; | ||
nixpkgs = { | ||
buildPlatform.system = "x86_64-linux"; | ||
overlays = [ | ||
self.overlays.cross-compilation | ||
]; | ||
}; | ||
hardware.deviceTree.name = lib.mkForce "freescale/imx8mp-evk.dtb"; | ||
disabledModules = ["profiles/all-hardware.nix"]; | ||
} | ||
] | ||
++ extraModules; | ||
}; | ||
in { | ||
inherit hostConfiguration; | ||
name = "${name}-${variant}"; | ||
package = hostConfiguration.config.system.build.sdImage; | ||
}; | ||
debugModules = []; | ||
releaseModules = []; | ||
targets = [ | ||
(nxp-imx8mp-evk "debug" debugModules) | ||
(nxp-imx8mp-evk "release" releaseModules) | ||
]; | ||
in { | ||
flake = { | ||
nixosConfigurations = | ||
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.hostConfiguration) targets); | ||
packages = { | ||
aarch64-linux = | ||
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
description = "PROJ_NAME - Ghaf based configuration"; | ||
|
||
nixConfig = { | ||
substituters = [ | ||
"https://cache.vedenemo.dev" | ||
"https://cache.ssrcdevops.tii.ae" | ||
"https://ghaf-dev.cachix.org" | ||
"https://cache.nixos.org/" | ||
]; | ||
extra-trusted-substituters = [ | ||
"https://cache.vedenemo.dev" | ||
"https://cache.ssrcdevops.tii.ae" | ||
"https://ghaf-dev.cachix.org" | ||
"https://cache.nixos.org/" | ||
]; | ||
extra-trusted-public-keys = [ | ||
"cache.vedenemo.dev:8NhplARANhClUSWJyLVk4WMyy1Wb4rhmWW2u8AejH9E=" | ||
"cache.ssrcdevops.tii.ae:oOrzj9iCppf+me5/3sN/BxEkp5SaFkHfKTPPZ97xXQk=" | ||
"ghaf-dev.cachix.org-1:S3M8x3no8LFQPBfHw1jl6nmP8A7cVWKntoMKN3IsEQY=" | ||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" | ||
]; | ||
}; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nixos-hardware.url = "github:NixOS/nixos-hardware"; | ||
ghaf = { | ||
url = "github:tiiuae/ghaf"; | ||
inputs = { | ||
nixpkgs.follows = "nixpkgs"; | ||
flake-utils.follows = "flake-utils"; | ||
nixos-hardware.follows = "nixos-hardware"; | ||
}; | ||
}; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
ghaf, | ||
nixpkgs, | ||
flake-utils, | ||
... | ||
}: let | ||
systems = with flake-utils.lib.system; [ | ||
x86_64-linux | ||
aarch64-linux | ||
]; | ||
in | ||
# Combine list of attribute sets together | ||
nixpkgs.lib.foldr nixpkgs.lib.recursiveUpdate {} [ | ||
(flake-utils.lib.eachSystem systems (system: { | ||
formatter = nixpkgs.legacyPackages.${system}.alejandra; | ||
})) | ||
|
||
{ | ||
nixosConfigurations.PROJ_NAME-ghaf-debug = ghaf.nixosConfigurations.nxp-imx8mp-evk-debug.extendModules { | ||
modules = [ | ||
{ | ||
#insert your additional modules here e.g. | ||
# virtualisation.docker.enable = true; | ||
# users.users."ghaf".extraGroups = ["docker"]; | ||
} | ||
({pkgs, ...}: { | ||
environment.systemPackages = with pkgs; [ | ||
#Add additional system packages here | ||
]; | ||
}) | ||
]; | ||
}; | ||
packages.aarch64-linux.PROJ_NAME-ghaf-debug = self.nixosConfigurations.PROJ_NAME-ghaf-debug.config.system.build.sdImage; | ||
} | ||
]; | ||
} |