Browse Source

Cleanup

master
Emery Hemingway 4 months ago
parent
commit
9a12b98960
  1. 7
      flake.nix
  2. 4
      hydra.json
  3. 4
      nixos-modules/hardware/default.nix
  4. 12
      nixos-modules/lib/make-bootable-image.nix
  5. 3
      overlay/default.nix
  6. 3
      overlay/llvm-11/llvm.nix
  7. 33
      overlay/openssl/genode.patch
  8. 1
      packages/genodelabs/default.nix
  9. 13
      packages/genodelabs/patches/libc-port.patch
  10. 31
      packages/genodelabs/patches/test-vmm_x86.patch
  11. 7
      packages/genodelabs/ports.nix
  12. 46
      tests/bash.nix
  13. 1
      tests/hello.dhall

7
flake.nix

@ -70,8 +70,8 @@
with builtins;
let
pkg' = prev.getOutput output pkg;
erisInfo =
fromJSON (readFile "${pkg'}/nix-support/eris-manifest.json");
erisInfo = fromJSON (builtins.unsafeDiscardStringContext
(readFile "${pkg'}/nix-support/eris-manifest.json"));
caps = filter
({ path, ... }: prev.strings.hasPrefix "${pkg'}/${output}" path)
(prev.attrsets.mapAttrsToList (path:
@ -90,7 +90,8 @@
pkg' = prev.getOutput output pkg;
path' = "${pkg'}/${output}/${file}";
erisInfo =
fromJSON (readFile "${pkg'}/nix-support/eris-manifest.json");
fromJSON (builtins.unsafeDiscardStringContext
(readFile "${pkg'}/nix-support/eris-manifest.json"));
caps = filter ({ path, ... }: path == path')
(prev.attrsets.mapAttrsToList (path:
{ cap, closure }: {

4
hydra.json

@ -2,8 +2,8 @@
"enabled": 1,
"hidden": 1,
"type": 1,
"flake": "git+https://git.sr.ht/~ehmry/genodepkgs",
"description": "Genode Nix packages",
"flake": "git+https://gitea.c3d2.de/ehmry/sigil.git",
"description": "Sigil distro",
"checkinterval": 300,
"schedulingshares": 100,
"enableemail": false,

4
nixos-modules/hardware/default.nix

@ -1,7 +1,9 @@
{ config, pkgs, lib, ... }:
with lib;
let toDhall = lib.generators.toDhall { };
let
cfg = config.hardware.genode;
toDhall = lib.generators.toDhall { };
in {
imports = [ ./ahci.nix ./framebuffer.nix ./nic.nix ./usb.nix ];

12
nixos-modules/lib/make-bootable-image.nix

@ -1,7 +1,9 @@
# Builds a compressed EFI System Partition image
{ config, lib, pkgs }:
pkgs.stdenv.mkDerivation {
let cfg = config.block.partitions;
in pkgs.stdenv.mkDerivation {
name = "boot.qcow2";
nativeBuildInputs = with pkgs.buildPackages.buildPackages; [
@ -20,12 +22,12 @@ pkgs.stdenv.mkDerivation {
# Concatentenate the ESP
espByteOffset=$(stat --printf='%s' $img)
zstdcat ${esp.image} >> $img
zstdcat ${cfg.esp.image} >> $img
truncate --size=%1M $img
# Concatenate the store
storeByteOffset=$(stat --printf='%s' $img)
zstdcat ${store.image} >> $img
zstdcat ${cfg.store.image} >> $img
truncate --size=%1M $img
# Pad the end of the image
@ -38,8 +40,8 @@ pkgs.stdenv.mkDerivation {
sfdisk $img <<EOF
label: gpt
label-id: $disklabel
start=$(( $storeByteOffset / $sectorSize )), uuid=${config.block.partitions.store.guid}, type=${store.gptType}
start=$(( $espByteOffset / $sectorSize )), uuid=${config.block.partitions.esp.guid}, type=${esp.gptType}
start=$(( $storeByteOffset / $sectorSize )), uuid=${cfg.store.guid}, type=${cfg.store.gptType}
start=$(( $espByteOffset / $sectorSize )), uuid=${cfg.esp.guid}, type=${cfg.esp.gptType}
EOF
sfdisk --reorder $img

3
overlay/default.nix

@ -208,7 +208,8 @@ in nullPkgs // {
++ builtins.filter (x: x != "bin" && x != "out") attrs.outputs;
patches = attrs.patches or [ ] ++ [ ./openssl/genode.patch ];
configureScript = {
x86_64-genode = "./Configure Genode-x86_64";
x86_64-genode = "./Configure genode-x86_64";
aarch64-genode = "./Configure genode-aarch64";
}.${stdenv.hostPlatform.system} or (throw
"Not sure what configuration to use for ${stdenv.hostPlatform.config}");
configureFlags = attrs.configureFlags ++ [ "no-devcryptoeng" ];

3
overlay/llvm-11/llvm.nix

@ -112,7 +112,8 @@ in stdenv.mkDerivation (rec {
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${buildPackages.llvm_10}/bin/llvm-tblgen"
];
] ++ optional (stdenv.targetPlatform.isx86) "-DLLVM_TARGETS_TO_BUILD=X86"
++ optional (stdenv.targetPlatform.isAarch64) "-DLLVM_TARGETS_TO_BUILD=AArch64";
postBuild = ''
rm -fR $out

33
overlay/openssl/genode.patch

@ -1,31 +1,44 @@
diff -ur a/Configurations/10-main.conf b/Configurations/10-main.conf
--- a/Configurations/10-main.conf 2019-09-10 18:43:07.000000000 +0530
+++ b/Configurations/10-main.conf 2020-05-27 16:03:09.416462556 +0530
@@ -1559,6 +1559,28 @@
perlasm_scheme => "macosx",
--- a/Configurations/10-main.conf 2021-03-25 08:28:38.000000000 -0500
+++ b/Configurations/10-main.conf 2022-04-24 14:10:45.424394509 -0500
@@ -1567,6 +1567,42 @@
perlasm_scheme => "ios64",
},
+##### Genode
+ "Genode-x86_32" => {
+ "genode-generic32" => {
+ inherit_from => [ "BASE_unix" ],
+ CC => "cc",
+ CFLAGS => picker(default => "-Wall",
+ debug => "-O0 -g",
+ release => "-O3"),
+ cflags => threads("-pthread"),
+ cppflags => threads("-D_THREAD_SAFE -D_REENTRANT"),
+ bn_ops => "BN_LLONG",
+ thread_scheme => "pthreads",
+ dso_scheme => "dlfcn",
+ shared_target => "linux-shared",
+ shared_target => "bsd-shared",
+ shared_cflag => "-fPIC",
+ shared_extension => ".so",
+ perlasm_scheme => "elf",
+ },
+ "Genode-x86_64" => {
+ inherit_from => [ "Genode-x86_32", asm("x86_64_asm") ],
+ "genode-generic64" => {
+ inherit_from => [ "genode-generic32" ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
+ },
+
+ "genode-x86_32" => {
+ inherit_from => [ "genode-generic32", asm("x86_asm") ],
+ lib_cppflags => add("-DL_ENDIAN"),
+ bn_ops => "BN_LLONG",
+ },
+ "genode-x86_64" => {
+ inherit_from => [ "genode-generic64", asm("x86_64_asm") ],
+ lib_cppflags => add("-DL_ENDIAN"),
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
+ },
+ "genode-aarch64" => {
+ inherit_from => [ "genode-generic64", asm("aarch64_asm") ],
+ },
+
##### GNU Hurd
"hurd-x86" => {

1
packages/genodelabs/default.nix

@ -118,6 +118,7 @@ let
''
runHook preInstall
chmod -R +w $CONTRIB_DIR/*
find $CONTRIB_DIR/* -name cache -exec rm -rf {} \; || true
find $CONTRIB_DIR/* -name .git -exec rm -rf {} \; || true
find $CONTRIB_DIR/* -name .svn -exec rm -rf {} \; || true
find $CONTRIB_DIR/* -name '*.t?z' -exec rm -rf {} \; || true

13
packages/genodelabs/patches/libc-port.patch

@ -0,0 +1,13 @@
diff --git a/repos/libports/ports/libc.port b/repos/libports/ports/libc.port
index 927cf923a6..b276c57968 100644
--- a/repos/libports/ports/libc.port
+++ b/repos/libports/ports/libc.port
@@ -4,7 +4,7 @@ DOWNLOADS = libc.archive
D = src/lib/libc
-URL(libc) = http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.0-RELEASE/src.txz
+URL(libc) = http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/amd64/12.0-RELEASE/src.txz
SHA(libc) = 0da393ac2174168a71c1c527d1453e07372295187d05c288250800cb152a889b
DIR(libc) = $(D)

31
packages/genodelabs/patches/test-vmm_x86.patch

@ -1,31 +1,32 @@
diff --git a/repos/os/src/test/vmm_x86/component.cc b/repos/os/src/test/vmm_x86/component.cc
index 1bfbd58db7..d56a561061 100644
index 408c1088e2..1672f2a468 100644
--- a/repos/os/src/test/vmm_x86/component.cc
+++ b/repos/os/src/test/vmm_x86/component.cc
@@ -492,8 +492,9 @@ class Vmm {
@@ -530,6 +530,8 @@ class Vmm::Main
{
private:
- Genode::Signal_handler<Vmm> _destruct_handler;
- Genode::Reconstructible<Vm> _vm;
+ Genode::Env &_env;
+ Genode::Signal_handler<Vmm> _destruct_handler;
+ Genode::Reconstructible<Vm> _vm;
+ Genode::Env &_env;
+
Signal_handler<Main> _destruct_handler;
Reconstructible<Vm> _vm;
void _destruct()
{
@@ -502,12 +503,14 @@ class Vmm {
@@ -540,14 +542,16 @@ class Vmm::Main
_vm.destruct();
Genode::log("vmm test finished");
log("vmm test finished");
+ _env.parent().exit(0);
}
public:
Vmm(Genode::Env &env)
Main(Env &env)
:
- _destruct_handler(env.ep(), *this, &Main::_destruct),
- _vm(env, _destruct_handler)
+ _env(env),
_destruct_handler(env.ep(), *this, &Vmm::_destruct),
_vm(env, _destruct_handler)
+ _destruct_handler(_env.ep(), *this, &Main::_destruct),
+ _vm(_env, _destruct_handler)
{
}
};

7
packages/genodelabs/ports.nix

@ -12,9 +12,9 @@ with pkgs;
};
coreutils.hash = "sha256-ZVlFfLghHcXxwwRsN5xw2bVdIvvXoCNj2oZniOlSXrg=";
curl.hash = "sha256-5+nRKLrho9oO0XlzDO6ppZ2kLfWaIReY24YFYSQT7Xc=";
dde_bsd.hash = "sha256-KPA/ua3jETcHgWzhfhFm6ppds55Xi5YXJKDJvufJmU8=";
# dde_bsd.hash = "sha256-KPA/ua3jETcHgWzhfhFm6ppds55Xi5YXJKDJvufJmU8=";
dde_ipxe.hash = "sha256-rnMbramSDYBEjfSMoNpFcUQ4jfJh6SIHMtieSy9/Fe4=";
dde_linux.hash = "sha256-PBj/pTbCTZVtqqppnQyFtwH3G5qrQABBKxK19uVuT8U=";
dde_linux.hash = "sha256-DOPa+Bi/dV9NVSCQa0GOapQsNbZQBhZ4gtcTq3TiAGw=";
dde_rump = {
hash = "sha256-Wr5otGkWEa+5xImsFHQzwap5LckNEbyWA/7xbNcOreI=";
nativeBuildInputs = [ subversion ];
@ -31,8 +31,9 @@ with pkgs;
jitterentropy.hash = "sha256-6KS732GxtUMz0xPYKtshdn039DgdJq11vTDQesZn4Ds=";
jpeg.hash = "sha256-RLVnlrnYGrhqr3Feikoi/BNditCaKN0u3t9/UDpl2wQ=";
libc = {
hash = "sha256-BSZcO25jbH8+OkJWGyJxxVYuQ4Y3yDt0DNsYcITwqxA=";
hash = "sha256-/LX0uGiWLE+wNdbjNKr9CbzwqSPocHv5XBZuymJy1Gw=";
nativeBuildInputs = [ gcc rpcsvc-proto ];
patches = [ ./patches/libc-port.patch ];
};
libiconv.hash = "sha256-25YcW5zo1fE33ZolGQroR+KZO8wHEdN1QXa7+MhwS78=";
libpng.hash = "sha256-hNmSWN4gEk4UIjzkGD4j5qFooMCVXLwcBeOeFumvh+4=";

46
tests/bash.nix

@ -1,29 +1,31 @@
{
name = "bash";
machine = { config, lib, modulesPath, pkgs, ... }: {
genode.init.children.bash = let
extraErisInputs' = with pkgs.genodePackages; {
bash = lib.getEris "bin" pkgs.bash;
cached_fs_rom = lib.getEris "bin" cached_fs_rom;
vfs = lib.getEris "bin" vfs;
vfs_pipe = lib.getEris "lib" vfs_pipe;
};
params = {
bash = "${pkgs.bash}";
coreutils = "${pkgs.coreutils}";
cached_fs_rom = extraErisInputs'.cached_fs_rom.cap;
vfs = extraErisInputs'.vfs.cap;
vfs_pipe = extraErisInputs'.vfs_pipe.cap;
};
machine = { config, lib, modulesPath, pkgs, ... }:
let toDhall = lib.generators.toDhall { };
in {
package = pkgs.genodePackages.init;
extraErisInputs = builtins.attrValues extraErisInputs';
configFile = pkgs.writeText "bash.child.dhall" ''
${./bash.dhall} ${lib.generators.toDhall params}
'';
extraInputs = with pkgs.genodePackages; [ pkgs.bash libc posix ];
genode.init.children.bash = let
extraErisInputs' = with pkgs.genodePackages; {
bash = lib.getEris "bin" pkgs.bash;
cached_fs_rom = lib.getEris "bin" cached_fs_rom;
vfs = lib.getEris "bin" vfs;
vfs_pipe = lib.getEris "lib" vfs_pipe;
};
params = {
bash = "${pkgs.bash}";
coreutils = "${pkgs.coreutils}";
cached_fs_rom = extraErisInputs'.cached_fs_rom.cap;
vfs = extraErisInputs'.vfs.cap;
vfs_pipe = extraErisInputs'.vfs_pipe.cap;
};
in {
package = pkgs.genodePackages.init;
extraErisInputs = builtins.attrValues extraErisInputs';
configFile = pkgs.writeText "bash.child.dhall" ''
${./bash.dhall} ${toDhall params}
'';
extraInputs = with pkgs.genodePackages; [ pkgs.bash libc posix ];
};
};
};
testScript = ''
start_all()
machine.wait_until_serial_output('child "bash" exited with exit value 0')

1
tests/hello.dhall

@ -12,6 +12,7 @@ in λ(binary : Text) →
Child.flat
Child.Attributes::{
, binary
, exitPropagate = True
, resources = Sigil.Init.Resources::{
, caps = 500
, ram = Sigil.units.MiB 10

Loading…
Cancel
Save