]> Repositorios git - scryer-prolog.git/commitdiff
flake.nix
authorbakaq <[email protected]>
Tue, 13 Aug 2024 17:27:48 +0000 (14:27 -0300)
committerbakaq <[email protected]>
Wed, 14 Aug 2024 02:43:05 +0000 (23:43 -0300)
.envrc [new file with mode: 0644]
.gitignore
flake.lock [new file with mode: 0644]
flake.nix [new file with mode: 0644]

diff --git a/.envrc b/.envrc
new file mode 100644 (file)
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
index f63be9e995dbf7eb57fa698a265de129f3bf3502..c2e60e69b1d7da15f346429e4a732c2ebaaaff4f 100644 (file)
@@ -1,5 +1,5 @@
 src/static_atoms.rs
 target/
-
+.direnv/
 
 
diff --git a/flake.lock b/flake.lock
new file mode 100644 (file)
index 0000000..c1bd692
--- /dev/null
@@ -0,0 +1,82 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1723541349,
+        "narHash": "sha256-LrmeqqHdPgAJsVKIJja8jGgRG/CA2y6SGT2TjX5Do68=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "4877ea239f4d02410c3516101faf35a81af0c30e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs",
+        "rust-overlay": "rust-overlay"
+      }
+    },
+    "rust-overlay": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1723515680,
+        "narHash": "sha256-nHdKymsHCVIh0Wdm4MvSgxcTTg34FJIYHRQkQYaSuvk=",
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "rev": "4ee3d9e9569f70d7bb40f28804d6fe950c81eab3",
+        "type": "github"
+      },
+      "original": {
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "type": "github"
+      }
+    },
+    "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 (file)
index 0000000..64cc682
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,69 @@
+{
+  description = "A modern Prolog implementation written mostly in Rust";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+    flake-utils.url = "github:numtide/flake-utils";
+    rust-overlay = {
+      url = "github:oxalica/rust-overlay";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+  };
+
+  outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
+    let 
+      meta = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package;
+      inherit (meta) name version;
+      overlays = [ 
+        (import rust-overlay)
+        (self: super: {
+          rustToolchainDev = super.rust-bin.stable.latest.default.override {
+            extensions = [ "rust-src" "rust-analyzer" ];
+          };
+          rustToolchainNightly = super.rust-bin.selectLatestNightlyWith (toolchain:
+            toolchain.default.override {
+              extensions = [ "rust-src" "rust-analyzer" "miri" ];
+            }
+          );
+        })
+      ];
+    in flake-utils.lib.eachDefaultSystem(system:
+      let 
+        pkgs = import nixpkgs { inherit system overlays; };
+        nativeBuildInputs = with pkgs; [ pkg-config ];
+        buildInputs = with pkgs; [ openssl ];
+      in
+      {
+        devShells = {
+          default = pkgs.mkShell {
+            nativeBuildInputs = nativeBuildInputs;
+            buildInputs = buildInputs ++ (with pkgs; [
+              rustToolchainDev
+            ]);
+          };
+          # For use with Miri and stuff like it
+          nightly = pkgs.mkShell {
+            nativeBuildInputs = nativeBuildInputs;
+            buildInputs = buildInputs ++ (with pkgs; [
+              rustToolchainNightly
+            ]);
+          };
+        };
+
+        packages = rec {
+          default = scryer-prolog;
+          scryer-prolog = pkgs.rustPlatform.buildRustPackage {
+            pname = name;
+            inherit version;
+            src = ./.;
+            nativeBuildInputs = nativeBuildInputs;
+            buildInputs = buildInputs;
+            cargoLock = {
+              lockFile = ./Cargo.lock;
+            };
+            release = true;
+          };
+        };
+      }
+    );
+}