Skip to content

Commit aaa6673

Browse files
committed
add the basis for nix CI
1 parent 34a6c86 commit aaa6673

6 files changed

Lines changed: 135 additions & 2 deletions

File tree

arch/vc4/intc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct handlerArgPair irq_handlers[64];
1919
// it will then push pc and sr onto the new stack
2020
// it will then read an entry from this vector table, and set the PC to that entry
2121
// if the highest bit on this addr is set, the cpu will switch into supervisor mode
22-
irqType __attribute__ ((aligned (512))) vectorTable[128]; // might only need to be 128 entries
22+
irqType __attribute__ ((aligned (512))) vectorTable[128];
2323

2424
uint8_t irq_stack0[4096];
2525

default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ in {
2121
inherit (arm7) littlekernel;
2222
};
2323
vc4 = {
24-
inherit (vc4) littlekernel;
24+
shell = vc4.littlekernel;
25+
rpi3.bootcode = vc4.callPackage ./lk.nix { project = "rpi3-bootcode"; };
26+
rpi4.start4 = vc4.callPackage ./lk.nix { project = "rpi4-start4"; };
2527
};
2628
x86_64 = {
2729
inherit (x86_64) uart-manager;

nix/sources.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"niv": {
3+
"branch": "master",
4+
"description": "Easy dependency management for Nix projects",
5+
"homepage": "https://github.com/nmattia/niv",
6+
"owner": "nmattia",
7+
"repo": "niv",
8+
"rev": "61b61d1e5f8096fe65fb825bec23f33e861c51d0",
9+
"sha256": "1dwfkd942wisccpsv0kf47abl0n17d9v4zasv4bm8lvy1dhv82ia",
10+
"type": "tarball",
11+
"url": "https://github.com/nmattia/niv/archive/61b61d1e5f8096fe65fb825bec23f33e861c51d0.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"nixpkgs": {
15+
"branch": "nixos-19.03",
16+
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
17+
"homepage": "https://github.com/NixOS/nixpkgs",
18+
"owner": "NixOS",
19+
"repo": "nixpkgs-channels",
20+
"rev": "c8db7a8a16ee9d54103cade6e766509e1d1c8d7b",
21+
"sha256": "1b3h4mwpi10blzpvgsc0191k4shaw3nw0qd2p82hygbr8vv4g9dv",
22+
"type": "tarball",
23+
"url": "https://github.com/NixOS/nixpkgs-channels/archive/c8db7a8a16ee9d54103cade6e766509e1d1c8d7b.tar.gz",
24+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+
},
26+
"rpi-open-firmware": {
27+
"branch": "master",
28+
"description": "Open source VPU side bootloader for Raspberry Pi.",
29+
"homepage": null,
30+
"owner": "cleverca22",
31+
"repo": "rpi-open-firmware",
32+
"rev": "b2d019aca2cc788a8f656ea28ca91c0df9ff7291",
33+
"sha256": "1kiimh0gbjai6nbd1i06kbk1ymvhyr4xqd0196048hq8a9wf8kdb",
34+
"type": "tarball",
35+
"url": "https://github.com/cleverca22/rpi-open-firmware/archive/b2d019aca2cc788a8f656ea28ca91c0df9ff7291.tar.gz",
36+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+
}
38+
}

nix/sources.nix

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# This file has been generated by Niv.
2+
3+
# A record, from name to path, of the third-party packages
4+
with rec
5+
{
6+
pkgs =
7+
if hasNixpkgsPath
8+
then
9+
if hasThisAsNixpkgsPath
10+
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
11+
else import <nixpkgs> {}
12+
else
13+
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
14+
15+
sources_nixpkgs =
16+
if builtins.hasAttr "nixpkgs" sources
17+
then sources.nixpkgs
18+
else abort
19+
''
20+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
21+
add a package called "nixpkgs" to your sources.json.
22+
'';
23+
24+
# fetchTarball version that is compatible between all the versions of Nix
25+
builtins_fetchTarball =
26+
{ url, sha256 }@attrs:
27+
let
28+
inherit (builtins) lessThan nixVersion fetchTarball;
29+
in
30+
if lessThan nixVersion "1.12" then
31+
fetchTarball { inherit url; }
32+
else
33+
fetchTarball attrs;
34+
35+
# fetchurl version that is compatible between all the versions of Nix
36+
builtins_fetchurl =
37+
{ url, sha256 }@attrs:
38+
let
39+
inherit (builtins) lessThan nixVersion fetchurl;
40+
in
41+
if lessThan nixVersion "1.12" then
42+
fetchurl { inherit url; }
43+
else
44+
fetchurl attrs;
45+
46+
# A wrapper around pkgs.fetchzip that has inspectable arguments,
47+
# annoyingly this means we have to specify them
48+
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip attrs;
49+
50+
# A wrapper around pkgs.fetchurl that has inspectable arguments,
51+
# annoyingly this means we have to specify them
52+
fetchurl = { url, sha256 }@attrs: pkgs.fetchurl attrs;
53+
54+
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
55+
hasThisAsNixpkgsPath =
56+
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
57+
58+
sources = builtins.fromJSON (builtins.readFile ./sources.json);
59+
60+
mapAttrs = builtins.mapAttrs or
61+
(f: set: with builtins;
62+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
63+
64+
# borrowed from nixpkgs
65+
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
66+
callFunctionWith = autoArgs: f: args:
67+
let auto = builtins.intersectAttrs (functionArgs f) autoArgs;
68+
in f (auto // args);
69+
70+
getFetcher = spec:
71+
let fetcherName =
72+
if builtins.hasAttr "type" spec
73+
then builtins.getAttr "type" spec
74+
else "builtin-tarball";
75+
in builtins.getAttr fetcherName {
76+
"tarball" = fetchzip;
77+
"builtin-tarball" = builtins_fetchTarball;
78+
"file" = fetchurl;
79+
"builtin-url" = builtins_fetchurl;
80+
};
81+
};
82+
# NOTE: spec must _not_ have an "outPath" attribute
83+
mapAttrs (_: spec:
84+
if builtins.hasAttr "outPath" spec
85+
then abort
86+
"The values in sources.json should not have an 'outPath' attribute"
87+
else
88+
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
89+
then
90+
spec //
91+
{ outPath = callFunctionWith spec (getFetcher spec) { }; }
92+
else spec
93+
) sources

0 commit comments

Comments
 (0)