forked from cnlohr/mini-rv32ima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
84 lines (84 loc) · 3.07 KB
/
flake.nix
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:cleverca22/nixpkgs/riscv-uclibc";
#nixpkgs2.url = "path:/home/clever/apps/nixpkgs-master3";
};
outputs = { self, utils, nixpkgs }:
let
overlay = _: _: {
inherit self;
};
in
(utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "riscv32-nommu" "riscv32-nommu-musl" "x86_64-windows" ] (system:
let
hostLut = {
"x86_64-linux" = "x86_64-linux";
"aarch64-linux" = "aarch64-linux";
"riscv32-nommu" = "x86_64-linux";
"riscv32-nommu-musl" = "x86_64-linux";
"x86_64-windows" = "x86_64-linux";
};
pkgs_raw = import nixpkgs { system = "x86_64-linux"; };
pkgs_ = import nixpkgs {
system = hostLut.${system};
overlays = [ overlay (import ./overlay.nix) ];
config.allowUnsupportedSystem = true;
};
targetLut = {
"x86_64-linux" = x: x;
"aarch64-linux" = x: x;
"riscv32-nommu" = x: x.pkgsCross.riscv32-nommu;
"riscv32-nommu-musl" = x: x.pkgsCross.riscv32-nommu-musl;
"x86_64-windows" = x: x.pkgsCross.mingwW64;
};
pkgs = targetLut.${system} pkgs_;
mkDoTest = http: extra:
let
os = pkgs.callPackage ./os.nix { extraModules = extra; };
in
pkgs.writeShellScriptBin "dotest" ''
${pkgs.mini-rv32ima.override { inherit http; }}/bin/full-rv32ima -f ${os.toplevel}/Image -i ${os.toplevel}/initrd "$@"
'';
tests = {
default = mkDoTest false [];
http = mkDoTest true [];
doom = mkDoTest false [ ./configuration-fbdoom.nix ];
doom-http = mkDoTest true [ ./configuration-fbdoom.nix ];
windows-test = let
os = (pkgs_.callPackage ./os.nix { extraModules = []; }).toplevel;
in pkgs.writeShellScriptBin "windows-test" ''
export PATH=$PATH:${pkgs.wine64}/bin/
ls -lh ${self.packages.${system}.windows-rv32ima}/bin/
wine64 ${self.packages.${system}.windows-rv32ima}/bin/full-rv32ima.exe -f ${os}/Image -i ${os}/initrd
'';
};
in {
packages = tests // (import ./packages.nix pkgs);
devShells = {
default = pkgs.stdenv.mkDerivation {
name = "shell";
buildInputs = [
(pkgs.enableDebugging pkgs.pkgsCross.riscv32.buildPackages.gdb)
pkgs.pkgsCross.riscv32.buildPackages.binutils
pkgs_raw.qemu
];
};
kernel = pkgs.pkgsCross.riscv32-nommu.linux.overrideDerivation (drv: {
nativeBuildInputs = drv.nativeBuildInputs ++ (with pkgs; [ ncurses pkg-config ]);
makeFlags = drv.makeFlags ++ [ "O=rv32" ];
shellHook = ''
addToSearchPath PKG_CONFIG_PATH ${pkgs.ncurses.dev}/lib/pkgconfig
echo to configure: 'make $makeFlags menuconfig'
echo to build: 'time make $makeFlags zImage -j8'
'';
});
};
hydraJobs = import ./hydra-jobs.nix { inherit self system pkgs; };
})) // {
nixConfig = {
substituters = [ "https://hydra.angeldsis.com" "https://cache.nixos.org" ];
trusted-public-keys = [ "hydra.angeldsis.com-1:7s6tP5et6L8Y6sX7XGIwzX5bnLp00MtUQ/1C9t1IBGE=" ];
};
};
}