diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4ce4b7e..73601e9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - lfs: 'true' + lfs: "true" - run: rustup update - uses: Swatinem/rust-cache@v2 - run: cargo test --workspace @@ -64,3 +64,10 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo install typos-cli || true - run: typos + nix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + - uses: DeterminateSystems/magic-nix-cache-action@main + - run: nix flake check diff --git a/.gitignore b/.gitignore index 69870079..0b6aafde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ target Cargo.lock /docs/book/ +/.direnv +/result .DS_Store diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..cb46fcd4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1694081375, + "narHash": "sha256-vzJXOUnmkMCm3xw8yfPP5m8kypQ3BhAIRe4RRCWpzy8=", + "owner": "nix-community", + "repo": "naersk", + "rev": "3f976d822b7b37fc6fb8e6f157c2dd05e7e94e89", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1696725822, + "narHash": "sha256-B7uAOS7TkLlOg1aX01rQlYbydcyB6ZnLJSfaYbKVww8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5aabb5780a11c500981993d49ee93cfa6df9307b", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1696725822, + "narHash": "sha256-B7uAOS7TkLlOg1aX01rQlYbydcyB6ZnLJSfaYbKVww8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5aabb5780a11c500981993d49ee93cfa6df9307b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + } + }, + "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..7b191e5c --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nix-community/naersk"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = { self, flake-utils, naersk, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; + naersk' = pkgs.callPackage naersk {}; + nativeBuildInputs = with pkgs; [ pkg-config ]; + in rec { + packages.default = naersk'.buildPackage { + inherit nativeBuildInputs; + src = ./.; + buildInputs = with pkgs; [ openssl ]; + }; + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; nativeBuildInputs ++ [ + cargo + rustc + ]; + }; + checks.builds = packages.default; + } + ); +}