From 689414d1697e5787d643738c7aaeb540bb80579e Mon Sep 17 00:00:00 2001 From: Cormac Cannon Date: Thu, 19 Sep 2024 13:17:35 +0100 Subject: [PATCH 1/2] new(nix): Added flake-based devshell setup Just clone the repo and then 'direnv allow' --- .envrc | 1 + .gitignore | 1 + flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 27 ++++++++++++++++++++++++ 4 files changed, 90 insertions(+) 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 ee83431..830ec3c 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ /classes /target .garden/ +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4dcf979 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "garden": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1726732424, + "narHash": "sha256-QX8bPuBvhmBLOiR0QYantHewSKH9n6L9QrCOzfLgV5Y=", + "owner": "nextjournal", + "repo": "garden-cli", + "rev": "72c00aee7b8e17c36c42e1f9f0db46b5e944b692", + "type": "github" + }, + "original": { + "owner": "nextjournal", + "repo": "garden-cli", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711532879, + "narHash": "sha256-VUvOxVoxBokiZETZdZU97MnJpeKa19KqSOPlC84QB9Y=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2230a20f2b5a14f2db3d7f13a2dc3c22517e790b", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1726583932, + "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "658e7223191d2598641d50ee4e898126768fe847", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "garden": "garden", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..34ff355 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "A Nix-flake-based development environment for application.garden"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + garden.url = "github:nextjournal/garden-cli"; + }; + + outputs = { self, nixpkgs, garden }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { + inherit system; + overlays = [ + garden.overlays.default + ]; + }; + }); + in { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + buildInputs = [ pkgs.garden ]; + }; + }); + }; +} From fa447a99f64c5af1f0cb22efb3c0097044357bfa Mon Sep 17 00:00:00 2001 From: Cormac Cannon Date: Thu, 19 Sep 2024 13:37:31 +0100 Subject: [PATCH 2/2] fix(nix): Added clojure as explicit dependency Had assumed it was implicit in garden, but got an error without a globally installed clojure. --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 34ff355..667d35c 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,8 @@ outputs = { self, nixpkgs, garden }: let + # Latest LTS releases as of Nov 2023 + javaVersion = 21; supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { @@ -20,7 +22,7 @@ in { devShells = forEachSupportedSystem ({ pkgs }: { default = pkgs.mkShell { - buildInputs = [ pkgs.garden ]; + buildInputs = [ pkgs.clojure pkgs.garden ]; }; }); };