diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..eaf6eadee --- /dev/null +++ b/flake.lock @@ -0,0 +1,174 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "lowrisc-nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix" + }, + "locked": { + "lastModified": 1706718584, + "narHash": "sha256-c/3H6xwhWYmXEmeZMlSnJfYNkA9dnrar2ocgbsxNr90=", + "owner": "lowRISC", + "repo": "lowrisc-nix", + "rev": "f89515c9edf41deb1227a5f111de481de862ec7f", + "type": "github" + }, + "original": { + "owner": "lowRISC", + "repo": "lowrisc-nix", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "lowrisc-nix", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698974481, + "narHash": "sha256-yPncV9Ohdz1zPZxYHQf47S8S0VrnhV7nNhCawY46hDA=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "4bb5e752616262457bc7ca5882192a564c0472d2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705774713, + "narHash": "sha256-j6ADaDH9XiumUzkTPlFyCBcoWYhO83lfgiSqEJF2zcs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1b64fc1287991a9cce717a01c1973ef86cb1af0b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "lowrisc-nix", + "flake-utils" + ], + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "lowrisc-nix", + "nixpkgs" + ], + "systems": "systems_2", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1705060653, + "narHash": "sha256-puYyylgrBS4AFAHeyVRTjTUVD8DZdecJfymWJe7H438=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "e0b44e9e2d3aa855d1dd77b06f067cd0e0c3860d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": [ + "lowrisc-nix", + "flake-utils" + ], + "lowrisc-nix": "lowrisc-nix", + "nixpkgs": [ + "lowrisc-nix", + "nixpkgs" + ] + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "lowrisc-nix", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1699786194, + "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..24368af9d --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "Sonata System"; + inputs = { + lowrisc-nix.url = "github:lowRISC/lowrisc-nix"; + nixpkgs.follows = "lowrisc-nix/nixpkgs"; + flake-utils.follows = "lowrisc-nix/flake-utils"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + lowrisc-nix, + }: let + system_outputs = system: let + sonata_version = "0.0.1"; + + pkgs = import nixpkgs { + inherit system; + }; + lr_pkgs = lowrisc-nix.outputs.packages.${system}; + + sonata-simulator = pkgs.stdenv.mkDerivation { + pname = "sonata-system-simulator"; + version = sonata_version; + src = ./.; + buildInputs = with pkgs; [libelf zlib]; + nativeBuildInputs = [pkgs.python311Packages.pip] ++ (with lr_pkgs; [python_ot verilator_ot]); + buildPhase = '' + HOME=$TMPDIR fusesoc --cores-root=. run \ + --target=sim --tool=verilator --setup \ + --build lowrisc:sonata:system + ''; + installPhase = '' + mkdir -p $out/bin/ + cp -r build/lowrisc_sonata_system_0/sim-verilator/Vsonata_system $out/bin/ + ''; + }; + in { + formatter = pkgs.alejandra; + devShells.default = pkgs.mkShell { + name = "sonata-system-devshell"; + packages = [pkgs.gtkwave] ++ (with sonata-simulator; buildInputs ++ nativeBuildInputs); + }; + packages = {inherit sonata-simulator;}; + }; + in + flake-utils.lib.eachDefaultSystem system_outputs; +}