~ruther/vhdl-i2c

5c521b431117d51e3fe87ffee66efc0fd1ff289e — Rutherther 9 months ago 1c83890
chore: add vunit_lib linking mechanism and vhdl_ls.toml for lsp
3 files changed, 63 insertions(+), 135 deletions(-)

M flake.lock
M flake.nix
A vhdl_ls.toml
M flake.lock => flake.lock +1 -115
@@ 1,44 1,5 @@
{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1694529238,
        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nix-github-actions": {
      "inputs": {
        "nixpkgs": [
          "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": 1705697961,


@@ 55,84 16,9 @@
        "type": "github"
      }
    },
    "poetry2nix": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nix-github-actions": "nix-github-actions",
        "nixpkgs": [
          "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": {
        "nixpkgs": "nixpkgs",
        "poetry2nix": "poetry2nix"
      }
    },
    "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": [
          "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"
        "nixpkgs": "nixpkgs"
      }
    }
  },

M flake.nix => flake.nix +19 -20
@@ 1,25 1,17 @@
{
  description = "NSV stopwatch";
  description = "NSV I2C env";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    poetry2nix = {
      url = "github:nix-community/poetry2nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, poetry2nix, nixpkgs }:
  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        system = "${system}";
      };
      inherit (poetry2nix.lib.mkPoetry2Nix {
        inherit pkgs;
      }) mkPoetryPackages mkPoetryScriptsPackage mkPoetryApplication defaultPoetryOverrides;
      pkgs = nixpkgs.legacyPackages.${system};

      python-env = pkgs.python311.withPackages(ps: [
      python = pkgs.python311;
      python-env = python.withPackages(ps: [
        (ps.buildPythonPackage rec {
          pname = "vunit-hdl";
          version = "4.7.0";


@@ 51,7 43,7 @@
        meta.mainProgram = "nvc";
        paths = [
          pkgs.ghdl
          # pkgs.nvc
          pkgs.nvc
        ];
      };
    in {


@@ 90,22 82,22 @@
          ];
        };

        default = pkgs.mkShell {
        default = pkgs.mkShell rec {
          packages = [
            vhdl-toolchain

            (pkgs.rustPlatform.buildRustPackage rec {
                pname = "vhdl-ls";
                version = "0.77.0-patched";
                version = "0.81.0";

                src = pkgs.fetchFromGitHub {
                  owner = "Rutherther";
                  owner = "VHDL-LS";
                  repo = "rust_hdl";
                  rev = "return-new-line";
                  hash = "sha256-EYG6Rycnq9unTTVk9Iy6ivnbr8sT1U7vnNGnnZefSqk=";
                  rev = "348e42da73fc1d5b3ac2ed51f6d056a7af46d171";
                  hash = "sha256-F8LQijA7XcZyGipd0gG7SOQro38iltSmDGSWtbu6Umc=";
                };

                cargoHash = "sha256-YkeepkJLq95e9X2v+1AxMBmT0q4ARJXA1WB89/KmTcY=";
                cargoHash = "sha256-hkmaMzeQLd3l6A3xyLAZk+MrEeUKPd7H2N4Nsz7nBmk=";

                postPatch = ''
                  substituteInPlace vhdl_lang/src/config.rs \


@@ 121,6 113,13 @@
            python-env
          ];

          PYTHON_SITE_PACKAGES = "${python-env}/${python.sitePackages}";
          VUNIT_VHDL_LIB = "${PYTHON_SITE_PACKAGES}/vunit/vhdl";

          shellHook = ''
            ln -s ${VUNIT_VHDL_LIB} ./libs/vunit
          '';

          VUNIT_SIMULATOR = "nvc";
        };
      };

A vhdl_ls.toml => vhdl_ls.toml +43 -0
@@ 0,0 1,43 @@
[libraries]
i2c.files = [
  'src/i2c/*.vhd',
  'src/i2c/**/*.vhd'
]

utils.files = [
  'src/utils/*.vhd',
  'src/utils/**/*.vhd'
]

ssd1306.files = [
  'src/ssd1306/*.vhd',
  'src/ssd1306/**/*.vhd'
]

ssd1306_tb.files = [
  'tb/ssd1306/*.vhd',
  'tb/ssd1306/**/*.vhd'
]

mcu_slave.files = [
  'src/mcu_slave/*.vhd',
  'src/mcu_slave/**/*.vhd'
]

i2c_tb.files = [
  'tb/i2c/*.vhd',
  'tb/i2c/**/*.vhd'
]

mcu_slave_tb.files = [
  'tb/mcu_slave/*.vhd',
  'tb/mcu_slave/**/*.vhd'
]

# This is linked by nix shell. If you aren't using
# nix to setup the env, link this yourself to vunit
# vhdl directory
vunit_lib.files = [
  'libs/vunit/*.vhd',
  'libs/vunit/**/*.vhd',
]

Do not follow this link