iliana / wrench

🔧 nix flake for quickly defining NixOS configurations and tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🔧 wrench

wrench is a Nix flake for quickly declaring NixOS configurations with custom packages, and tests to test those configurations.

I haven't written reference documentation yet but you can refer to iliana/nixos-configs for more in-depth usage.

Example

flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
    wrench.url = "github:iliana/wrench";
    wrench.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = {wrench, ...}:
    wrench.lib.generate {
      packages = system: callPackage: {
        hello = callPackage ./hello.nix {};
      };

      nixosConfigurations.x86_64-linux.ghost = {myPkgs, ...}: {
        environment.systemPackages = [myPkgs.hello];
        system.stateVersion = "22.11";
      };

      checks.x86_64-linux.hello = {
        runTest,
        ghost,
        ...
      }:
        runTest {
          nodes = {
            inherit ghost;
          };

          testScript = ''
            stdout = ghost.succeed("hello")
            assert stdout.strip() == 'Hello, world!'
          '';
        };
    };
}
hello.nix (for completeness)
{pkgs, ...}:
pkgs.writeShellApplication {
  name = "hello";
  text = ''
    echo 'Hello, world!'
  '';
}

About

🔧 nix flake for quickly defining NixOS configurations and tests

License:Mozilla Public License 2.0


Languages

Language:Nix 100.0%