Litex work
[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:lschuermann/nix-litex?ref=staging";
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 litex = pkgs: import "${nix-litex}/pkgs" { inherit pkgs; };
25
26 nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
27
28 lib = nixpkgs.lib;
29 in
30 {
31 overlay = final: prev: {
32 python3Packages = prev.python3Packages.override {
33 overrides = lib.composeExtensions (litex final).pythonOverlay (pfinal: pprev: {
34 libresoc-ieee754fpu = pfinal.callPackage ./nix/ieee754fpu.nix {};
35 libresoc-openpower-isa = pfinal.callPackage ./nix/openpower-isa.nix {};
36 c4m-jtag = pfinal.callPackage (import ./nix/c4m-jtag.nix { src = c4m-jtag; version = getv c4m-jtag; }) {};
37 bigfloat = pfinal.callPackage ./nix/bigfloat.nix {};
38 modgrammar = pfinal.callPackage ./nix/modgrammar.nix {};
39 libresoc-nmutil = pfinal.callPackage ./nix/nmutil.nix {};
40 libresoc-soc = pfinal.callPackage (import ./nix/soc.nix { version = getv self; }) {};
41
42 nmigen-soc = pprev.nmigen-soc.overrideAttrs (_: {
43 doCheck = false;
44 src = nmigen-soc;
45 setuptoolsCheckPhase = "true";
46 });
47
48 nmigen = pprev.nmigen.overrideAttrs (_: {
49 src = nmigen;
50 });
51 });
52 };
53
54 libresoc-pre-litex = final.callPackage (import ./nix/pre-litex.nix { version = getv self; }) {};
55 libresoc-ls180 = final.callPackage (import ./nix/ls180.nix { version = getv self; }) {};
56 libresoc-pinmux = final.callPackage (import ./nix/pinmux.nix { version = getv self; }) {};
57 };
58
59 packages = forAllSystems (system: {
60 soc = nixpkgsFor.${system}.python3Packages.libresoc-soc;
61 pre-litex = nixpkgsFor.${system}.libresoc-pre-litex;
62 pinmux = nixpkgsFor.${system}.libresoc-pinmux;
63 ls180 = nixpkgsFor.${system}.libresoc-ls180;
64 openpower-isa = nixpkgsFor.${system}.python3Packages.libresoc-openpower-isa;
65 });
66
67 defaultPackage = forAllSystems (system: self.packages.${system}.pre-litex);
68 };
69 }