From 4c4c04ce3f8a3d0d2551708e6af73a44a9722ebd Mon Sep 17 00:00:00 2001 From: Michael van Straten Date: Thu, 7 Nov 2024 12:12:11 +0100 Subject: [PATCH] Add Nix Flake support and CI workflow --- .github/workflows/flake.yml | 32 +++++++++++++++++++ .gitignore | 3 ++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++ flake.nix | 34 +++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 .github/workflows/flake.yml create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml new file mode 100644 index 00000000..9da483ed --- /dev/null +++ b/.github/workflows/flake.yml @@ -0,0 +1,32 @@ +name: Nix Flake CI + +on: + pull_request: + push: + branches: [master] + +jobs: + check-and-build: + name: Check and Build Nix Flake + runs-on: ubuntu-latest + + strategy: + matrix: + system: [x86_64-linux, aarch64-linux] # Check for multiple systems + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v30 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Check Flake + run: nix flake check --all-systems --system ${{ matrix.system }} + + - name: Build Flake + run: nix build .# --system ${{ matrix.system }} + diff --git a/.gitignore b/.gitignore index 06589715..5db17433 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ install_manifest.txt *.dylib *.so *.dll + +# Nix build results +result* diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..ccc9bf27 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..fdf4b88b --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "A Package for Automatic Differentiation of Algorithms Written in C/C++ "; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = + { flake-utils, nixpkgs, ... }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + packages = rec { + adolc-cmake = pkgs.stdenv.mkDerivation { + name = "adolc"; + src = ./.; + nativeBuildInputs = [ pkgs.cmake ]; + }; + + adolc-autotools = adolc-cmake.overrideAttrs ( + _: _: { + nativeBuildInputs = [ pkgs.autoreconfHook ]; + } + ); + + default = adolc-cmake; + }; + } + ); +}