From a4d29644f7116976cb0b626c49b152332adc52dc Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 28 Sep 2021 20:14:17 +0200 Subject: [PATCH] feat: add flake --- README.md | 39 ++++++++++++++++++++++++++++++++++++++- default.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 41 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 17 +++++++++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 26b1db1..d5331e4 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,41 @@ image inspired by the ``` cargo run --example clipping -- --help # run the examples/clipping -``` \ No newline at end of file +``` +# How to Build (with flakes) + +```shell +nix build +``` +or (if you haven't enabled flakes yet) + +``` shell +nix-shell -p nixFlake --run "nix build" +``` + +# How to us it (with flakes) + +``` nix +{ + description = "example usage"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05"; + inputs.polygon-art.url = "git+https://git.ingolf-wagner.de/palo/polygon-art.git"; + inputs.polygon-art.inputs.nixpkgs.follows = "nixpkgs"; + outputs = { self, nixpkgs, polygon-art, ... }: { + nixosConfigurations.example = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ({ pkgs, ... }: { + nixpkgs.overlays = [ + (_self: _super: { + polygon-art = polygon-art.packages.${pkgs.system}; + }) + ]; + environment.systemPackages = [ pkgs.polygon-art.polygon-art ]; + }) + ]; + }; + }; +} +``` + diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..e9fb6c5 --- /dev/null +++ b/default.nix @@ -0,0 +1,47 @@ +{ rustPlatform, + fetchgit, + lib, + cairo, + geos, + clipper, + clang, + pkg-config, + cmake, + openssl, + llvmPackages, + ... }: + +rustPlatform.buildRustPackage { + + pname = "polygon-art"; + + version = "1.0.0"; + + # nix-prefetch-git-rendered --rev refs/heads/develop https://git.ingolf-wagner.de/palo/polygon-art.git + #src = fetchgit { + # url = "https://git.ingolf-wagner.de/palo/polygon-art.git"; + # rev = "dfb6e0789ec67ee649050ad3b16d8b6a6b38955d"; + # sha256 = "0iqmikvl93pazxfd120hcr0waxav7zy6px5kmdqxifrjgdbda9xx"; + #}; + src = ./.; + + #cargoSha256 = "05rkn8iihj4j9k179xx7wn2a07hxks050raj6fbxmj6gdx6aj170"; + cargoSha256 = "0sgk4hw77cxqbqzd258fz67r7fpjblkm7cqh14n5f1c43y8vgxa0"; + verifyCargoDeps = true; + + # Needed so bindgen can find libclang.so + LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; + + buildInputs = [ cairo geos clipper openssl ]; + + nativeBuildInputs = + [ cmake llvmPackages.clang llvmPackages.libclang pkg-config ]; + + meta = with lib; { + description = "Framework with examples to generate plotter friendly SVGs"; + homepage = "https://git.ingolf-wagner.de/palo/polygon-art.git"; + license = licenses.gpl3Plus; + maintainers = [ maintainers.mrVanDalo ]; + }; +} + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e4ba231 --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1632855891, + "narHash": "sha256-crW76mt9/kbUBiKy/KiSnsQ9JEYgD3StDuYAMVkTbM0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "73086069ebd402e85eaa39c06aef33c2b917f532", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d92c23b --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "Framework with examples to generate plotter friendly SVGs"; + + #inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils , ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + polygon-art = (pkgs.callPackage ./default.nix {}); + in { + packages.polygon-art = polygon-art; + defaultPackage = polygon-art; + } + ); +}