• Stars
    star
    215
  • Rank 177,611 (Top 4 %)
  • Language
    Nix
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Another NixOS Deployment Tool - Nixinate your systems 🕶️

Nixinate 🕶️

Nixinate is a proof of concept that generates a deployment script for each nixosConfiguration you already have in your flake, which can be ran via nix run, thanks to the apps attribute of the flake schema.

Usage

To add and configure nixinate in your own flake, you need to:

  1. Add the result of nixinate self to the apps attribute of your flake.
  2. Add and configure _module.args.nixinate to the nixosConfigurations you want to deploy

Below is a minimal example:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
    nixinate.url = "github:matthewcroughan/nixinate";
  };

  outputs = { self, nixpkgs, nixinate }: {
    apps = nixinate.nixinate.x86_64-linux self;
    nixosConfigurations = {
      myMachine = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          (import ./my-configuration.nix)
          {
            _module.args.nixinate = {
              host = "itchy.scratchy.com";
              sshUser = "matthew";
              buildOn = "remote"; # valid args are "local" or "remote"
              substituteOnTarget = true; # if buildOn is "local" then it will substitute on the target, "-s"
              hermetic = false;
            };
          }
          # ... other configuration ...
        ];
      };
    };
  };
}

Each nixosConfiguration you have configured should have a deployment script in apps.nixinate, visible in nix flake show like this:

$ nix flake show
git+file:///etc/nixos
├───apps
│   └───nixinate
│       └───myMachine: app
└───nixosConfigurations
    └───myMachine: NixOS configuration

To finally execute the deployment script, use nix run .#apps.nixinate.myMachine

Example Run

[root@myMachine:/etc/nixos]# nix run .#apps.nixinate.myMachine
🚀 Deploying nixosConfigurations.myMachine from /nix/store/279p8aaclmng8kc3mdmrmi6q3n76r1i7-source
👤 SSH User: matthew
🌐 SSH Host: itchy.scratchy.com
🚀 Sending flake to myMachine via nix copy:
([email protected]) Password:
🤞 Activating configuration on myMachine via ssh:
([email protected]) Password:
[sudo] password for matthew:
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for matthew...
setting up tmpfiles
Connection to itchy.scratchy.com closed.

Available arguments via _module.args.nixinate

  • host string

    A string representing the hostname or IP address of a machine to connect to via ssh.

  • sshUser string

    A string representing the username a machine to connect to via ssh.

  • buildOn "remote" or "local"

    • "remote"

      Push the flake to the remote, build and activate entirely remotely, returning logs via SSH.

    • "local"

      Build the system closure locally, copy to the remote and activate.

  • hermetic bool

    Whether to copy Nix to the remote for usage when building and activating, instead of using the Nix which is already installed on the remote.

  • substituteOnTarget bool

    Whether to fetch closures and paths from the remote, even when building locally. This makes sense in most cases, because the remote will have already built a lot of the paths from the previous deployment. However, if the remote has a slow upload bandwidth, this would not be a good idea to enable.

Project Principles

  • No Premature Optimization: Make it work, then optimize it later if the optimization is taking a lot of time to figure out now.
  • KISS: Keep it simple, stupid. Unnecesary complexity should be avoided.

More Repositories

1

NixThePlanet

Run macOS, Windows and more via a single Nix command, or simple nixosModules
Nix
456
star
2

nixcfg

My nix configuration(s), using flakes. It's my laptop, it's my servers, it's my everything, in code.
Nix
243
star
3

visionfive-nix

Nix
41
star
4

raspberrypi-nixos-example

The simplest possible way to begin using and extending a NixOS Configuration with a Raspberry Pi
Nix
29
star
5

hamnix

A collection of Amateur Radio software packaged for Nix
Nix
22
star
6

filestash-nix

A flake for testing, building and using Filestash by Mickael Kerjean
Nix
19
star
7

nix-dropper-bundle

Bundlers to drop software onto systems, for good or bad intent
Nix
11
star
8

nrf-nix

A Nix flake for developing and working with Nordic Semiconductor hardware
Nix
6
star
9

nixblitz

NixBlitz - Using Nix to implement RaspiBlitz with NixOS as the base
Nix
6
star
10

mobile-nixos-oneplus-enchilada-template

A template for the oneplus-enchilada (OnePlus 6) using Mobile NixOS
Nix
6
star
11

dolphin-emu-nix

A flake for testing, building and packaging the Dolphin Gamecube emulator
Nix
5
star
12

nixkvm

A Flake for distributing PiKVM running on Embedded NixOS
Nix
4
star
13

static-nix-in-repo

A ridiculous idea, to provide the Nix binary as part of the git repo
Shell
4
star
14

disko-utils

Fun with https://github.com/nix-community/disko
Nix
4
star
15

esp-r-nix

A Nix flake for building ESP-R
Nix
3
star
16

painter

Nix + Stable Diffusion + Vosk = Fun
Nix
1
star
17

haskell.fix

Nix
1
star
18

userland-mqtt-stack

Installs and provisions mqtt, grafana, jupyter-notebook, node-red and influxdb for usage inside UserLAnd on Android
Shell
1
star
19

nix-pi3-pi4-systemimage-example

Creates an arm64 image for usage with a Pi3 and or Pi4
Nix
1
star
20

talks

A repository of my talks
Nix
1
star
21

h96-max-v58-nixos

Nix
1
star
22

OpenFlam

1
star
23

mobile-nixos-templates

Templates for Mobile NixOS devices
Nix
1
star
24

pi-intercom

Personal rudimentary files to produce a two-way intercom with two raspberry pi's using Seren
Python
1
star
25

xmimsim-nix

Nix
1
star