diff --git a/.github/workflows/nix_environment_testing.yaml b/.github/workflows/nix_environment_testing.yaml new file mode 100644 index 00000000..61c7a445 --- /dev/null +++ b/.github/workflows/nix_environment_testing.yaml @@ -0,0 +1,36 @@ +name: nix-flake-test +on: + workflow_dispatch: + push: + branches: [ develop ] + pull_request: + branches: + - develop +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v3 + + # Step 2: Install Nix + - name: Install Nix with Extra Options + run: | + curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/1145 | sh -s -- install --no-confirm --extra-conf " + extra-substituters = https://openlane.cachix.org + extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E= + " + # Step 3: Enable Nix Flakes + - name: Enable Nix Flakes + run: | + mkdir -p ~/.config/nix + echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf + # Step 5: Build the flake with no options + - name: Build Flake + run: nix build . + + # Step 6: Run flake checks/tests + - name: Run Flake Checks + run: nix flake check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd0fee42..e33f29de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,4 +62,4 @@ jobs: - name: Run tests run: | source venv/bin/activate - uv run pytest -rA tests + python -m pytest -rA tests diff --git a/.github/workflows/test_notebooks.yaml b/.github/workflows/test_notebooks.yaml index e943fce4..1eb27214 100644 --- a/.github/workflows/test_notebooks.yaml +++ b/.github/workflows/test_notebooks.yaml @@ -62,4 +62,4 @@ jobs: - name: Run tests run: | source venv/bin/activate - uv run python docs/examples/run_all_notebooks.py + python docs/examples/run_all_notebooks.py diff --git a/.gitignore b/.gitignore index b9ef9c29..6b6231ec 100644 --- a/.gitignore +++ b/.gitignore @@ -201,3 +201,4 @@ RUN_* *.sif .idea/ docs/autoapi/ +result diff --git a/docs/examples/07_full_flow_demo_electronic_photonic/07_full_flow_demo_electronic_photonic.py b/docs/examples/07_full_flow_demo_electronic_photonic/07_full_flow_demo_electronic_photonic.py index e8e89a69..c9ab0a5a 100644 --- a/docs/examples/07_full_flow_demo_electronic_photonic/07_full_flow_demo_electronic_photonic.py +++ b/docs/examples/07_full_flow_demo_electronic_photonic/07_full_flow_demo_electronic_photonic.py @@ -13,7 +13,6 @@ # All the imports we will need throughout this flows. -# + # We begin by importing a parametric circuit from `gdsfactory`: import hdl21 as h import numpy as np @@ -26,9 +25,6 @@ straight_heater_metal_simple, ) - -# - - # First, let's set up the filesystem in the directory in which all our files will be generated and stored. This is really an extension of a full mixed-signal design compatible with the tools supported by `piel`. current_example_directory = piel.return_path(".") @@ -116,6 +112,7 @@ def create_switch_fabric(): chain_fock_state_transitions = piel.flows.get_state_phase_transitions( circuit_component=chain_3_mode_lattice_circuit, models=optical_logic_verification_models, + switch_states=[0, np.pi], mode_amount=3, target_mode_index=2, ) diff --git a/flake.nix b/flake.nix index 0a0f1c9a..9148c104 100644 --- a/flake.nix +++ b/flake.nix @@ -1,64 +1,66 @@ -# file: flake.nix { description = "Python application packaged using poetry2nix and additional EDA tools"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; poetry2nix.url = "github:nix-community/poetry2nix"; - nix-eda.url = "github:efabless/nix-eda"; - openlane2.url = "github:efabless/openlane2"; + nix-eda.url = "github:efabless/nix-eda"; + openlane2.url = "github:efabless/openlane2"; }; outputs = { self, nixpkgs, poetry2nix, nix-eda, openlane2 }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; - edaPkgs = import nix-eda { inherit pkgs; }; - openlane = import openlane2 { inherit pkgs; }; + + # Correctly accessing nix-eda and openlane2 outputs + edaPkgs = nix-eda.packages.${system}; + openlane = openlane2.packages.${system}.openlane; # Verify the exact output name # Use the same Python version as OpenLane python = pkgs.python311Full; - # create a custom "mkPoetryApplication" API function that under the hood uses - # the packages and versions (python3, poetry etc.) from our pinned nixpkgs above: + # Create a custom "mkPoetryApplication" using poetry2nix inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication defaultPoetryOverrides; + # Define build requirements for specific Python packages pypkgs-build-requirements = { - rectpack = [ "setuptools" ]; - vlsir = [ "setuptools" ]; - vlsirtools = [ "setuptools" ]; - hdl21 = [ "flit-core" ]; - sky130-hdl21 = [ "flit-core" ]; - gdsfactory = [ "flit-core" ]; - sky130 = [ "flit-core" ]; - thewalrus = [ "setuptools" ]; + rectpack = [ "setuptools" ]; + vlsir = [ "setuptools" ]; + vlsirtools = [ "setuptools" ]; + hdl21 = [ "flit-core" ]; + sky130-hdl21 = [ "flit-core" ]; + gdsfactory = [ "flit-core" ]; + sky130 = [ "flit-core" ]; + thewalrus = [ "setuptools" ]; }; + + # Extend default poetry overrides with custom build requirements custom_overrides = defaultPoetryOverrides.extend (final: prev: builtins.mapAttrs (package: build-requirements: (builtins.getAttr package prev).overridePythonAttrs (old: { - buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements); + buildInputs = (old.buildInputs or []) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements); }) ) pypkgs-build-requirements ); + # Define the main application using poetry2nix app = mkPoetryApplication { - projectDir = ./.; + projectDir = ./.; preferWheels = true; - extras = [] ; - overrides = custom_overrides; - python=python; + extras = []; + overrides = custom_overrides; + python = python; }; - # Test support for overriding the app passed to the environment - # Override app to depend on hatchling and scikit-build-core + # Override the application to include additional build inputs overridden = app.overrideAttrs (old: { - name = "${old.pname}-overridden-${old.version}"; - nativeBuildInputs = old.nativeBuildInputs or [] ++ [ + name = "${old.pname}-overridden-${old.version}"; + nativeBuildInputs = old.nativeBuildInputs or [] ++ [ pkgs.python3Packages.hatchling pkgs.python3Packages.scikit-build-core pkgs.python3Packages.scikit-learn ]; - # Include scikit-build-core in propagatedBuildInputs to ensure it's available to dependencies propagatedBuildInputs = old.propagatedBuildInputs or [] ++ [ pkgs.python3Packages.hatchling pkgs.python3Packages.scikit-build-core @@ -66,61 +68,50 @@ ]; }); + # Define a dependency environment depEnv = app.dependencyEnv.override { app = overridden; }; - packages.x86_64-linux.piel = nixpkgs.legacyPackages.x86_64-linux.piel; in { - packages.${system} = { - default = app; - python = python; - }; + # Define packages + packages.${system} = { + default = app; + python = python; + }; - apps.${system}.default = { - type = "app"; - # replace