Skip to content

Commit

Permalink
Add shell.nix for Nix(OS) users (#18)
Browse files Browse the repository at this point in the history
This adds a shell.nix file for Nix(OS) users. In Nix, a shell.nix file is used to create a development environment with certain packages installed, in this case just Go.
  • Loading branch information
enderger authored Apr 13, 2021
1 parent 16ce9a6 commit ad92ea3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/tangle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
- push
- pull_request


env:
FILES: 'Implementation.md WhitespacePreservation.md SubdirectoryFiles.md LineNumbers.md IndentedBlocks.md'
GOVER: '^1.16'
Expand Down
2 changes: 1 addition & 1 deletion Implementation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# lmt - literate markdown tangle

This file implements a tangle program for a literate programming style
where the code is weaved into markdown code blocks. There is no corresponding
where the code is tangled from markdown code blocks. There is no corresponding
weave, because the markdown itself can already be read as the documentation,
either through a text editor or through an online system that already renders
markdown such as GitHub.
Expand Down
18 changes: 18 additions & 0 deletions Nix-Shell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# About Nix
Nix is a package manager designed to allow for completely reproducible builds. It allows for developers to have reproducible build environments in order to ensure consistency. For more information, see <https://nixos.org/>.

# Nix Shell
Nix development shells can be used to get development environments which can be accessed using the `nix-shell` command.

Firstly, we must define a function. Nix expressions are written in a functional language (also called Nix) and use the function as their basic unit. This one takes a parameter called `pkgs` with a default value of the primary Nix package collection.
```nix shell.nix+=
{ pkgs ? import <nixpkgs> {} }:
```

Now, we can create a shell using the `pkgs.mkShell` function. This function creates the shell that will be accessed and defines properties of it. In our case, we use the `buildInputs` parameter to include our build dependencies (ie. Golang) in this shell.
```nix shell.nix+=
pkgs.mkShell {
buildInputs = with pkgs; [ go ];
}
```

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ directory. You can use the `-o $path` argument to `go build` to build
the binary in a different location. (i.e. `go build -o ~/bin/` to put the
binary in `~/bin/`.)

#### A note for Nix(OS) users
This repo also comes with a `shell.nix` file. While an existing version is included, like lmt itself, this is mainly for bootstrapping purposes. To compile it, use `lmt Nix-Shell.md`

## Demo

To observe `lmt` at work, put this file in an empty directory, cd to that
Expand Down
4 changes: 4 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [ go ];
}

0 comments on commit ad92ea3

Please sign in to comment.