2023-09-12 14:09:05 +00:00
|
|
|
{
|
2023-09-13 18:24:26 +00:00
|
|
|
description = "A Nix Flake example for ANSI C using GNU Autoconf";
|
|
|
|
|
|
|
|
nixConfig = {
|
|
|
|
bash-prompt = "\\[\\e[34;1m\\]flake.nix ~ \\[\\e[0m\\]";
|
|
|
|
};
|
2023-09-12 14:09:05 +00:00
|
|
|
|
2023-09-12 15:31:06 +00:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2023-09-13 17:54:05 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
2023-09-12 14:09:05 +00:00
|
|
|
let
|
2023-09-13 18:57:49 +00:00
|
|
|
inherit (nixpkgs) lib;
|
|
|
|
officialRelease = false;
|
|
|
|
|
|
|
|
version = lib.fileContents ./.version + versionSuffix;
|
|
|
|
versionSuffix =
|
|
|
|
if officialRelease
|
|
|
|
then ""
|
|
|
|
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
|
2023-09-12 14:09:05 +00:00
|
|
|
|
|
|
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
|
|
|
|
2023-09-13 18:57:49 +00:00
|
|
|
# Generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
2023-09-12 14:09:05 +00:00
|
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
|
|
|
|
|
|
# Nixpkgs instantiated for supported system types.
|
|
|
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
|
|
|
|
|
|
|
|
in
|
2023-09-13 17:54:05 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
hello = with final; stdenv.mkDerivation rec {
|
|
|
|
pname = "hello";
|
|
|
|
inherit version;
|
2023-09-13 19:19:18 +00:00
|
|
|
src = self;
|
2023-09-13 17:54:05 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
2023-09-13 19:19:18 +00:00
|
|
|
};
|
2023-09-13 17:54:05 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-09-13 18:24:26 +00:00
|
|
|
in rec {
|
2023-09-13 17:54:05 +00:00
|
|
|
packages = { inherit (pkgs) hello; };
|
|
|
|
packages.default = self.packages.${system}.hello;
|
2023-09-13 18:24:26 +00:00
|
|
|
packages.container = pkgs.callPackage ./container.nix { package = packages.default; };
|
2023-09-13 18:42:19 +00:00
|
|
|
|
2023-09-13 18:24:26 +00:00
|
|
|
apps.hello = flake-utils.lib.mkApp { drv = packages.default; };
|
2023-09-13 19:19:18 +00:00
|
|
|
apps.${system}.default = apps.hello;
|
2023-09-13 18:42:19 +00:00
|
|
|
|
2023-09-13 18:36:27 +00:00
|
|
|
devShells.default = import ./shell.nix { inherit pkgs; };
|
2023-09-13 17:54:05 +00:00
|
|
|
}
|
|
|
|
);
|
2023-09-12 14:09:05 +00:00
|
|
|
}
|