49 lines
1.2 KiB
Nix
Raw Normal View History

{
# Exposes an overlay that adds one package, then imports nixpkgs with that
# overlay so the package is available through normal flake outputs.
description = "A minimal overlay example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
overlay = _: prev: {
hello-overlay = prev.writeShellScriptBin "hello-overlay" ''
echo "hello from an overlay"
'';
};
pkgs = import nixpkgs {
inherit system;
overlays = [ overlay ];
};
in
{
overlays.default = overlay;
packages.${system}.default = pkgs.hello-overlay;
apps.${system}.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/hello-overlay";
meta.description = "Run the package added by the overlay.";
};
checks.${system}.runs = pkgs.runCommand "hello-overlay-runs" { } ''
output="$(${self.packages.${system}.default}/bin/hello-overlay)"
if [ "$output" = "hello from an overlay" ]; then
echo ok > "$out"
else
echo "unexpected output: $output" >&2
exit 1
fi
'';
};
}