Skip to content

Commit 0939f08

Browse files
authored
Convert to Nix Flake (#1)
1 parent f83b5a5 commit 0939f08

File tree

5 files changed

+133
-17
lines changed

5 files changed

+133
-17
lines changed

default.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
python3,
3+
buildPythonPackage,
4+
lib,
5+
pytest,
6+
nix-gitignore,
7+
clang,
8+
swig4,
9+
}:
10+
11+
let
12+
yosys = builtins.fetchTarball {
13+
url = "https://github.com/yosyshq/yosys/archive/73cb4977b2e493b840b23419919a63be7c83e6df.tar.gz";
14+
sha256 = "sha256:0rhhx08dia0rd51rp3922vnqzi2fjarz1mrzp27s79k9y5k0mhzk";
15+
};
16+
in
17+
buildPythonPackage rec {
18+
name = "libparse";
19+
20+
version_file = builtins.readFile ./libparse/__version__.py;
21+
version_list = builtins.match ''.+''\n__version__ = "([^"]+)"''\n.+''$'' version_file;
22+
version = builtins.head version_list;
23+
24+
prePatch = ''
25+
cp -r ${yosys} ./yosys
26+
'';
27+
28+
src = (nix-gitignore.gitignoreSourcePure ./.gitignore ./.);
29+
30+
checkPhase = ''
31+
python3 ./test/test.py
32+
'';
33+
34+
nativeBuildInputs = [
35+
clang
36+
swig4
37+
];
38+
39+
meta = with lib; {
40+
description = "Python wrapper around Yosys's libparse";
41+
license = with licenses; [asl20];
42+
homepage = "https://github.com/efabless/libpaprse-python";
43+
platforms = platforms.linux ++ platforms.darwin;
44+
};
45+
}

flake.lock

Lines changed: 26 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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2024 Efabless Corporation
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+
inputs = {
16+
nixpkgs.url = github:nixos/nixpkgs/nixos-23.11;
17+
};
18+
19+
outputs = {
20+
self,
21+
nixpkgs,
22+
...
23+
}: {
24+
# Helper functions
25+
forAllSystems = function:
26+
nixpkgs.lib.genAttrs [
27+
"x86_64-linux"
28+
"aarch64-linux"
29+
"x86_64-darwin"
30+
"aarch64-darwin"
31+
] (
32+
system:
33+
function (import nixpkgs {
34+
inherit system;
35+
})
36+
);
37+
38+
# Outputs
39+
packages = self.forAllSystems (pkgs: let
40+
callPackage = pkgs.lib.callPackageWith (pkgs // self.packages.${pkgs.system});
41+
callPythonPackage = pkgs.lib.callPackageWith (pkgs // pkgs.python3.pkgs // self.packages.${pkgs.system});
42+
in
43+
rec {
44+
libparse = callPythonPackage ./default.nix {};
45+
default = libparse;
46+
}
47+
);
48+
};
49+
}

libparse/__version__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2024 Efabless Corporation
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.
114
__version__ = "0.3.1"
215

316
if __name__ == "__main__":

shell.nix

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)