diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..79038c8 --- /dev/null +++ b/default.nix @@ -0,0 +1,11 @@ +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); +in +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { + src = ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2690eb0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,165 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "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" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1717067539, + "narHash": "sha256-oIs5EF+6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY=", + "owner": "nix-community", + "repo": "naersk", + "rev": "fa19d8c135e776dc97f4dcca08656a0eeb28d5c0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1717399147, + "narHash": "sha256-eCWaE/q1VItpFAxxLVt171MdtDcjEnwi6QB/yuF73JU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4a4ecb0ab415c9fccfb005567a215e6a9564cdf5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717399147, + "narHash": "sha256-eCWaE/q1VItpFAxxLVt171MdtDcjEnwi6QB/yuF73JU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4a4ecb0ab415c9fccfb005567a215e6a9564cdf5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717442957, + "narHash": "sha256-w0fqHofxM2hf3pGDXCPSdH0A09v6FgHm6I38nCWA96k=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "025e1742de4fa75b3fb63818bd9726d17da6a102", + "type": "github" + }, + "original": { + "owner": "oxalica", + "ref": "stable", + "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" + } + }, + "systems_2": { + "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 0000000..87f19b3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs"; + rust-overlay = { + url = "github:oxalica/rust-overlay?ref=stable"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + naersk.url = "github:nix-community/naersk"; + flake-utils = {url = "github:numtide/flake-utils"; flake=true; }; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; + }; + + outputs = {nixpkgs, flake-utils, rust-overlay, naersk, ...}: + flake-utils.lib.eachDefaultSystem (system: let + overlays = [ + rust-overlay.overlays.default + ]; + pkgs = import nixpkgs { inherit system overlays; }; + rust-bin = pkgs.rust-bin.stable."1.78.0".default; + naersk-lib = pkgs.callPackage naersk { + rustc = rust-bin; + cargo = rust-bin; + }; + in with pkgs; + rec { + clio = naersk-lib.buildPackage { + pname = "clio"; + src = ./.; + nativeBuildInputs = [pkgs.pkg-config]; + buildInputs = + ( + if pkgs.stdenv.isDarwin + then with pkgs.darwin.apple_sdk.frameworks; [Security SystemConfiguration] + else [pkgs.openssl] + ) + ++ [rust-bin]; + }; + packages.clio = clio; + packages.default = clio; + devShell = mkShell { + buildInputs = ( + if stdenv.isDarwin then + [ pkgs.darwin.apple_sdk.frameworks.Security pkg-config ] + else + [ ]) ++ [rust-bin]; + }; + }); +}