From cbc093a5d86eaf25737269ba1ccb53c934851f30 Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Thu, 4 Aug 2022 01:59:15 +0300 Subject: [PATCH] flake: Add nix flake --- .envrc | 1 + .gitignore | 1 + flake.lock | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 39 +++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore 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 new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a442066 --- /dev/null +++ b/flake.lock @@ -0,0 +1,92 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1658746384, + "narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=", + "owner": "numtide", + "repo": "devshell", + "rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1643381941, + "narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1659494082, + "narHash": "sha256-XRwMisQY/BcvDMDRVkd4n3/CT89HOtlPgWIQUNPvWSc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8c7576622aeb4707351a17e83429667f42e7d910", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f2d7701 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "Twitter follower counts in Prometheus."; + + inputs.utils.url = "github:numtide/flake-utils"; + inputs.devshell = { + url = "github:numtide/devshell"; + inputs.utils.follows = "utils"; + }; + + outputs = { + self, + nixpkgs, + utils, + devshell, + }: + utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [devshell.overlay]; + }; + in rec { + packages.default = pkgs.buildGoModule { + name = "twitter-prometheus"; + src = self; + vendorSha256 = "PNOP2y6MYKYyD8QcvulenSj/iUb8/otoByfmtSBNc8E="; + + # Inject the git version if you want + #ldflags = '' + # -X main.version=${if self ? rev then self.rev else "dirty"} + #''; + }; + + apps.default = utils.lib.mkApp {drv = packages.default;}; + + devShells.default = + pkgs.devshell.mkShell {packages = with pkgs; [go gopls];}; + formatter = pkgs.alejandra; + }); +}