switch to hugo
This commit is contained in:
parent
123615ff9a
commit
e581629364
14 changed files with 59 additions and 322 deletions
60
content/posts/2022-06-09-nix-registry.md
Normal file
60
content/posts/2022-06-09-nix-registry.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: Nix registry
|
||||
date: 2022-06-09
|
||||
summary: A quick note about a small trick I implemented in my NixOS configurations.
|
||||
---
|
||||
|
||||
*A quick note about a small trick I implemented in my NixOS configurations.*
|
||||
|
||||
I started using [flakes](https://nixos.wiki/wiki/Flakes) a few months ago, and
|
||||
quickly began using them daily. Notably, I moved the NixOS configurations for
|
||||
all my machines in a single flake. But there has been a caveat in my workflow:
|
||||
using flakes for almost every project I compile made me end up with lots of
|
||||
different versions of Nixpkgs lying around. It became very annoying when
|
||||
compiling LaTeX documents: two LaTeX projects created a few hours apart could be
|
||||
using different versions of Nixpkgs, and thus different versions of TexLive.
|
||||
Downloading a few gigabytes every time I set up a LaTeX project was not very
|
||||
optimal. I began copying lock files between projects, but it only made me more
|
||||
frustrated.
|
||||
|
||||
Nix uses a
|
||||
[registry](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-registry.html)
|
||||
to resolve flake URIs. For instance, it resolves the special flake URI "nixpkgs"
|
||||
to "github:nixpkgs/nixos-unstable". We can configure the registry system-wide to
|
||||
map "nixpkgs" to a specific revision of the repository. Using the "rev"
|
||||
attribute of a flake input, we can even point it to the same revision as the one
|
||||
used by our flake-defined configuration.
|
||||
|
||||
The module to configure the Nix registry looks like this:
|
||||
|
||||
```Nix
|
||||
{
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, }: {
|
||||
|
||||
nixosModule = {
|
||||
nix.registry.nixpkgs = {
|
||||
from = {
|
||||
type = "indirect";
|
||||
id = "nixpkgs";
|
||||
};
|
||||
to = {
|
||||
type = "github";
|
||||
owner = "nixos";
|
||||
repo = "nixpkgs";
|
||||
inherit (nixpkgs) rev;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The Nix registry can also be configured at the user level, and this module can
|
||||
be used as a home-manager module.
|
26
content/posts/2023-11-07-flake-template.md
Normal file
26
content/posts/2023-11-07-flake-template.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
title: A Nix Flake Template
|
||||
date: 2023-11-07
|
||||
summary: I wrote a Nix ❄ Template
|
||||
---
|
||||
|
||||
I learned to use Nix when flakes were already ubiquitous, and I realized
|
||||
recently that by learning Nix through flakes I adopted some bad coding habits. I
|
||||
don't think I am the only one that tends to overload their `flake.nix` (the
|
||||
flake of [Nix](http://github.com/nixos/nix/blob/master/flake.nix) is over 700
|
||||
lines long at the time of writing). Paradoxically, this makes flake expressions
|
||||
less discoverable, or at least less flexible. For instance, how do you override
|
||||
the package expression defined in a `flake.nix` to try and build it for a system
|
||||
that is not explicitly exposed by this flake? In many cases, you can't! Just
|
||||
fork the repository and patch the Nix code!
|
||||
|
||||
A friend recently told me about [Niv](https://github.com/nmattia/niv), and I
|
||||
really liked the way I naturally set up my projects when trying it out, namely
|
||||
in a more modular fashion than before. Even if I decided to stick with flakes, I will
|
||||
be trying to write them in a more modular way going forward.
|
||||
|
||||
If you are interested, I wrote a
|
||||
[template](https://github.com/pnmadelaine/flake) that I will be using for medium
|
||||
to large projects in the future (it may be a bit ridiculous for smaller flakes).
|
||||
For a non-trivial example, you can take a look at
|
||||
[Typhon](https://github.com/typhon-ci/typhon) (more on that soon, hopefully!).
|
Loading…
Add table
Add a link
Reference in a new issue