• Stars
    star
    239
  • Rank 168,763 (Top 4 %)
  • Language
    Nix
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 6 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
535
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

raspberrypi-nixos-example

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

visionfive-nix

Nix
44
star
5

nixkvm

A Flake for distributing PiKVM running on Embedded NixOS
Nix
35
star
6

hamnix

A collection of Amateur Radio software packaged for Nix
Nix
25
star
7

filestash-nix

A flake for testing, building and using Filestash by Mickael Kerjean
Nix
23
star
8

nix-dropper-bundle

Bundlers to drop software onto systems, for good or bad intent
Nix
12
star
9

mobile-nixos-oneplus-enchilada-template

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

nrf-nix

A Nix flake for developing and working with Nordic Semiconductor hardware
Nix
8
star
11

disko-utils

Fun with https://github.com/nix-community/disko
Nix
7
star
12

nixblitz

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

h96-max-v58-nixos

Nix
4
star
14

dolphin-emu-nix

A flake for testing, building and packaging the Dolphin Gamecube emulator
Nix
4
star
15

static-nix-in-repo

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

esp-r-nix

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

talks

A repository of my talks
Nix
1
star
18

codedisaster

A Nix flake to build and run code-aster.org
Nix
1
star
19

painter

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

haskell.fix

Nix
1
star
21

userland-mqtt-stack

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

nix-pi3-pi4-systemimage-example

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

mobile-nixos-templates

Templates for Mobile NixOS devices
Nix
1
star
24

bioflake

A Nix flake for Outbreak Server Resurrection, a Resident Evil Outbreak File 1 and File 2 Server restoration project.
Nix
1
star
25

OpenFlam

1
star
26

clan-mobile

A template for using mobile-nixos to create a mobile clan.lol device
Nix
1
star
27

pi-intercom

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

xmimsim-nix

Nix
1
star