Migrate nixos deployment blog post.
This commit is contained in:
parent
863a07e10e
commit
d5e3d1ae2c
78
blog/2023-11-14-easy-nixos-remote-deployments.markdown
Normal file
78
blog/2023-11-14-easy-nixos-remote-deployments.markdown
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Easy NixOS remote deployments"
|
||||
date: 2023-11-14
|
||||
comments: true
|
||||
tags: nixos, nix, flakes
|
||||
---
|
||||
|
||||
There exists a [mutitude](https://github.com/NixOS/nixops)
|
||||
[of](https://github.com/DBCDK/morph) [tooling](https://github.com/krebs/krops)
|
||||
to remotely manage nixos machines, each with its own features and compromises.
|
||||
|
||||
In my experience, for a simple deployment of few hosts
|
||||
`nixos-rebuild --target-host` is pretty powerful.
|
||||
|
||||
This is the workflow I've been using to manage my personal systems:
|
||||
|
||||
I bootstrap the machines manually by following the [nixos install
|
||||
guide](https://nixos.org/manual/nixos/stable/#sec-installation), and copy over
|
||||
the generated configuration to `config/<hostname>/configuration.nix`.
|
||||
|
||||
On the root directory create `flake.nix`:
|
||||
|
||||
```nix
|
||||
{
|
||||
description = "systems needed";
|
||||
inputs = {
|
||||
# extra inputs go here
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }@attrs: {
|
||||
# this is where we add new machines
|
||||
nixosConfigurations = {
|
||||
# host fancyHostname
|
||||
fancyHostname = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = attrs;
|
||||
modules = [
|
||||
# This points to the actual machine configuration
|
||||
(import ./config/nixmachine/configuration.nix)
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
From there, hosts can deployed over SSH!
|
||||
|
||||
```
|
||||
nixos-rebuild switch --target-host root@fancyHostname --flake '.#fancyHostname'
|
||||
```
|
||||
|
||||
|
||||
More hosts can be added by adding them to the `nixosConfigurations` attribute set.
|
||||
|
||||
```
|
||||
nixosConfigurations = {
|
||||
fancySecondHost = { ... }
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Should I do this?
|
||||
|
||||
I think this is an easier workflow for me to manage and debug, However a lot of
|
||||
things in this space has non-linear learning curves and has sparse documentation
|
||||
at best.
|
||||
|
||||
So maybe a tool with better documentation might work well for you?
|
||||
|
||||
This also relies heavily on `flakes`, which is "experimental". In my experience,
|
||||
ground reality is everyone uses flakes, but good documentation is hard to come by
|
||||
|
||||
I've herd good things about Nix [Flakes Book](https://nixos-and-flakes.thiscute.world/), but
|
||||
haven't read it
|
||||
|
||||
*This was first published at <https://pencil.lalalala.in/dbalan/easy-nixos-remote-deployments>*
|
@ -48,6 +48,7 @@
|
||||
ghcid
|
||||
cabal-install
|
||||
nodePackages.prettier
|
||||
python3
|
||||
];
|
||||
};
|
||||
devShell = self.devShells.${system}.default;
|
||||
|
@ -21,6 +21,7 @@
|
||||
</section>
|
||||
<hr id="footerdiv">
|
||||
<footer>
|
||||
<p><a href="https://notwork.in/@notmycommit">Comments? toot me!</a></p>
|
||||
<p>
|
||||
<a href="https://git.sr.ht/~dbalan/blogng">Source Code</a> -
|
||||
<a href="https://jaspervdj.be/hakyll/"> built with hakyll</a> -
|
||||
@ -28,8 +29,9 @@
|
||||
</p>
|
||||
<a href="https://creativecommons.org/licenses/by-nc/4.0/"><img src="/images/cc-by-nc.svg"></a>
|
||||
<p>
|
||||
Want to become a better programmer? <a href="https://www.recurse.com/scout/click?t=7fa4273c56d752484c0e30d3fbb0d52a">Join the Recurse Center!</a>
|
||||
Want to become a better programmer? <a href="https://www.recurse.com/scout/click?t=7fa4273c56d752484c0e30d3fbb0d52a">Join the Recurse Center!</a>
|
||||
</p>
|
||||
|
||||
</footer>
|
||||
</body>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user