Skip to content

Commit

Permalink
Add nix support
Browse files Browse the repository at this point in the history
  • Loading branch information
AliasQli committed Dec 3, 2022
1 parent ae7e608 commit 1f797ba
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ elftosb1
rsrctool
sbtoelf
edb
sysigner
sysigner

# nix outputs
result
8 changes: 8 additions & 0 deletions Libs/src/micropython-master/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -e
source $stdenv/setup
mkdir -p $out/lib $TMP/src

cp -R $src $TMP/src/mpy
chmod 755 -R $TMP/src/mpy
cd $TMP/src/mpy/ports/eoslib && make
cp $TMP/libmpy.libc $out/lib/
11 changes: 11 additions & 0 deletions Libs/src/micropython-master/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "micropython-eos";
src = ./.;
builder = ./builder.sh;
buildInputs = [
gcc-arm-embedded
python3
];
}
22 changes: 22 additions & 0 deletions builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e
source $stdenv/setup

mkdir -p $out

cd $src
cp -R $src $TMP/ExistOS
chmod -R 755 $TMP/ExistOS
cd $TMP/ExistOS

echo '#!/bin/sh -e
sysigner $@' >> ./tools/sysigner
chmod +x ./tools/sysigner

echo '#!/bin/sh -e
elftosb $@' >> ./tools/sbtools/elftosb
chmod +x ./tools/sbtools/elftosb

cmake .
make
cp $TMP/ExistOS/OSLoader/OSLoader.sb $out/
cp $TMP/ExistOS/System/ExistOS.sys $out/
14 changes: 14 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "ExistOS";
src = ./.;
builder = ./builder.sh;
buildInputs = [
gcc-arm-embedded
newlib-nano
cmake
(import ./tools/sys_signer/default.nix {})
(import ./tools/sbtools/default.nix {})
];
}
11 changes: 11 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let pkgs = import <nixpkgs> {};
in with pkgs;
pkgs.mkShell {
buildInputs = [
gcc-arm-embedded
newlib-nano
cmake
(import ./tools/sys_signer/default.nix {})
(import ./tools/sbtools/default.nix {})
];
}
9 changes: 9 additions & 0 deletions tools/sbtools/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -e
source $stdenv/setup
mkdir -p $out/bin

cp -R $src $TMP/sbtools
chmod 755 -R $TMP/sbtools
cd $TMP/sbtools && make
cp sbloader $out/bin/
cp elftosb $out/bin/
13 changes: 13 additions & 0 deletions tools/sbtools/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "sbtools";
src = ./.;
builder = ./builder.sh;
buildInputs = [
libusb
cryptopp
udev
pkg-config
];
}
9 changes: 9 additions & 0 deletions tools/sys_signer/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -e
source $stdenv/setup
mkdir -p $out/bin

cd $src
mkdir -p $TMP/sys_signer/build
cmake -B $TMP/sys_signer/build/
cmake --build $TMP/sys_signer/build/
cp $TMP/sys_signer/build/sysigner $out/bin/sysigner
11 changes: 11 additions & 0 deletions tools/sys_signer/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "sys_signer";
src = ./.;
builder = ./builder.sh;
buildInputs = [
cmake
glibc.static
];
}

0 comments on commit 1f797ba

Please sign in to comment.