Add daily email for 2024-11-26
The Nix language
This commit is contained in:
parent
af2cd5f1ab
commit
c4ac4a8d3f
65
source/_daily_emails/2024-11-26.md
Normal file
65
source/_daily_emails/2024-11-26.md
Normal file
|
@ -0,0 +1,65 @@
|
|||
---
|
||||
title: The Nix language
|
||||
date: 2024-11-26
|
||||
permalink: daily/2024/11/26/the-nix-language
|
||||
tags:
|
||||
- software-development
|
||||
- linux
|
||||
- nix
|
||||
cta: ~
|
||||
snippet: |
|
||||
Today, let's have a look at the Nix programming language.
|
||||
---
|
||||
|
||||
Yesterday, I wrote about [Nix the package manager][0].
|
||||
|
||||
To use it, you need to write code in the Nix language in .nix files.
|
||||
|
||||
To see an example, you can see [my dotfiles on GitHub][1] as well as lots of other people's that they've published.
|
||||
|
||||
It's a functional language so some of the concepts were new to me, but I picked it up fairly quickly and learned some of the paradigms and conventions.
|
||||
|
||||
This is the code that installs Nginx on my server:
|
||||
|
||||
```nix
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
serverNamesHashBucketSize = 256;
|
||||
};
|
||||
```
|
||||
|
||||
These are some of the packages I have installed on my laptop:
|
||||
|
||||
```nix
|
||||
environment.systemPackages = with pkgs: {
|
||||
devenv
|
||||
dog
|
||||
git
|
||||
go
|
||||
jq
|
||||
php
|
||||
phpPackages.composer
|
||||
pv
|
||||
tldr
|
||||
}
|
||||
```
|
||||
|
||||
And this is how to configure processes [in a devenv configuration][2], which is built with Nix:
|
||||
|
||||
```nix
|
||||
processes = {
|
||||
tailwind.exec = ''
|
||||
cd ${drupal.theme.path}
|
||||
watchexec --exts css,twig tailwindcss --config assets/tailwind.config.ts \
|
||||
--output dist/tailwind.css
|
||||
'';
|
||||
};
|
||||
```
|
||||
|
||||
Once you have written the configuration, you can run it and install what you've specified, and it will do it the same way every time.
|
||||
|
||||
For a crash course in the Nix language, take a look at <https://zero-to-nix.com/concepts/nix-language> or one of the many open-sourced configurations on GitHub.
|
||||
|
||||
[0]: {{site.url}}/daily/2024/11/25/nix-the-package-manager
|
||||
[1]: https://github.com/opdavies/dotfiles/tree/main/nix
|
||||
[2]: {{site.url}}/daily/2024/11/11/could-nix-and-devenv-replace-docker-compose
|
Loading…
Reference in a new issue