Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
53 lines (50 loc) · 1.7 KB
/
Copy pathflake.nix
File metadata and controls
53 lines (50 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# srs: the s4 kernel built from its seed. bootstrap/srs_seed.c is the C the image emits for itself
# (fixpoint: the kernel built from it emits it again byte for byte); bootstrap/srs_rt.c is the runtime.
# The image source is ./srs (one unit per file); `nix build` gives bin/srs.
{
description = "srs: the s4 kernel, built from its self-emitted seed";
inputs.nixpkgs.url = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz";
outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
];
each = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in
{
packages = each (pkgs: rec {
srs = pkgs.stdenv.mkDerivation {
pname = "srs";
version = "0";
src = ./bootstrap;
dontConfigure = true;
# -O1: measured 9.7 s build and 0.09 s per check (vic/prompt.md 7.1)
buildPhase = ''
runHook preBuild
$CC -std=gnu11 -O1 -w -o srs srs_seed.c srs_rt.c -lm
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 srs $out/bin/srs
runHook postInstall
'';
meta.mainProgram = "srs";
};
default = srs;
});
# `nix develop`: the C compilers the kernel and its programs are built with, just (Justfile) and valgrind
devShells = each (pkgs: {
default = pkgs.mkShell {
packages = [
pkgs.just
pkgs.gcc # the kernel: gcc -O1 (9.7 s build, 0.09 s per check)
pkgs.tinycc # small programs: 0.1 s builds
pkgs.valgrind
];
};
});
};
}