From f37eb4e24342f0b5366f8e452a55dd42cae3e608 Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Sun, 19 May 2024 20:05:21 +0000 Subject: [PATCH] feat(nix): Add flake.nix --- .envrc | 1 + .gitignore | 3 +- flake.lock | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++ 4 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 39124a8..20429b4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /run config.toml config.test.toml -/values.yaml \ No newline at end of file +/values.yaml +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..01797d9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "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" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713520724, + "narHash": "sha256-CO8MmVDmqZX2FovL75pu5BvwhW+Vugc7Q6ze7Hj8heI=", + "owner": "nix-community", + "repo": "naersk", + "rev": "c5037590290c6c7dae2e42e7da1e247e54ed2d49", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716097317, + "narHash": "sha256-1UMrLtgzielG/Sop6gl6oTSM4pDt7rF9j9VuxhDWDlY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8535fb92661f37ff9f0da3007fbc942f7d134b41", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1716097317, + "narHash": "sha256-1UMrLtgzielG/Sop6gl6oTSM4pDt7rF9j9VuxhDWDlY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8535fb92661f37ff9f0da3007fbc942f7d134b41", + "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 0000000..384936d --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + 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 {}; + in rec { + defaultPackage = naersk'.buildPackage { + src = ./.; + buildInputs = with pkgs; [openssl]; + nativeBuildInputs = with pkgs; [pkg-config]; + }; + + devShell = pkgs.mkShell { + buildInputs = with pkgs; [openssl]; + nativeBuildInputs = with pkgs; [rustc cargo rust-analyzer pkg-config clippy]; + }; + + formatter = nixpkgs.legacyPackages.${system}.alejandra; + } + ); +} + -- GitLab