-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from w4tsn/envs-add-buildroot
envs: add buildroot shell.nix
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 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
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,15 @@ | ||
# buildroot | ||
|
||
Buildroot, making embedded Linux easy. | ||
|
||
For more info checkout [buildroot over on GitLab](https://gitlab.com/buildroot.org/buildroot) or on their [website](https://buildroot.org). | ||
|
||
## Remarks | ||
|
||
- works on unstable, but not on 23.11. 24.05 has not been tested. | ||
- For reasons explained in comments this adds two scripts to the shell needed for gcc backwards compatibility | ||
- This adds ccache, which is an optional dependency but one that speeds up consecutive builds tremendously | ||
- Some dependencies are not mentioned in the docs (yet) - they were found by trial and error | ||
- At the time of writing buildroot under nixos suffers from incompatibility between their systemd version and nixos's kernel headers | ||
A patch from the mailing list has to be applied: https://lore.kernel.org/all/[email protected]/T/ | ||
- buildFHSUserEnv is required as buildroot tooling has some hardcoded paths expecting a "usual" linux FS |
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,83 @@ | ||
{ | ||
# Unstable is required as stable does not contain required glib | ||
pkgs ? import (fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz"; # TODO: Remove unstable override, when we have 24.11 | ||
}) { } | ||
, extraPkgs ? [] | ||
}: | ||
let | ||
# POSIX compliant gcc wrappers for backwards compatiblity | ||
# https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/commit/cacf18c7cd79fb00645a4bf367392b05ad2dc290 | ||
# Small change: last line was '${1+"$@"}' which throws causes nix | ||
# to throw an error: add not allowed for integer and string | ||
c98 = pkgs.writeShellScriptBin "c98" '' | ||
set -eu -o pipefail | ||
fl="-std=c89" | ||
for opt; do | ||
case "$opt" in | ||
-ansi|-std=c89|-std=iso9899:1990) fl="";; | ||
-std=*) echo "`basename $0` called with non ANSI/ISO C option $opt" >&2 | ||
exit 1;; | ||
esac | ||
done | ||
exec gcc $fl "$@" | ||
''; | ||
c99 = pkgs.writeShellScriptBin "c99" '' | ||
set -eu -o pipefail | ||
fl="-std=c99" | ||
for opt; do | ||
case "$opt" in | ||
-std=c99|-std=iso9899:1999) fl="";; | ||
-std=*) echo "`basename $0` called with non ISO C99 option $opt" >&2 | ||
exit 1;; | ||
esac | ||
done | ||
exec gcc $fl "$@" | ||
''; | ||
in | ||
# Unfortunately the more versatile and nix-nativ mkShell does not work | ||
# for buildroot as some of the paths are hardcoded and expect a usual | ||
# linux posix-compliant file system structure | ||
(pkgs.buildFHSUserEnv { | ||
name = "buildroot"; | ||
targetPkgs = pkgs: (with pkgs; [ | ||
(lib.hiPrio gcc) | ||
bashInteractive | ||
bc | ||
binutils | ||
bzip2 | ||
c98 | ||
c99 | ||
ccache # optional, speeds up consecutive builds | ||
cmake | ||
cpio | ||
diffutils | ||
expat # not mentioned in buildroot deps; dep of host-libxml-parser-perl | ||
expect # not mentioned in buildroot deps | ||
file | ||
findutils | ||
gcc | ||
glib # not mentioned; not sure if necessary | ||
glibc # transitively mentioned: debian build-essential | ||
gnumake | ||
gnused | ||
gnutar | ||
gzip | ||
libxcrypt # not mentioned in buildroot deps; required for host-mkpasswd | ||
ncurses # optional | ||
patch | ||
perl | ||
pkg-config # not mentioned, unsure if necessary | ||
rsync | ||
unzip | ||
wget | ||
which | ||
] ++ pkgs.linux.nativeBuildInputs ++ extraPkgs); | ||
runScript = '' | ||
# The host-uboot-tools package uses objcopy from the shells OBJCOPY var | ||
# Since the var is set to OBJCOPY=objcopy the buildroot provided | ||
# CROSS_COMPILE path is ignored hence the script is using the wrong objcopy | ||
unset $OBJCOPY | ||
exec bash | ||
''; | ||
}).env |