Split up into several derivations
[soc.git] / flake.nix
1 # The license for this file is included in the `nix` directory next to this file.
2
3 {
4 description = "FOSS CPU/GPU/VPU/SoC all in one, see https://libre-soc.org/";
5
6 inputs.nixpkgs.url = "github:L-as/nixpkgs?ref=libresoc"; # for alliance and migen
7 inputs.c4m-jtag.url = "git+https://git.libre-soc.org/git/c4m-jtag.git";
8 inputs.c4m-jtag.flake = false;
9 inputs.nmigen.url = "git+https://git.libre-soc.org/git/nmigen.git";
10 inputs.nmigen.flake = false;
11 inputs.nmigen-soc.url = "git+https://git.libre-soc.org/git/nmigen-soc.git";
12 inputs.nmigen-soc.flake = false;
13 inputs.nix-litex.url = "github:L-as/tock-litex";
14 inputs.nix-litex.flake = false;
15
16 outputs = { self, nixpkgs, c4m-jtag, nmigen, nmigen-soc, nix-litex }:
17 let
18 getv = x: builtins.substring 0 8 x.lastModifiedDate;
19
20 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
21
22 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
23
24 nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
25
26 litexPkgs = pkgs: import "${nix-litex}/pkgs" { inherit pkgs; };
27 in
28 {
29 overlay = final: prev: {
30 python3Packages = prev.python3Packages.override {
31 overrides = pfinal: pprev: {
32 libresoc-ieee754fpu = pfinal.callPackage ./nix/ieee754fpu.nix {};
33 libresoc-openpower-isa = pfinal.callPackage ./nix/openpower-isa.nix {};
34 c4m-jtag = pfinal.callPackage (import ./nix/c4m-jtag.nix { src = c4m-jtag; version = getv c4m-jtag; }) {};
35 bigfloat = pfinal.callPackage ./nix/bigfloat.nix {};
36 modgrammar = pfinal.callPackage ./nix/modgrammar.nix {};
37 libresoc-nmutil = pfinal.callPackage ./nix/nmutil.nix {};
38 libresoc-soc = pfinal.callPackage (import ./nix/soc.nix { version = getv self; }) {};
39
40 nmigen-soc = pprev.nmigen-soc.overrideAttrs (_: {
41 doCheck = false;
42 src = nmigen-soc;
43 setuptoolsCheckPhase = "true";
44 });
45
46 nmigen = pprev.nmigen.overrideAttrs (_: {
47 src = nmigen;
48 });
49 };
50 };
51
52 libresoc-pre-litex = final.callPackage (import ./nix/pre-litex.nix { version = getv self; }) {};
53 libresoc-ilang = final.callPackage (import ./nix/ilang.nix { version = getv self; litexPkgs = litexPkgs final; }) {};
54 libresoc-pinmux = final.callPackage (import ./nix/pinmux.nix { version = getv self; }) {};
55 };
56
57 packages = forAllSystems (system: {
58 soc = nixpkgsFor.${system}.python3Packages.libresoc-soc;
59 pre-litex = nixpkgsFor.${system}.libresoc-pre-litex;
60 pinmux = nixpkgsFor.${system}.libresoc-pinmux;
61 ilang = nixpkgsFor.${system}.libresoc-ilang;
62 openpower-isa = nixpkgsFor.${system}.python3Packages.libresoc-openpower-isa;
63 });
64
65 defaultPackage = forAllSystems (system: self.packages.${system}.pre-litex);
66 };
67 }