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 = {
|
2023-09-14 16:47:45 +00:00
|
|
|
bash-prompt = "\\[\\e[34;1m\\]hello.nix ~ \\[\\e[0m\\]";
|
2023-09-13 18:24:26 +00:00
|
|
|
};
|
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-14 16:47:45 +00:00
|
|
|
zicross.url = "github:flyx/Zicross";
|
2023-09-12 15:31:06 +00:00
|
|
|
};
|
2023-09-15 17:54:20 +00:00
|
|
|
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
|
|
|
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
|
|
|
|
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
|
2023-09-12 15:31:06 +00:00
|
|
|
|
2023-09-15 17:54:20 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, nix-github-actions, zicross }:
|
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
|
|
|
|
2023-09-20 22:56:37 +00:00
|
|
|
#supportedSystems = [ "i386-linux" "x86_64-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "powerpc64le-linux" "riscv64-linux" "x86_64-darwin" "aarch64-darwin" "x86_64-windows" "x86_64-windows" ];
|
2023-09-20 23:18:43 +00:00
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2023-09-12 14:09:05 +00:00
|
|
|
|
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.
|
2023-09-14 16:47:45 +00:00
|
|
|
nixpkgsFor = forAllSystems (system: import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ self.overlay ];
|
|
|
|
});
|
2023-09-12 14:09:05 +00:00
|
|
|
|
|
|
|
in
|
2023-09-13 17:54:05 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
overlays = [
|
2023-09-20 23:18:43 +00:00
|
|
|
#zicross.overlays.zig
|
|
|
|
#zicross.overlays.debian
|
|
|
|
#zicross.overlays.windows
|
2023-09-20 22:56:37 +00:00
|
|
|
|
2023-09-13 17:54:05 +00:00
|
|
|
(final: prev: {
|
2023-09-20 23:18:43 +00:00
|
|
|
#hello = with final; (if lib.strings.hasSuffix "windows" system then zigStdenv else stdenv).mkDerivation rec {
|
|
|
|
hello = with final; stdenv.mkDerivation rec {
|
|
|
|
inherit version system;
|
2023-09-14 16:47:45 +00:00
|
|
|
pname = "hello";
|
2023-09-13 19:19:18 +00:00
|
|
|
src = self;
|
2023-09-14 16:47:45 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--host ${system}"
|
|
|
|
];
|
2023-09-13 17:54:05 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
2023-09-14 16:47:45 +00:00
|
|
|
meta = {
|
2023-09-15 17:54:20 +00:00
|
|
|
maintainers = [ "Greg Burd <greg@burd.me>" ];
|
|
|
|
downloadPage = "https://github.com/gburd/hello/releases";
|
|
|
|
changelog = "https://raw.githubusercontent.com/gburd/hello/main/ChangeLog";
|
|
|
|
platforms = supportedSystems;
|
|
|
|
homepage = "https://github.com/gburd/hello";
|
|
|
|
license = "https://github.com/gburd/hello/LICENSE";
|
2023-09-14 16:47:45 +00:00
|
|
|
mainProgram = "hello";
|
2023-09-13 19:19:18 +00:00
|
|
|
};
|
2023-09-14 16:47:45 +00:00
|
|
|
};
|
2023-09-13 17:54:05 +00:00
|
|
|
})
|
|
|
|
];
|
2023-09-15 17:54:20 +00:00
|
|
|
|
|
|
|
checks = {
|
|
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
hooks = {
|
|
|
|
nixpkgs-fmt.enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
devShell = nixpkgs.legacyPackages.${system}.mkShell {
|
|
|
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
|
|
|
};
|
|
|
|
|
2023-09-13 17:54:05 +00:00
|
|
|
};
|
|
|
|
|
2023-09-13 18:24:26 +00:00
|
|
|
in rec {
|
2023-09-15 17:54:20 +00:00
|
|
|
packages = {
|
2023-09-20 22:56:37 +00:00
|
|
|
inherit (pkgs) hello;
|
|
|
|
|
2023-09-20 18:40:29 +00:00
|
|
|
# This changes things in "packages" below of the form: "packages.x86_64-linux" into
|
2023-09-20 22:56:37 +00:00
|
|
|
# "githubActions.targets.x86_64-linux.hello" so that the GHA matrix can iterate over them.
|
2023-09-15 17:54:20 +00:00
|
|
|
githubActions = nix-github-actions.lib.mkGithubMatrix {
|
2023-09-20 18:40:29 +00:00
|
|
|
checks = nixpkgs.lib.getAttrs supportedSystems self.packages;
|
2023-09-15 17:54:20 +00:00
|
|
|
};
|
|
|
|
};
|
2023-09-13 17:54:05 +00:00
|
|
|
packages.default = self.packages.${system}.hello;
|
2023-09-20 18:40:29 +00:00
|
|
|
|
2023-09-20 23:18:43 +00:00
|
|
|
#packages.lxc = pkgs.callPackage ./nix/lxc.nix { package = packages.default; };
|
|
|
|
#packages.x86_64-windows = pkgs.callPackage ./nix/pkg-win64zip.nix { package = packages.default; };
|
2023-09-20 22:56:37 +00:00
|
|
|
#packages.x86_64-wix = pkgs.callPackage ./nix/pkg-win64-wix.nix { inherit pkgs packages; };
|
2023-09-13 18:42:19 +00:00
|
|
|
|
2023-09-20 22:56:37 +00:00
|
|
|
#apps.hello = flake-utils.lib.mkApp { drv = packages.default; };
|
|
|
|
#apps.${system}.default = apps.hello;
|
2023-09-13 18:42:19 +00:00
|
|
|
|
2023-09-20 23:18:43 +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
|
|
|
}
|