From 452e4d695fd857a578f7e045335347121586a5fd Mon Sep 17 00:00:00 2001 From: Anantha Kumaran Date: Thu, 15 Sep 2022 22:54:42 +0530 Subject: [PATCH] nix flake based shell --- .github/workflows/release.yml | 6 ++--- .github/workflows/test.yml | 4 ++-- Makefile | 2 +- flake.lock | 41 +++++++++++++++++++++++++++++++++++ flake.nix | 8 +++++++ shell.nix | 18 +++++---------- 6 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f918a66..c273b25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,9 @@ jobs: with: nix_path: nixpkgs=channel:nixos-unstable - run: | - nix-shell --run 'npm install' - nix-shell --run './node_modules/.bin/esbuild web/src/index.ts --bundle --outfile=web/static/dist.js' - nix-shell --run 'go build' + nix develop --command npm install + nix develop --command ./node_modules/.bin/esbuild web/src/index.ts --bundle --outfile=web/static/dist.js + nix develop --command go build cp paisa paisa-linux-amd64 - name: Release uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74dcdb5..cea5167 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,5 +13,5 @@ jobs: with: nix_path: nixpkgs=channel:nixos-unstable - run: | - nix-shell --run 'npm install' - nix-shell --run 'make lint' + nix develop --command npm install + nix develop --command make lint diff --git a/Makefile b/Makefile index 3354045..296d92a 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ sample: go build && ./paisa init && ./paisa update && ./paisa serve publish: - nix-shell --run 'cd docs && mdbook build' + nix develop --command bash -c 'cd docs && mdbook build' lint: ./node_modules/.bin/prettier --check web/src diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6066b3b --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1663235518, + "narHash": "sha256-q8zLK6rK/CLXEguaPgm9yQJcY0VQtOBhAT9EV2UFK/A=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2277e4c9010b0f27585eb0bed0a86d7cbc079354", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f26019d --- /dev/null +++ b/flake.nix @@ -0,0 +1,8 @@ +{ + description = "paisa"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { devShells.default = import ./shell.nix { inherit pkgs; }; }); +} diff --git a/shell.nix b/shell.nix index 46afca4..e4d0bb8 100644 --- a/shell.nix +++ b/shell.nix @@ -1,20 +1,14 @@ { pkgs ? import { } }: -let - pinned = import (builtins.fetchTarball { - url = - "https://github.com/NixOS/nixpkgs/archive/1ffba9f2f683063c2b14c9f4d12c55ad5f4ed887.tar.gz"; - }) { }; - -in pkgs.mkShell { +pkgs.mkShell { nativeBuildInputs = [ - pinned.go_1_18 - pinned.gotools - pinned.gopls + pkgs.go_1_19 + pkgs.gotools + pkgs.gopls pkgs.sqlite - pinned.nodejs-17_x + pkgs.nodejs-18_x pkgs.mdbook - pkgs.pkgsCross.mingwW64.buildPackages.gcc + # pkgs.pkgsCross.mingwW64.buildPackages.gcc ]; shellHook = ''