-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5cbadfd
Showing
11 changed files
with
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
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,3 @@ | ||
target | ||
result* | ||
.direnv |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[workspace] | ||
|
||
members = ["tinyboot"] |
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,14 @@ | ||
{ pkgsStatic, lib, ... }: | ||
let | ||
cargoTOML = lib.importTOML ./tinyboot/Cargo.toml; | ||
in | ||
pkgsStatic.rustPlatform.buildRustPackage { | ||
pname = cargoTOML.package.name; | ||
version = cargoTOML.package.version; | ||
src = ./.; | ||
buildAndTestSubdir = "tinyboot"; | ||
cargoLock.lockFile = ./Cargo.lock; | ||
postInstall = '' | ||
ln -s $out/bin/tinyboot $out/init | ||
''; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
description = "A small '/init' for linuxboot"; | ||
inputs = { | ||
nixpkgs.url = "nixpkgs/nixos-unstable"; | ||
}; | ||
outputs = inputs: with inputs; | ||
let | ||
forAllSystems = f: nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: f { | ||
inherit system; | ||
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; | ||
}); | ||
in | ||
{ | ||
overlays.default = final: prev: { | ||
tinyboot = prev.callPackage ./. { }; | ||
tinyboot-initramfs = prev.callPackage ./initramfs.nix { | ||
inherit (final) tinyboot; | ||
}; | ||
}; | ||
devShells = forAllSystems ({ pkgs, ... }: { | ||
default = pkgs.mkShell { | ||
buildInputs = with pkgs; [ rustc cargo ]; | ||
}; | ||
}); | ||
packages = forAllSystems ({ pkgs, ... }: { | ||
default = pkgs.tinyboot; | ||
initramfs = pkgs.tinyboot-initramfs; | ||
test = pkgs.callPackage ./test.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,16 @@ | ||
{ lib, buildEnv, runCommand, cpio, xz, pkgsStatic, tinyboot, compressed ? true, ... }: | ||
let | ||
paths = [ /*tinyboot*/ pkgsStatic.busybox ]; | ||
in | ||
runCommand "tinyboot-initramfs" | ||
{ nativeBuildInputs = [ cpio ] ++ (lib.optional compressed xz); } '' | ||
mkdir -p root; ${lib.concatMapStringsSep "; " (p: "cp -r ${p}/. root") paths} | ||
pushd root && | ||
find . -print0 | cpio --null --create --format=newc >../initramfs.cpio && | ||
popd | ||
${if compressed then '' | ||
xz --check=crc32 --lzma2=dict=512KiB <initramfs.cpio >$out | ||
'' else '' | ||
cp initramfs.cpio $out | ||
''} | ||
'' |
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,14 @@ | ||
{ nixosTest, lib, tinyboot-initramfs, ... }: | ||
nixosTest { | ||
name = "tinyboot"; | ||
nodes.machine = { | ||
virtualisation.qemu.options = lib.mkAfter [ | ||
"-initrd ${tinyboot-initramfs}" | ||
"-append \"console=ttyS0 init=/init\"" | ||
]; | ||
}; | ||
testScript = '' | ||
machine.start() | ||
machine.wait_for_console_text("Hello, world!") | ||
''; | ||
} |
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,8 @@ | ||
[package] | ||
name = "tinyboot" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
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,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |