From 6edfd9fe5064bbc6fe8a0ac6fa596943b2597523 Mon Sep 17 00:00:00 2001 From: Sashanoraa Date: Wed, 8 Mar 2023 16:29:25 -0500 Subject: [PATCH] Add nix flake --- .gitignore | 1 + flake.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..d787b70 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fa5f2f1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "crate2nix": { + "flake": false, + "locked": { + "lastModified": 1678256065, + "narHash": "sha256-gZK7UPeL5276Zbjamo8zWDPDxYi6S81sumCKeZr69Vo=", + "owner": "kolloch", + "repo": "crate2nix", + "rev": "a00ef13cd769496bf937b16f16acad01fd004e1f", + "type": "github" + }, + "original": { + "owner": "kolloch", + "repo": "crate2nix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678306555, + "narHash": "sha256-3C/ivszxgGeItTKkU2Mcn9LrBKLpO3BK0LUPPXKUJtw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3d57138bd9abe31bae25704cebaab7527010cc5e", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crate2nix": "crate2nix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fbd96b8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2021 Serokell +# +# SPDX-License-Identifier: CC0-1.0 + +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + crate2nix = { + url = "github:kolloch/crate2nix"; + flake = false; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, crate2nix, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + crateName = "kitty-img"; + + inherit (import "${crate2nix}/tools.nix" { inherit pkgs; }) + generatedCargoNix; + + project = import (generatedCargoNix { + name = crateName; + src = ./.; + }) { + inherit pkgs; + defaultCrateOverrides = pkgs.defaultCrateOverrides // { + # Crate dependency overrides go here + }; + }; + + in { + packages.${crateName} = project.rootCrate.build; + + defaultPackage = self.packages.${system}.${crateName}; + + devShell = pkgs.mkShell { + inputsFrom = builtins.attrValues self.packages.${system}; + buildInputs = [ pkgs.cargo pkgs.rust-analyzer pkgs.clippy ]; + }; + }); +} -- 2.45.2