-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using-nix/0-prebuilt: add (and revamp all restricted seeding)
- Loading branch information
Showing
17 changed files
with
200 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# This is to support building protosrc/tinycc from nixpkgs, see comment in 0.nix | ||
|
||
let | ||
nixpkgs = import (builtins.fetchTarball { | ||
name = "pinned-nixpkgs"; | ||
url = "https://github.com/nixos/nixpkgs/archive/a898a9d1f0503d3b2c66a5bbf8ac459003d3c843.tar.gz"; | ||
sha256 = "sha256:0m70w5rw5adz3riwh4m4x0vh5z8w0w8nlr1ajwi43ridma30vs8f"; | ||
}) { system = "x86_64-linux"; }; | ||
|
||
tinycc-unliberated = nixpkgs.pkgsStatic.tinycc.overrideAttrs(oa: { | ||
version = "unstable-2021-10-30"; | ||
src = nixpkgs.fetchFromRepoOrCz { | ||
repo = "tinycc"; | ||
rev = "da11cf651576f94486dbd043dbfcde469e497574"; | ||
sha256 = "sha256-LWdM/1fjx88eCj+Bz4YN9zLEWhSjlX4ULZiPx82nocA="; | ||
}; | ||
configureFlags = nixpkgs.lib.remove "--enable-cross" oa.configureFlags; | ||
}); | ||
|
||
tinycc-liberated = derivation { | ||
name = "tinycc-liberated"; | ||
builder = "/bin/sh"; | ||
args = [ "-uexc" '' | ||
${nixpkgs.pkgs.gnused}/bin/sed \ | ||
's|/nix/store/.\{32\}-|!nix!store/................................-|g' \ | ||
< ${tinycc-unliberated}/bin/tcc \ | ||
> $out | ||
! ${nixpkgs.pkgs.gnugrep}/bin/grep -i /nix/store $out | ||
${nixpkgs.pkgs.coreutils}/bin/chmod +x $out | ||
'']; | ||
allowedReferences = [ ]; | ||
allowedRequisites = [ ]; | ||
system = "x86_64-linux"; | ||
__contentAddressed = true; | ||
outputHashAlgo = "sha256"; outputHashMode = "recursive"; | ||
outputHash = "sha256-ADunchN4nGrE7OJ9OxkuzwsIDOW8I9/GukeiQMwhNIs="; | ||
}; | ||
|
||
source-tarball-musl = builtins.fetchurl { | ||
url = "http://musl.libc.org/releases/musl-1.2.2.tar.gz"; | ||
sha256 = "9b969322012d796dc23dda27a35866034fa67d8fb67e0e2c45c913c3d43219dd"; | ||
}; | ||
|
||
source-tarball-busybox = builtins.fetchurl { | ||
url = "https://busybox.net/downloads/busybox-1.34.1.tar.bz2"; | ||
sha256 = "415fbd89e5344c96acf449d94a6f956dbed62e18e835fc83e064db33a34bd549"; | ||
}; | ||
|
||
source-tarball-tinycc = builtins.fetchurl { | ||
url = "https://github.com/TinyCC/tinycc/archive/da11cf651576f94486dbd043dbfcde469e497574.tar.gz"; | ||
sha256 = "c6b244e58677c4c486dbf80e35ee01b192e133876942afa07454159ba118b44e"; | ||
}; | ||
|
||
protosrc = derivation { | ||
name = "protosrc"; | ||
builder = "/bin/sh"; | ||
args = [ "-uexc" '' | ||
PATH=${nixpkgs.coreutils}/bin | ||
PATH=$PATH:${nixpkgs.gnused}/bin | ||
PATH=$PATH:${nixpkgs.gnutar}/bin | ||
PATH=$PATH:${nixpkgs.gzip}/bin | ||
PATH=$PATH:${nixpkgs.bzip2}/bin | ||
export PATH | ||
mkdir downloads/ | ||
cp ${source-tarball-musl} downloads/musl-1.2.2.tar.gz | ||
cp ${source-tarball-busybox} downloads/busybox-1.34.1.tar.bz2 | ||
cp ${source-tarball-tinycc} downloads/tinycc-mob-gitda11cf6.tar.gz | ||
mkdir -p recipes | ||
cp -r ${../recipes/1-stage1} recipes/1-stage1 | ||
DESTDIR=$out ${nixpkgs.bash}/bin/bash \ | ||
${../recipes/1-stage1/seed.host-executed.sh} | ||
mv $out/protosrc/* $out/; rm -d $out/protosrc | ||
'']; | ||
allowedReferences = [ ]; | ||
allowedRequisites = [ ]; | ||
system = "x86_64-linux"; | ||
__contentAddressed = true; | ||
outputHashAlgo = "sha256"; outputHashMode = "recursive"; | ||
outputHash = "sha256-VPbQvwJOmtld+kTBXdzwrR346L6qT7KhhpUsKu6/IfM="; | ||
}; | ||
in | ||
{ | ||
tinycc = tinycc-liberated; | ||
inherit protosrc; | ||
} |
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,30 @@ | ||
# This is to prefetch protosrc/tinycc from github, see comment in 0.nix | ||
|
||
let | ||
fetchTarball = { name, url, sha256 }: derivation { | ||
inherit name url; | ||
urls = [ url ]; | ||
unpack = true; | ||
|
||
builder = "builtin:fetchurl"; | ||
system = "builtin"; | ||
outputHashMode = "recursive"; outputHashAlgo = "sha256"; | ||
preferLocalBuild = true; | ||
outputHash = sha256; | ||
}; | ||
in | ||
{ | ||
protosrc = fetchTarball { | ||
name = "protosrc"; | ||
url = "http:///127.0.0.1:8000/protosrc.tar.gz"; | ||
#url = "https://github.com/ZilchOS/bootstrap-from-tcc/.../protosrc.tar.gz"; | ||
sha256 = "sha256-VPbQvwJOmtld+kTBXdzwrR346L6qT7KhhpUsKu6/IfM="; | ||
}; | ||
|
||
tinycc = fetchTarball { | ||
name = "tinycc-liberated"; | ||
url = "http:///127.0.0.1:8000/tinycc-liberated.nar"; | ||
#url = "https://github.com/ZilchOS/bootstrap-from-tcc/.../tinycc-liberated.tar.gz"; | ||
sha256 = "sha256-ADunchN4nGrE7OJ9OxkuzwsIDOW8I9/GukeiQMwhNIs="; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,99 +1,35 @@ | ||
# Where do tcc-seed and protosrc come from if you build with Nix? | ||
|
||
# When building with `make` or `build.sh` you'll have tcc-seed and protosrc | ||
# long long before you have Nix, | ||
# so there's no question of where to take them from, you just inject'em. | ||
# In this case this file isn't used at all and a simpler 0.nix is generated, | ||
# see recipes/4-rebootstrap-using-nix.sh | ||
|
||
# But not everyone wants to go the full bootstrap route. | ||
# This file is for when you already have Nix and want to jump into the middle, | ||
# starting from the second, `using-nix` half of the bootstrap. | ||
# Cases like hydra or flake-building. | ||
|
||
# You ought to start from some tcc | ||
# and do the initial source patching with something. | ||
|
||
# Hope in the future there'll be neater ways to do that, | ||
# or at least a tarball published somewhere, | ||
# but currently it just builds both using nixpkgs | ||
# and ensures they have no dependencies: | ||
|
||
let | ||
nixpkgs = import (builtins.fetchTarball { | ||
name = "pinned-nixpkgs"; | ||
url = "https://github.com/nixos/nixpkgs/archive/a898a9d1f0503d3b2c66a5bbf8ac459003d3c843.tar.gz"; | ||
sha256 = "sha256:0m70w5rw5adz3riwh4m4x0vh5z8w0w8nlr1ajwi43ridma30vs8f"; | ||
}) { system = "x86_64-linux"; }; | ||
|
||
tinycc-unliberated = nixpkgs.pkgsStatic.tinycc.overrideAttrs(oa: { | ||
version = "unstable-2021-10-30"; | ||
src = nixpkgs.fetchFromRepoOrCz { | ||
repo = "tinycc"; | ||
rev = "da11cf651576f94486dbd043dbfcde469e497574"; | ||
sha256 = "sha256-LWdM/1fjx88eCj+Bz4YN9zLEWhSjlX4ULZiPx82nocA="; | ||
}; | ||
configureFlags = nixpkgs.lib.remove "--enable-cross" oa.configureFlags; | ||
}); | ||
|
||
tinycc-liberated = derivation { | ||
name = "tinycc-liberated"; | ||
builder = "/bin/sh"; | ||
args = [ "-uexc" '' | ||
${nixpkgs.pkgs.gnused}/bin/sed \ | ||
's|/nix/store/.\{32\}-|!nix!store/................................-|g' \ | ||
< ${tinycc-unliberated}/bin/tcc \ | ||
> $out | ||
! ${nixpkgs.pkgs.gnugrep}/bin/grep -i /nix/store $out | ||
${nixpkgs.pkgs.coreutils}/bin/chmod +x $out | ||
'']; | ||
allowedReferences = [ ]; | ||
allowedRequisites = [ ]; | ||
system = "x86_64-linux"; | ||
__contentAddressed = true; | ||
outputHashAlgo = "sha256"; outputHashMode = "recursive"; | ||
}; | ||
# One option is to build them using nixpkgs (see 0-from-nixpkgs.nix), | ||
# but then you need nixpkgs, IFD and stuff. | ||
|
||
source-tarball-musl = builtins.fetchurl { | ||
url = "http://musl.libc.org/releases/musl-1.2.2.tar.gz"; | ||
sha256 = "9b969322012d796dc23dda27a35866034fa67d8fb67e0e2c45c913c3d43219dd"; | ||
}; | ||
# Alternatively we could download them prebuilt from github:ZilchOS, | ||
# but then there's the question of falling back to another method | ||
# when recipes/1-stage1/seed.host-executed.sh or recipes/1-stage1/syscall.h | ||
# are updated. | ||
|
||
source-tarball-busybox = builtins.fetchurl { | ||
url = "https://busybox.net/downloads/busybox-1.34.1.tar.bz2"; | ||
sha256 = "415fbd89e5344c96acf449d94a6f956dbed62e18e835fc83e064db33a34bd549"; | ||
}; | ||
# Here's one weird combined approach: | ||
|
||
source-tarball-tinycc = builtins.fetchurl { | ||
url = "https://github.com/TinyCC/tinycc/archive/da11cf651576f94486dbd043dbfcde469e497574.tar.gz"; | ||
sha256 = "c6b244e58677c4c486dbf80e35ee01b192e133876942afa07454159ba118b44e"; | ||
}; | ||
|
||
protosrc = derivation { | ||
name = "protosrc"; | ||
builder = "/bin/sh"; | ||
args = [ "-uexc" '' | ||
PATH=${nixpkgs.coreutils}/bin | ||
PATH=$PATH:${nixpkgs.gnused}/bin | ||
PATH=$PATH:${nixpkgs.gnutar}/bin | ||
PATH=$PATH:${nixpkgs.gzip}/bin | ||
PATH=$PATH:${nixpkgs.bzip2}/bin | ||
export PATH | ||
mkdir downloads/ | ||
cp ${source-tarball-musl} downloads/musl-1.2.2.tar.gz | ||
cp ${source-tarball-busybox} downloads/busybox-1.34.1.tar.bz2 | ||
cp ${source-tarball-tinycc} downloads/tinycc-mob-gitda11cf6.tar.gz | ||
mkdir -p recipes | ||
cp -r ${../recipes/1-stage1} recipes/1-stage1 | ||
DESTDIR=$out ${nixpkgs.bash}/bin/bash \ | ||
${../recipes/1-stage1/seed.host-executed.sh} | ||
mv $out/protosrc/* $out/; rm -d $out/protosrc | ||
'']; | ||
allowedReferences = [ ]; | ||
allowedRequisites = [ ]; | ||
system = "x86_64-linux"; | ||
__contentAddressed = true; | ||
outputHashAlgo = "sha256"; outputHashMode = "recursive"; | ||
}; | ||
let | ||
and = builtins.all (x: x); | ||
syscall_h_ours = ../recipes/1-stage1/syscall.h; | ||
syscall_h_reference = "/nix/store/gh596yjx16c7p4l7djwl34aljsn0a21w-syscall.h"; | ||
syscall_h_is_unmodified = (syscall_h_ours == syscall_h_reference); | ||
stage1_seeder_ours = ../recipes/1-stage1/seed.host-executed.sh; | ||
stage1_seeder_reference = "/nix/store/8y505dqkkn80mvpg3pxz2gqmfardbg8h-seed.host-executed.sh"; | ||
stage1_seeder_is_unmodified = (stage1_seeder_ours == stage1_seeder_reference); | ||
in | ||
{ | ||
tinycc = tinycc-liberated; | ||
inherit protosrc; | ||
} | ||
if (and [ syscall_h_is_unmodified stage1_seeder_is_unmodified ]) | ||
then import ./0-from-nixpkgs.nix | ||
else import ./0-prebuilt.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
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
Oops, something went wrong.