From 006ce4d197f5abefa498b2848a87d7cf0ba6e380 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Wed, 30 Mar 2022 12:29:14 +0300 Subject: [PATCH] build(nix): Add Nix-based dev environment configuration --- .direnv/.gitkeep | 0 .envrc | 9 +++++++++ .gitignore | 7 +++++++ flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 15 +++++++++++++++ shell.nix | 17 +++++++++++++++++ 6 files changed, 91 insertions(+) create mode 100644 .direnv/.gitkeep create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/.direnv/.gitkeep b/.direnv/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..8e43c2ca --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +# shellcheck shell=bash + +if ! has nix_direnv_version || ! nix_direnv_version 1.6.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/1.6.1/direnvrc" "sha256-aFwy76WtzXD7SVXWetpg+welXMZI/VcEUPQ2WUMXYSY=" +fi + +dotenv_if_exists +nix_direnv_watch_file shell.nix +use flake diff --git a/.gitignore b/.gitignore index 503790a9..fedf9bde 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,10 @@ __test__library__ *.swp dlang-tour-test-library + +# Nix build artifact: +result + +# Direnv: +.direnv/* +!.direnv/.gitkeep diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..d76dc6b2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1648297722, + "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1648390671, + "narHash": "sha256-u69opCeHUx3CsdIerD0wVSR+DjfDQjnztObqfk9Trqc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce8cbe3c01fd8ee2de526ccd84bbf9b82397a510", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "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 00000000..8dd9795a --- /dev/null +++ b/flake.nix @@ -0,0 +1,15 @@ +{ + description = "Dlang Tour"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; + flake-utils.url = github:numtide/flake-utils; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.simpleFlake { + inherit self nixpkgs; + name = "dlang-tour"; + shell = ./shell.nix; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..fb980b73 --- /dev/null +++ b/shell.nix @@ -0,0 +1,17 @@ +{ pkgs ? import { } }: with pkgs; +mkShell { + buildInputs = [ + figlet + glibc.static + zlib.static + (openssl.override { static = true; }).dev + dmd + dtools + dub + ldc + ]; + + shellHook = '' + figlet "Welcome to Dlang Tour" + ''; +}