add first draft
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
result*
|
result*
|
||||||
|
.buildroot
|
||||||
|
build
|
||||||
84
buildroot.nix
Normal file
84
buildroot.nix
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# nix-build --expr 'with import <nixpkgs> {}; callPackage ./buildroot.nix {}'
|
||||||
|
{
|
||||||
|
pkgs ? import <nixpkgs> {},
|
||||||
|
packagName ? "buildroot",
|
||||||
|
packageVersion ? "2021.02.7",
|
||||||
|
packageSha256 ? "0kdkar2pbd9k0q4i4a87xnqmsdr7njj6mc8x2avvhh9skw2qrg64",
|
||||||
|
outputFolder ? "$PWD/.buildroot",
|
||||||
|
withXConfig ? false,
|
||||||
|
withGConfig ? false,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
|
||||||
|
buildRootPath = "usr/src/${packagName}-${packageVersion}";
|
||||||
|
package = pkgs.stdenv.mkDerivation rec {
|
||||||
|
name = "${packagName}";
|
||||||
|
version = "${packageVersion}";
|
||||||
|
src = pkgs.fetchzip {
|
||||||
|
url = "https://buildroot.org/downloads/buildroot-${packageVersion}.tar.gz";
|
||||||
|
sha256 = "${packageSha256}";
|
||||||
|
};
|
||||||
|
phases = [ "unpackPhase" "installPhase" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/${buildRootPath}
|
||||||
|
cp -R . $out/${buildRootPath}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
makeBuildRoot = pkgs.writeShellScriptBin "makeBuildRoot" ''
|
||||||
|
BR2_DL_DIR="${outputFolder}/dl" ${pkgs.gnumake}/bin/make O="${outputFolder}" -C "${package}/${buildRootPath}" $@
|
||||||
|
'';
|
||||||
|
|
||||||
|
makeBuildRootScriptPaths = [ pkgs.gnumake];
|
||||||
|
|
||||||
|
qtPaths = if withXConfig then [pkgs.qt5.base] else [];
|
||||||
|
gtkPaths = if withGConfig then [
|
||||||
|
pkgs.gtk2.dev
|
||||||
|
pkgs.gtkmm2
|
||||||
|
pkgs.gnome2.libglade
|
||||||
|
pkgs.glib
|
||||||
|
] else [];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
package = package;
|
||||||
|
makeBuildRoot = {
|
||||||
|
command = makeBuildRoot;
|
||||||
|
scriptPaths = makeBuildRootScriptPaths;
|
||||||
|
paths = makeBuildRootScriptPaths ++ [
|
||||||
|
pkgs.which
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.ncurses.dev
|
||||||
|
pkgs.rsync
|
||||||
|
pkgs.bc
|
||||||
|
pkgs.unzip
|
||||||
|
pkgs.cpio
|
||||||
|
pkgs.wget
|
||||||
|
pkgs.git
|
||||||
|
pkgs.subversion
|
||||||
|
pkgs.gnused
|
||||||
|
pkgs.file
|
||||||
|
pkgs.perl
|
||||||
|
pkgs.flock
|
||||||
|
pkgs.bash
|
||||||
|
pkgs.gnugrep
|
||||||
|
pkgs.coreutils-full
|
||||||
|
pkgs.binutils
|
||||||
|
pkgs.gcc
|
||||||
|
pkgs.gnupatch
|
||||||
|
pkgs.gzip
|
||||||
|
pkgs.bzip2
|
||||||
|
pkgs.gnutar
|
||||||
|
pkgs.cacert
|
||||||
|
pkgs.python3Full
|
||||||
|
pkgs.lzma
|
||||||
|
pkgs.gdbm
|
||||||
|
pkgs.readline
|
||||||
|
|
||||||
|
]
|
||||||
|
++ qtPaths
|
||||||
|
++ gtkPaths;
|
||||||
|
};
|
||||||
|
}
|
||||||
17
examples/buildroot_nix-build.nix
Normal file
17
examples/buildroot_nix-build.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
|
let
|
||||||
|
|
||||||
|
buildroot = pkgs.callPackage ../buildroot.nix {};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.stdenv.mkDerivation rec {
|
||||||
|
name = "makeBuildRoot";
|
||||||
|
phases = "installPhase";
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp ${buildroot.makeBuildRoot.command}/bin/makeBuildRoot $out/bin/makeBuildRoot
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
30
examples/buildroot_nix-docker.nix
Normal file
30
examples/buildroot_nix-docker.nix
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
|
let
|
||||||
|
|
||||||
|
buildroot = pkgs.callPackage ../buildroot.nix {};
|
||||||
|
|
||||||
|
buildrootBaseImage = pkgs.dockerTools.pullImage {
|
||||||
|
imageName = "buildroot/base";
|
||||||
|
imageDigest = "sha256:d81f16ae5635f1548fe3a9dafef5f41932fa5a209368cb7d74fa9a8dea2b2b07";
|
||||||
|
finalImageName = "buildroot/base";
|
||||||
|
finalImageTag = "20210922.2200";
|
||||||
|
sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8";
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.dockerTools.buildImage {
|
||||||
|
name = "buildroot-nix";
|
||||||
|
tag = "latest";
|
||||||
|
|
||||||
|
fromImage = buildrootBaseImage;
|
||||||
|
|
||||||
|
contents = [
|
||||||
|
buildroot.package
|
||||||
|
buildroot.makeBuildRoot.command
|
||||||
|
buildroot.makeBuildRoot.scriptPaths
|
||||||
|
];
|
||||||
|
|
||||||
|
config.Cmd = [ "${pkgs.bash}/bin/bash" ];
|
||||||
|
}
|
||||||
|
|
||||||
25
examples/buildroot_nix-shell.nix
Normal file
25
examples/buildroot_nix-shell.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
|
let
|
||||||
|
|
||||||
|
buildroot = pkgs.callPackage ../buildroot.nix {};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
name = "buildroot-shell";
|
||||||
|
buildInputs = buildroot.makeBuildRoot.paths ++ [
|
||||||
|
buildroot.package
|
||||||
|
buildroot.makeBuildRoot.command
|
||||||
|
];
|
||||||
|
hardeningDisable = [ "all" ];
|
||||||
|
shellHook = ''
|
||||||
|
alias make='makeBuildRoot'
|
||||||
|
'';
|
||||||
|
phases = [ "nobuildPhase" ];
|
||||||
|
nobuildPhase = ''
|
||||||
|
echo
|
||||||
|
echo "This derivation is not meant to be built, aborting";
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user