Manage system config using nix on any distro (numtide/system-manager fork)
Find a file
github-actions[bot] 0ac4966d54 flake.lock: Update
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/5b03654ce046b5167e7b0bccbd8244cb56c16f0e?narHash=sha256-/mumx8AQ5xFuCJqxCIOFCHTVlxHkMT21idpbgbm/TIE%3D' (2024-09-26)
  → 'github:ipetkov/crane/37e4f9f0976cb9281cd3f0c70081e5e0ecaee93f?narHash=sha256-WD0//20h%2B2/yPGkO88d2nYbb23WMWYvnRyDQ9Dx4UHg%3D' (2024-10-03)
• Updated input 'nix-vm-test':
    'github:numtide/nix-vm-test/7901cec00670681b3e405565cb7bffe6a9368240?narHash=sha256-vSA04DQX59TtJ8p8qu7msyWkmhmwGj%2BujfjIkQFRAlU%3D' (2024-09-23)
  → 'github:numtide/nix-vm-test/72f9228db6582a59976e70e61b8257185434a8cf?narHash=sha256-V418lqfB49qSD9X5deClNNTkVoB0WDVaaYHI%2BcLAIi8%3D' (2024-09-30)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/1925c603f17fc89f4c8f6bf6f631a802ad85d784?narHash=sha256-J%2BPeFKSDV%2BpHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI%3D' (2024-09-26)
  → 'github:NixOS/nixpkgs/bc947f541ae55e999ffdb4013441347d83b00feb?narHash=sha256-NOiTvBbRLIOe5F6RbHaAh6%2B%2BBNjsb149fGZd1T4%2BKBg%3D' (2024-10-04)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/85f7a7177c678de68224af3402ab8ee1bcee25c8?narHash=sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL%2BcSh9nk%3D' (2024-09-28)
  → 'github:cachix/pre-commit-hooks.nix/1211305a5b237771e13fcca0c51e60ad47326a9a?narHash=sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM%3D' (2024-10-05)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/c2099c6c7599ea1980151b8b6247a8f93e1806ee?narHash=sha256-83j/GrHsx8GFUcQofKh%2BPRPz6pz8sxAsZyT/HCNdey8%3D' (2024-09-30)
  → 'github:oxalica/rust-overlay/25685cc2c7054efc31351c172ae77b21814f2d42?narHash=sha256-lJMFnMO4maJuNO6PQ5fZesrTmglze3UFTTBuKGwR1Nw%3D' (2024-10-07)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/879b29ae9a0378904fbbefe0dadaed43c8905754?narHash=sha256-uGRlRT47ecicF9iLD1G3g43jn2e%2Bb5KaMptb59LHnvM%3D' (2024-09-27)
  → 'github:numtide/treefmt-nix/4446c7a6fc0775df028c5a3f6727945ba8400e64?narHash=sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc%3D' (2024-10-03)
2024-10-07 03:49:29 +00:00
.github Update peter-evans/create-pull-request action to v7 2024-09-30 10:03:56 +00:00
examples Reformat with nixfmt 2024-09-30 11:59:31 +02:00
nix Reformat with nixfmt 2024-09-30 11:59:31 +02:00
src Fix pre-popopulate script name (#99) 2024-06-30 16:22:59 +02:00
test/nix/modules Reformat with nixfmt 2024-09-30 11:59:31 +02:00
.envrc Add nix shell and some checks 2023-02-02 00:55:37 +01:00
.gitignore Use nix-vm-test for our tests 2024-04-29 14:28:49 +02:00
Cargo.lock Update Rust crate clap to v4.5.19 2024-10-01 22:03:13 +00:00
Cargo.toml Merge branch 'main' into renovate/nix-0.x 2024-09-30 11:55:10 +02:00
default.nix Reformat with nixfmt 2024-09-30 11:59:31 +02:00
flake.lock flake.lock: Update 2024-10-07 03:49:29 +00:00
flake.nix Remove inputs that were removed upstream 2024-09-30 12:02:48 +02: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 Fix indentation 2024-04-22 21:32:27 -07:00
renovate.json Add renovate.json 2024-07-26 09:34:06 +00:00
shell.nix Reformat with nixfmt 2024-09-30 11:59:31 +02: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 = {
    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