From 4379396e1d28bc2fb68261b7d5b7d2593d2d146a Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Sun, 11 Dec 2022 23:02:15 +0100 Subject: [PATCH] Add flake --- .envrc | 8 +++++ default.nix | 13 ++++++++ devshell.toml | 57 ++++++++++++++++++++++++++++++++++ flake.lock | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 42 ++++++++++++++++++++++++++ shell.nix | 13 ++++++++ 6 files changed, 217 insertions(+) create mode 100644 .envrc create mode 100644 default.nix create mode 100644 devshell.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4e9b89c --- /dev/null +++ b/.envrc @@ -0,0 +1,8 @@ +use flake + +HEX_HOME="${PWD}/.nix/hex" +MIX_HOME="${PWD}/.nix/mix" + +export HEX_HOME MIX_HOME + +PATH_add "${MIX_HOME}/escripts" diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..873ece4 --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +(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 = ./.; + }).defaultNix diff --git a/devshell.toml b/devshell.toml new file mode 100644 index 0000000..73d6c22 --- /dev/null +++ b/devshell.toml @@ -0,0 +1,57 @@ +[devshell] +packages = [ + "erlang", + "libnotify", + "inotify-tools", + "gnumake", + "taplo", +] + +[[env]] +name = "HEX_HOME" +eval = "${PWD}/.nix/hex" + +[[env]] +name = "MIX_HOME" +eval = "${PWD}/.nix/mix" + +[[env]] +name = "PATH" +prefix = "${MIX_HOME}/escripts" + +[[env]] +name = "ERL_AFLAGS" +value = "-kernel shell_history enabled" + +[[env]] +name = "XLA_TARGET" +value = "cpu" + +# [[env]] +# name = "XLA_BUILD" +# value = "true" + +[[env]] +name = "LIVEBOOK_HOME" +eval = "${PWD}" + +[[env]] +name = "LIVEBOOK_TOKEN_ENABLED" +value = "false" + +[[env]] +name = "LIVEBOOK_SHUTDOWN_ENABLED" +value = "true" + +[[env]] +name = "LIVEBOOK_PORT" +value = "9090" + +[[env]] +name = "LIVEBOOK_IFRAME_PORT" +value = "9091" + +[[commands]] +name = "mix" +package = "elixir_1_14" +help = "mix" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1ae3442 --- /dev/null +++ b/flake.lock @@ -0,0 +1,84 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667210711, + "narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=", + "owner": "numtide", + "repo": "devshell", + "rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1670597555, + "narHash": "sha256-/k939P2S2246G6K5fyvC0U2IWvULhb4ZJg9K7ZxsX+k=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2dea0f4c2d6e4603f54b2c56c22367e77869490c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "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 0000000..9e15eef --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + description = "A basic flake for elixir development"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, flake-utils, devshell, ... }@inputs: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ devshell.overlay ]; + }; + in + { + formatter = pkgs.nixpkgs-fmt; + + packages = { }; + + devShells.default = + let + elixir_ls = pkgs.elixir_ls.override { elixir = pkgs.elixir_1_14; }; + in pkgs.devshell.mkShell { + imports = [ + (pkgs.devshell.importTOML ./devshell.toml) + ]; + + devshell.packages = [ elixir_ls ]; + }; + }); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..9eb132a --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +(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