Skip to content

Commit 48ff88b

Browse files
Merge pull request #7 from Mahmoud-Yasser-18/nix
Adding Nix derivation to the OQD compiler infrastructure
2 parents b065699 + 57db1fc commit 48ff88b

6 files changed

Lines changed: 444 additions & 0 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,55 @@ or alternatively from `git`:
3232
pip install git+https://github.com/OpenQuantumDesign/oqd-compiler-infrastructure.git
3333
```
3434

35+
### Installation with Nix
36+
37+
You can use this package with Nix in several ways:
38+
39+
1. Using the development environment:
40+
```bash
41+
# Clone the repository
42+
git clone https://github.com/OpenQuantumDesign/oqd-compiler-infrastructure.git
43+
cd oqd-compiler-infrastructure
44+
45+
# Enter the development shell
46+
nix develop
47+
```
48+
49+
2. Building the package:
50+
```bash
51+
nix build github:OpenQuantumDesign/oqd-compiler-infrastructure
52+
```
53+
54+
### Using in Your Nix Projects
55+
56+
To use this package in your own Nix project, you can add it to your `flake.nix`:
57+
58+
```nix
59+
{
60+
inputs = {
61+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
62+
oqd-compiler.url = "github:OpenQuantumDesign/oqd-compiler-infrastructure";
63+
};
64+
65+
outputs = { self, nixpkgs, oqd-compiler }: {
66+
# For using in a development shell
67+
devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
68+
buildInputs = [
69+
oqd-compiler.packages.x86_64-linux.default
70+
];
71+
};
72+
73+
# For using as a dependency in your package
74+
packages.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.python3Packages.buildPythonPackage {
75+
# ... your package configuration ...
76+
propagatedBuildInputs = [
77+
oqd-compiler.packages.x86_64-linux.default
78+
];
79+
};
80+
};
81+
}
82+
```
83+
3584
For development, clone the repository locally:
3685

3786
```bash

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2024-2025 Open Quantum Design
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
{
15+
description = "OpenQuantum Design Compiler Infrastructure";
16+
17+
inputs = {
18+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
19+
flake-utils.url = "github:numtide/flake-utils";
20+
};
21+
22+
outputs = { self, nixpkgs, flake-utils }:
23+
flake-utils.lib.eachDefaultSystem (system:
24+
let
25+
pkgs = nixpkgs.legacyPackages.${system};
26+
python = pkgs.python311;
27+
pythonPackages = python.pkgs;
28+
in
29+
{
30+
packages.default = pythonPackages.callPackage ./pkgs/derivation.nix { };
31+
32+
devShells.default = pkgs.mkShell {
33+
packages = with pkgs; [
34+
# Python with dependencies
35+
(python.withPackages (ps: with ps; [
36+
# Core dependencies
37+
pydantic
38+
39+
# Documentation dependencies
40+
pymdown-extensions
41+
mkdocstrings
42+
mkdocs-material
43+
mkdocstrings-python
44+
mdx-truly-sane-lists
45+
46+
# Test dependencies
47+
pytest
48+
49+
# Development tools
50+
pip
51+
black
52+
isort
53+
mypy
54+
]))
55+
56+
# Additional development tools
57+
git
58+
];
59+
60+
shellHook = ''
61+
export PYTHONPATH="$PWD/src:$PYTHONPATH"
62+
echo "OpenQuantum Design Compiler Infrastructure development environment"
63+
echo "Python version: $(python --version)"
64+
'';
65+
};
66+
}
67+
);
68+
}

pkgs/derivation.nix

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2024-2025 Open Quantum Design
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
{ lib
16+
, buildPythonPackage
17+
, pythonOlder
18+
, pydantic
19+
, pytest
20+
, pymdown-extensions
21+
, mkdocstrings
22+
, mkdocs-material
23+
, mkdocstrings-python
24+
, mdx-truly-sane-lists
25+
}:
26+
27+
buildPythonPackage rec {
28+
pname = "oqd-compiler-infrastructure";
29+
version = "0.1.0";
30+
format = "pyproject";
31+
32+
disabled = pythonOlder "3.10";
33+
34+
src = ./..;
35+
36+
propagatedBuildInputs = [
37+
pydantic
38+
];
39+
40+
checkInputs = [
41+
pytest
42+
];
43+
44+
nativeBuildInputs = [
45+
pymdown-extensions
46+
mkdocstrings
47+
mkdocs-material
48+
mkdocstrings-python
49+
];
50+
51+
pythonImportsCheck = [ "oqd_compiler_infrastructure" ];
52+
53+
meta = with lib; {
54+
description = "OpenQuantum Design Compiler Infrastructure";
55+
homepage = "https://github.com/OpenQuantumDesign/oqd-compiler-infrastructure";
56+
license = licenses.apache20;
57+
maintainers = with maintainers; [ ];
58+
};
59+
}

0 commit comments

Comments
 (0)