Manage system config using nix on any distro (numtide/system-manager fork)
Find a file
2024-04-21 22:05:47 -07:00
.github Fix error in workflow. 2023-05-29 11:43:31 +02:00
examples Provide an implementation for systemd-tmpfiles. 2023-10-12 11:16:37 +02:00
nix Add void option for compatibility with NixOS modules 2024-01-08 12:10:50 +01:00
src Add debug output showing the nix commands being run. 2023-10-12 12:20:51 +02:00
test/nix Drop support for old test-driver 2024-01-08 12:10:30 +01:00
.envrc Add nix shell and some checks 2023-02-02 00:55:37 +01:00
.gitignore Continue implementing basic features. 2023-02-02 17:31:10 +00:00
Cargo.lock cargo update 2024-04-08 03:48:41 +00:00
Cargo.toml Rework error handling and merge the two state files. 2023-04-11 21:55:26 +02:00
default.nix Add nix shell and some checks 2023-02-02 00:55:37 +01:00
flake.lock flake.lock: Update 2024-04-08 03:48:41 +00:00
flake.nix Crane removed flake inputs. 2023-12-11 12:31:57 +01:00
garnix.yaml Rename garnix.io config file. (#7) 2023-04-27 14:03:13 +02:00
LICENSE Initial commit 2023-02-01 18:21:52 +02:00
README.md Include section in readme about unsupported distros 2024-04-21 22:05:47 -07:00
shell.nix Add nix shell and some checks 2023-02-02 00:55:37 +01:00

System Manager using Nix

This project provides a basic method to manage system configuration using Nix on any Linux distribution. It builds on the many modules that already exist in NixOS.

Warning: System Manager is a work in progress, you can expect things not to work or to break.

Usage

Getting Nix

In order to use System Manager, you will first need to install Nix. You can either use your distro's package manager, or use one of the different options to install Nix, like the official installer or this new installer.

Usage with flakes

Defining the configuration

A basic Nix flake using System Manager would look something like this:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    system-manager = {
      url = "github:numtide/system-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, flake-utils, nixpkgs, system-manager }: {
    systemConfigs.default = system-manager.lib.makeSystemConfig {
      modules = [
        ./modules
      ];
    };
  };
}

And you would then put your System Manager modules in the modules directory, which should contain a default.nix file which functions as the entrance point.

A simple System Manager module could look something like this:

{ config, lib, pkgs, ... }:

{
  config = {
    nixpkgs.hostPlatform = "x86_64-linux";

    environment = {
      etc = {
        "foo.conf".text = ''
          launch_the_rockets = true
        '';
      };
      systemPackages = [
        pkgs.ripgrep
        pkgs.fd
        pkgs.hello
      ];
    };

    systemd.services = {
      foo = {
        enable = true;
        serviceConfig = {
          Type = "oneshot";
          RemainAfterExit = true;
        };
        wantedBy = [ "system-manager.target" ];
        script = ''
          ${lib.getBin pkgs.hello}/bin/hello
          echo "We launched the rockets!"
        '';
      };
    };
  };
}

Activating the configuration

Once the configuration is defined, you can activate it using the system-manager CLI:

nix run 'github:numtide/system-manager' -- switch --flake '.'

Currently supported features

Currently it is possible to configure files under /etc/ and systemd services. More features may follow later.

Supported Systems

System Manger is currently only supported on NixOS and Ubuntu. However, it can be used on other distributions by enabling the following:

{ config, lib, pkgs, ... }:

{
  config = {
          system-manager.allowAnyDistro = true;
  }
}

Warning

This is unsupported and untested. Use at your own risk.

Commercial support

Looking for help or customization?

Get in touch with Numtide to get a quote. We make it easy for companies to work with Open Source projects: https://numtide.com/contact