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

• Updated input 'crane':
    'github:ipetkov/crane/35110cccf28823320f4fd697fcafcb5038683982' (2023-05-25)
  → 'github:ipetkov/crane/4bdf5595ae15481b4021358dc17d6c0df8eecd7f' (2023-06-04)
• Updated input 'flake-utils':
    'github:numtide/flake-utils/cfacdce06f30d2b68473a46042957675eebb3401' (2023-04-11)
  → 'github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef' (2023-05-31)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/4e37b4e55b60fb7d43d2b62deb51032a489bcbe8' (2023-05-28)
  → 'github:NixOS/nixpkgs/dd4982554e18b936790da07c4ea2db7c7600f283' (2023-06-03)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/61e567d6497bc9556f391faebe5e410e6623217f' (2023-05-23)
  → 'github:cachix/pre-commit-hooks.nix/ca2fdbf3edda2a38140184da6381d49f8206eaf4' (2023-05-29)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/d6ac24aa7ff658552ce57913df4b0cb823cf15ab' (2023-05-29)
  → 'github:oxalica/rust-overlay/08b06ab2046bce2c3b5f53ec599a6550ab9a9485' (2023-06-05)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/4e92552731aca44ece86731ec4c7848a2c46aa67' (2023-05-22)
  → 'github:numtide/treefmt-nix/6521a278bcba66b440554cc1350403594367b4ac' (2023-05-31)
2023-06-05 03:48:41 +00:00
.github Fix error in workflow. 2023-05-29 11:43:31 +02:00
examples Add Aarch64 tests and include multiple test images. (#9) 2023-04-27 14:57:00 +02:00
nix Fix the logic to apply the test-driver patch only when needed. 2023-05-25 18:37:50 +02:00
src Remove unneeded turbofish. 2023-05-29 01:24:12 +02:00
test Don't create an nginx service by default. 2023-05-16 17:27:55 +02: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 2023-05-29 11:27:15 +02: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 2023-06-05 03:48:41 +00:00
flake.nix Revert "Specify the systems through a flake input." 2023-05-31 13:38:04 +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 missing function parameter in README. 2023-05-24 22:38:39 +08: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";
    flake-utils.url = "github:numtide/flake-utils";

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

  outputs = { self, flake-utils, nixpkgs, system-manager }: {
    systemConfigs.default = self.lib.makeSystemConfig {
      system = flake-utils.lib.system.x86_64-linux;
      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 = {
    environment.etc = {
      "foo.conf".text = ''
        launch_the_rockets = true
      '';
    };
    systemd.services = {
      foo = {
        enable = true;
        serviceConfig = {
          Type = "oneshot";
          RemainAfterExit = true;
        };
        wantedBy = [ "multi-user.target" ];
        script = ''
          ${lib.getBin pkgs.foo}/bin/foo
          echo "We launched the rockets!"
        '';
      };
    };
  };
}

Activating the configuration

Once the configuration 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.