From afa811c9304b3059ffa4f149314c0254e590cda3 Mon Sep 17 00:00:00 2001 From: "Vlad P. Luchian" Date: Thu, 9 Mar 2023 10:00:27 +0000 Subject: [PATCH] new: add nix flake + instructions on how to use --- .gitignore | 6 +++++- README.md | 22 +++++++++++++++++++--- flake.nix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 7e3e74b..9447bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -203,4 +203,8 @@ sftp-config.json # Vagrant .vagrant/ -ubuntu-xenial-16.04-cloudimg-console.log \ No newline at end of file +ubuntu-xenial-16.04-cloudimg-console.log + + +# Direnv +.direnv diff --git a/README.md b/README.md index da88f1c..8707d7e 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,10 @@ completed. You have a few options for installation: -- Install the dependencies for the koans (such as Clojure) on your machine -- Use Vagrant and the configuration in this repository -- Use Docker +- Install the dependencies for the koans (such as Clojure) on your machine. +- Use Vagrant and the configuration in this repository. +- Use Docker. +- Use Nix Develop environment. Instructions for each option are below! @@ -69,6 +70,21 @@ To start up a REPL: docker run --rm -it -v $(pwd):/app -w /app clojure lein repl ``` +### Installation with Nix Develop Environment + +Make sure you have [nix](https://nixos.wiki/wiki/Nix_Installation_Guide) setup, +then run: + +``` +nix --experimental-features 'nix-command flakes' develop +``` + +This will drop you into a shell with all the required dependencies installed. +To run koans, in the root of the repository run: + +``` +lein koan run +``` ## Running the Koans diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dcbc936 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Clojure Koans"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = inputs@{ self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ ]; + + pkgs = import nixpkgs {inherit system overlays;}; + + additionalPkgs = with pkgs; [ ]; + + buildPkgs = with pkgs; [ clojure leiningen ]; + + project = pkgs.stdenv.mkDerivation { + name = "koans-env"; + root = self; + buildInputs = buildPkgs; + shellInputs = additionalPkgs; + }; + + in { + defaultPackage = project; + devShell = project; + }); +}