From c4729affcc57f61bfb775bb6696efbbd7c7917c6 Mon Sep 17 00:00:00 2001 From: Patrick McLaughlin Date: Wed, 11 May 2022 14:05:40 -0400 Subject: [PATCH] feat(nix): use flake --- flake.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 ++++++++++++++++++++++++++++++ shell.nix | 24 +++++++++------------- 3 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..96a20eb7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1652290453, + "narHash": "sha256-0iXRvx7DP/HIKd5h7b7Y1+JffoDDRCwz4WTVYfsltrs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e680b5cf74e550508f1e2be2fcfdee688bbd3b74", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..05007cad --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "api-ts"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, flake-utils, flake-compat }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in { + devShell = pkgs.mkShell { + name = "api-ts-shell"; + + packages = with pkgs; [ + nodejs-16_x + go + ]; + + shellHook = '' + export PATH="$(pwd)/node_modules/.bin:$PATH" + ''; + }; + } + ); +} diff --git a/shell.nix b/shell.nix index 3c0a9cab..6234bb4d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,14 +1,10 @@ -{ pkgs ? import {} }: - -let - PROJECT_ROOT=builtins.toString ./.; - -in pkgs.mkShell { - packages = with pkgs; [ - nodejs-16_x - ]; - - shellHook = with pkgs; '' - export PATH="${PROJECT_ROOT}/node_modules/.bin:$PATH" - ''; -} +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + 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 = ./.; } +).shellNix