From 627a1a18104c85080beb4f3fe92fe020e41fe423 Mon Sep 17 00:00:00 2001 From: Stefan Ellmauthaler <71695780+ellmau@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:00:39 +0200 Subject: [PATCH] Add flake app and packages for adf-bdd (#155) * Add flake packages for adf-bdd --- Cargo.lock | 2 +- bin/Cargo.toml | 2 +- flake.lock | 37 ++++++++-------- flake.nix | 112 +++++++++++++++++++++++++++++++------------------ 4 files changed, 93 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 547bfd6..ac1a65b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "adf-bdd-bin" -version = "0.3.0" +version = "0.3.0-dev" dependencies = [ "adf_bdd", "assert_cmd", diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 8d99deb..da2739a 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "adf-bdd-bin" -version = "0.3.0" +version = "0.3.0-dev" authors = ["Stefan Ellmauthaler "] edition = "2021" homepage = "https://ellmau.github.io/adf-obdd" diff --git a/flake.lock b/flake.lock index 73539df..f08b868 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,24 @@ { "nodes": { "flake-utils": { + "inputs": { + "flake-utils": "flake-utils_2" + }, + "locked": { + "lastModified": 1657226504, + "narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -18,22 +36,6 @@ "type": "github" } }, - "gitignoresrc": { - "flake": false, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1690927903, @@ -69,15 +71,14 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "gitignoresrc": "gitignoresrc", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable", "rust-overlay": "rust-overlay" } }, "rust-overlay": { "inputs": { "flake-utils": [ + "flake-utils", "flake-utils" ], "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 1655a27..eae50b8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,57 +1,89 @@ -{ - description = "basic rust flake"; +rec { + description = "adf-bdd, Abstract Dialectical Frameworks solved by Binary Decision Diagrams; developed in Dresden"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; - nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; + flake-utils.follows = "flake-utils/flake-utils"; }; }; - flake-utils.url = "github:numtide/flake-utils"; - gitignoresrc = { - url = "github:hercules-ci/gitignore.nix"; - flake = false; - }; + flake-utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; }; - outputs = { + outputs = inputs @ { self, - nixpkgs, - nixpkgs-unstable, flake-utils, - gitignoresrc, rust-overlay, ... - } @ inputs: - { - #overlay = import ./nix { inherit gitignoresrc; }; - } - // (flake-utils.lib.eachDefaultSystem (system: let - unstable = import nixpkgs-unstable {inherit system;}; - pkgs = import nixpkgs { - inherit system; - overlays = [(import rust-overlay)]; - }; - in rec { - devShell = pkgs.mkShell { - RUST_LOG = "debug"; - RUST_BACKTRACE = 1; - buildInputs = [ - pkgs.rust-bin.stable.latest.rustfmt - pkgs.rust-bin.stable.latest.default - pkgs.rust-analyzer - pkgs.cargo-audit - pkgs.cargo-license - pkgs.cargo-tarpaulin - pkgs.cargo-kcov - pkgs.valgrind - pkgs.gnuplot - pkgs.kcov - ]; + }: + flake-utils.lib.mkFlake { + inherit self inputs; + channels.nixpkgs.overlaysBuilder = channels: [rust-overlay.overlays.default]; + outputsBuilder = channels: let + pkgs = channels.nixpkgs; + toolchain = pkgs.rust-bin.stable.latest.default; + platform = pkgs.makeRustPlatform { + cargo = toolchain; + rustc = toolchain; + }; + in rec { + packages = let + cargoMetaBin = (builtins.fromTOML (builtins.readFile ./bin/Cargo.toml)).package; + cargoMetaLib = (builtins.fromTOML (builtins.readFile ./lib/Cargo.toml)).package; + meta = { + inherit description; + homepage = "https://github.com/ellmau/adf-obdd"; + license = [pkgs.lib.licenses.mit]; + + nativeBuildInputs = with platform; [ + cargoBuildHook + cargoCheckHook + ]; + }; + in rec { + adf-bdd = platform.buildRustPackage { + pname = "adf-bdd"; + inherit (cargoMetaBin) version; + inherit meta; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + + buildAndTestSubdir = "bin"; + }; + adf_bdd = platform.buildRustPackage { + pname = "adf_bdd"; + inherit (cargoMetaLib) version; + inherit meta; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + + buildAndTestSubdir = "lib"; + }; + }; + devShells.default = pkgs.mkShell { + RUST_LOG = "debug"; + RUST_BACKTRACE = 1; + shellHook = '' + export PATH=''${HOME}/.cargo/bin''${PATH+:''${PATH}} + ''; + buildInputs = let + notOn = systems: + pkgs.lib.optionals (!builtins.elem pkgs.system systems); + in + [ + toolchain + pkgs.rust-analyzer + pkgs.cargo-audit + pkgs.cargo-license + ] + ++ (notOn ["aarch64-darwin" "x86_64-darwin"] [pkgs.kcov pkgs.cargo-kcov pkgs.gnuplot pkgs.valgrind]) + ++ (notOn ["aarch64-linux" "aarch64-darwin" "i686-linux"] [pkgs.cargo-tarpaulin]); + }; }; - })); + }; }