2019-04-08 18:28:05 +03:00
|
|
|
{
|
|
|
|
description = "The purely functional package manager";
|
|
|
|
|
2024-07-24 16:30:56 +03:00
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
2022-05-16 21:46:44 +03:00
|
|
|
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
|
2024-06-03 18:00:48 +03:00
|
|
|
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
|
2023-03-06 21:51:58 +02:00
|
|
|
inputs.flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
2024-07-24 16:24:10 +03:00
|
|
|
inputs.libgit2 = { url = "github:libgit2/libgit2/v1.8.1"; flake = false; };
|
2019-04-08 18:28:05 +03:00
|
|
|
|
2024-04-18 22:59:39 +03:00
|
|
|
# dev tooling
|
|
|
|
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
|
2024-07-24 16:55:57 +03:00
|
|
|
inputs.git-hooks-nix.url = "github:cachix/git-hooks.nix";
|
2024-04-18 22:59:39 +03:00
|
|
|
# work around https://github.com/NixOS/nix/issues/7730
|
|
|
|
inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
2024-07-24 16:55:57 +03:00
|
|
|
inputs.git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.git-hooks-nix.inputs.nixpkgs-stable.follows = "nixpkgs";
|
2024-04-18 22:59:39 +03:00
|
|
|
# work around 7730 and https://github.com/NixOS/nix/issues/7807
|
2024-07-24 16:55:57 +03:00
|
|
|
inputs.git-hooks-nix.inputs.flake-compat.follows = "";
|
|
|
|
inputs.git-hooks-nix.inputs.gitignore.follows = "";
|
2024-04-18 22:59:39 +03:00
|
|
|
|
|
|
|
outputs = inputs@{ self, nixpkgs, nixpkgs-regression, libgit2, ... }:
|
|
|
|
|
2019-04-08 18:28:05 +03:00
|
|
|
|
2019-10-04 11:45:33 +03:00
|
|
|
let
|
2022-03-02 04:40:18 +02:00
|
|
|
inherit (nixpkgs) lib;
|
2023-12-02 19:25:47 +02:00
|
|
|
|
2022-12-06 19:00:10 +02:00
|
|
|
officialRelease = false;
|
|
|
|
|
2023-08-23 21:28:24 +03:00
|
|
|
linux32BitSystems = [ "i686-linux" ];
|
2020-10-28 07:13:18 +02:00
|
|
|
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ];
|
2023-08-23 21:28:24 +03:00
|
|
|
linuxSystems = linux32BitSystems ++ linux64BitSystems;
|
|
|
|
darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
systems = linuxSystems ++ darwinSystems;
|
2023-08-31 05:57:59 +03:00
|
|
|
|
|
|
|
crossSystems = [
|
2023-09-02 21:36:25 +03:00
|
|
|
"armv6l-unknown-linux-gnueabihf"
|
|
|
|
"armv7l-unknown-linux-gnueabihf"
|
2024-04-18 14:10:52 +03:00
|
|
|
"riscv64-unknown-linux-gnu"
|
2023-09-02 21:36:25 +03:00
|
|
|
"x86_64-unknown-netbsd"
|
2024-06-04 11:17:58 +03:00
|
|
|
"x86_64-unknown-freebsd"
|
2023-12-11 19:26:42 +02:00
|
|
|
"x86_64-w64-mingw32"
|
2023-08-31 05:57:59 +03:00
|
|
|
];
|
2021-02-06 02:07:48 +02:00
|
|
|
|
2023-12-01 00:48:44 +02:00
|
|
|
stdenvs = [
|
|
|
|
"ccacheStdenv"
|
|
|
|
"clangStdenv"
|
|
|
|
"gccStdenv"
|
|
|
|
"libcxxStdenv"
|
|
|
|
"stdenv"
|
|
|
|
];
|
2021-07-08 18:01:51 +03:00
|
|
|
|
2024-06-25 16:49:39 +03:00
|
|
|
/**
|
|
|
|
`flatMapAttrs attrs f` applies `f` to each attribute in `attrs` and
|
|
|
|
merges the results into a single attribute set.
|
|
|
|
|
|
|
|
This can be nested to form a build matrix where all the attributes
|
|
|
|
generated by the innermost `f` are returned as is.
|
|
|
|
(Provided that the names are unique.)
|
|
|
|
|
|
|
|
See https://nixos.org/manual/nixpkgs/stable/index.html#function-library-lib.attrsets.concatMapAttrs
|
|
|
|
*/
|
|
|
|
flatMapAttrs = attrs: f: lib.concatMapAttrs f attrs;
|
|
|
|
|
2022-03-02 04:40:18 +02:00
|
|
|
forAllSystems = lib.genAttrs systems;
|
|
|
|
|
|
|
|
forAllCrossSystems = lib.genAttrs crossSystems;
|
|
|
|
|
|
|
|
forAllStdenvs = f:
|
|
|
|
lib.listToAttrs
|
2021-07-08 18:01:51 +03:00
|
|
|
(map
|
2022-03-02 04:40:18 +02:00
|
|
|
(stdenvName: {
|
|
|
|
name = "${stdenvName}Packages";
|
|
|
|
value = f stdenvName;
|
|
|
|
})
|
|
|
|
stdenvs);
|
2021-07-08 18:01:51 +03:00
|
|
|
|
2024-04-18 22:59:39 +03:00
|
|
|
|
|
|
|
# We don't apply flake-parts to the whole flake so that non-development attributes
|
|
|
|
# load without fetching any development inputs.
|
|
|
|
devFlake = inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
|
|
|
imports = [ ./maintainers/flake-module.nix ];
|
|
|
|
systems = lib.subtractLists crossSystems systems;
|
|
|
|
perSystem = { system, ... }: {
|
|
|
|
_module.args.pkgs = nixpkgsFor.${system}.native;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-04 11:45:33 +03:00
|
|
|
# Memoize nixpkgs for different platforms for efficiency.
|
2022-03-02 04:40:18 +02:00
|
|
|
nixpkgsFor = forAllSystems
|
|
|
|
(system: let
|
|
|
|
make-pkgs = crossSystem: stdenv: import nixpkgs {
|
2023-08-31 05:57:59 +03:00
|
|
|
localSystem = {
|
|
|
|
inherit system;
|
|
|
|
};
|
|
|
|
crossSystem = if crossSystem == null then null else {
|
2023-09-02 21:36:25 +03:00
|
|
|
config = crossSystem;
|
|
|
|
} // lib.optionalAttrs (crossSystem == "x86_64-unknown-freebsd13") {
|
2023-08-31 05:57:59 +03:00
|
|
|
useLLVM = true;
|
|
|
|
};
|
2022-03-02 04:40:18 +02:00
|
|
|
overlays = [
|
|
|
|
(overlayFor (p: p.${stdenv}))
|
|
|
|
];
|
|
|
|
};
|
|
|
|
stdenvs = forAllStdenvs (make-pkgs null);
|
|
|
|
native = stdenvs.stdenvPackages;
|
|
|
|
in {
|
|
|
|
inherit stdenvs native;
|
|
|
|
static = native.pkgsStatic;
|
2024-01-13 03:39:46 +02:00
|
|
|
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
|
2022-03-02 04:40:18 +02:00
|
|
|
});
|
2019-10-04 11:45:33 +03:00
|
|
|
|
2023-12-04 01:16:07 +02:00
|
|
|
binaryTarball = nix: pkgs: pkgs.callPackage ./scripts/binary-tarball.nix {
|
2023-12-01 00:48:44 +02:00
|
|
|
inherit nix;
|
|
|
|
};
|
2021-06-26 08:12:03 +03:00
|
|
|
|
2021-07-08 18:01:51 +03:00
|
|
|
overlayFor = getStdenv: final: prev:
|
2023-12-01 00:48:44 +02:00
|
|
|
let
|
|
|
|
stdenv = getStdenv final;
|
|
|
|
in
|
2022-01-25 02:28:44 +02:00
|
|
|
{
|
|
|
|
nixStable = prev.nix;
|
2020-11-10 11:43:33 +02:00
|
|
|
|
2024-06-26 03:38:07 +03:00
|
|
|
# A new scope, so that we can use `callPackage` to inject our own interdependencies
|
|
|
|
# without "polluting" the top level "`pkgs`" attrset.
|
|
|
|
# This also has the benefit of providing us with a distinct set of packages
|
|
|
|
# we can iterate over.
|
2024-08-13 23:15:56 +03:00
|
|
|
nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix {
|
|
|
|
inherit (final) lib;
|
|
|
|
inherit officialRelease;
|
|
|
|
src = self;
|
|
|
|
});
|
2023-12-04 01:47:54 +02:00
|
|
|
|
2024-06-26 04:58:47 +03:00
|
|
|
# The dependencies are in their own scope, so that they don't have to be
|
|
|
|
# in Nixpkgs top level `pkgs` or `nixComponents`.
|
2024-06-26 11:41:56 +03:00
|
|
|
nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix {
|
2024-08-13 23:15:56 +03:00
|
|
|
inherit inputs stdenv;
|
2024-06-26 11:41:56 +03:00
|
|
|
pkgs = final;
|
2024-06-26 04:58:47 +03:00
|
|
|
});
|
|
|
|
|
2024-11-07 14:46:37 +02:00
|
|
|
nix = final.nixComponents.nix;
|
2023-02-06 17:36:57 +02:00
|
|
|
|
2024-04-21 14:52:56 +03:00
|
|
|
# See https://github.com/NixOS/nixpkgs/pull/214409
|
|
|
|
# Remove when fixed in this flake's nixpkgs
|
2024-04-18 22:59:39 +03:00
|
|
|
pre-commit =
|
|
|
|
if prev.stdenv.hostPlatform.system == "i686-linux"
|
|
|
|
then (prev.pre-commit.override (o: { dotnet-sdk = ""; })).overridePythonAttrs (o: { doCheck = false; })
|
|
|
|
else prev.pre-commit;
|
|
|
|
|
2024-01-17 20:08:03 +02:00
|
|
|
};
|
|
|
|
|
2021-07-08 18:01:51 +03:00
|
|
|
in {
|
|
|
|
# A Nixpkgs overlay that overrides the 'nix' and
|
2024-06-05 01:10:25 +03:00
|
|
|
# 'nix-perl-bindings' packages.
|
2022-02-11 16:05:07 +02:00
|
|
|
overlays.default = overlayFor (p: p.stdenv);
|
2021-07-08 18:01:51 +03:00
|
|
|
|
2024-06-26 05:24:50 +03:00
|
|
|
hydraJobs = import ./packaging/hydra.nix {
|
2024-05-31 20:12:35 +03:00
|
|
|
inherit
|
|
|
|
inputs
|
|
|
|
binaryTarball
|
|
|
|
forAllCrossSystems
|
|
|
|
forAllSystems
|
|
|
|
lib
|
|
|
|
linux64BitSystems
|
|
|
|
nixpkgsFor
|
|
|
|
self
|
2024-08-13 23:15:56 +03:00
|
|
|
officialRelease
|
2024-05-31 20:12:35 +03:00
|
|
|
;
|
2024-06-01 01:27:20 +03:00
|
|
|
};
|
2021-10-15 13:36:29 +03:00
|
|
|
|
|
|
|
checks = forAllSystems (system: {
|
|
|
|
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
|
|
|
installTests = self.hydraJobs.installTests.${system};
|
2023-01-18 01:17:59 +02:00
|
|
|
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
|
2023-12-09 20:55:47 +02:00
|
|
|
rl-next =
|
|
|
|
let pkgs = nixpkgsFor.${system}.native;
|
|
|
|
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
|
2024-06-03 19:38:38 +03:00
|
|
|
LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out
|
2023-12-09 20:55:47 +02:00
|
|
|
'';
|
2024-05-27 10:58:49 +03:00
|
|
|
repl-completion = nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.nix { };
|
2022-03-02 04:40:18 +02:00
|
|
|
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
2021-11-24 10:19:29 +02:00
|
|
|
dockerImage = self.hydraJobs.dockerImage.${system};
|
2024-03-07 11:40:53 +02:00
|
|
|
} // (lib.optionalAttrs (!(builtins.elem system linux32BitSystems))) {
|
|
|
|
# Some perl dependencies are broken on i686-linux.
|
|
|
|
# Since the support is only best-effort there, disable the perl
|
|
|
|
# bindings
|
2024-06-05 01:10:25 +03:00
|
|
|
|
|
|
|
# Temporarily disabled because GitHub Actions OOM issues. Once
|
|
|
|
# the old build system is gone and we are back to one build
|
|
|
|
# system, we should reenable this.
|
|
|
|
#perlBindings = self.hydraJobs.perlBindings.${system};
|
2024-06-25 16:35:47 +03:00
|
|
|
}
|
2024-11-07 14:46:37 +02:00
|
|
|
/*
|
2024-06-25 16:49:39 +03:00
|
|
|
# Add "passthru" tests
|
2024-06-25 17:56:45 +03:00
|
|
|
// flatMapAttrs ({
|
2024-06-25 16:35:47 +03:00
|
|
|
"" = nixpkgsFor.${system}.native;
|
2024-06-25 17:56:45 +03:00
|
|
|
} // lib.optionalAttrs (! nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) {
|
|
|
|
# TODO: enable static builds for darwin, blocked on:
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/320448
|
2024-08-22 14:47:33 +03:00
|
|
|
# TODO: disabled to speed up GHA CI.
|
|
|
|
#"static-" = nixpkgsFor.${system}.static;
|
2024-06-25 17:56:45 +03:00
|
|
|
})
|
2024-06-28 00:28:31 +03:00
|
|
|
(nixpkgsPrefix: nixpkgs:
|
2024-06-26 03:38:07 +03:00
|
|
|
flatMapAttrs nixpkgs.nixComponents
|
2024-06-25 16:49:39 +03:00
|
|
|
(pkgName: pkg:
|
|
|
|
flatMapAttrs pkg.tests or {}
|
|
|
|
(testName: test: {
|
|
|
|
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
|
|
|
|
})
|
|
|
|
)
|
2024-07-08 23:07:06 +03:00
|
|
|
// lib.optionalAttrs (nixpkgs.stdenv.hostPlatform == nixpkgs.stdenv.buildPlatform) {
|
|
|
|
"${nixpkgsPrefix}nix-functional-tests" = nixpkgs.nixComponents.nix-functional-tests;
|
|
|
|
}
|
2024-06-25 16:49:39 +03:00
|
|
|
)
|
2024-11-07 14:46:37 +02:00
|
|
|
*/
|
2024-06-25 16:35:47 +03:00
|
|
|
// devFlake.checks.${system} or {}
|
2024-04-18 22:59:39 +03:00
|
|
|
);
|
2019-10-04 11:45:33 +03:00
|
|
|
|
2024-06-26 03:03:21 +03:00
|
|
|
packages = forAllSystems (system:
|
|
|
|
{ # Here we put attributes that map 1:1 into packages.<system>, ie
|
|
|
|
# for which we don't apply the full build matrix such as cross or static.
|
|
|
|
inherit (nixpkgsFor.${system}.native)
|
|
|
|
changelog-d;
|
2024-11-07 14:46:37 +02:00
|
|
|
default = self.packages.${system}.nix-ng;
|
2024-07-30 22:05:22 +03:00
|
|
|
nix-manual = nixpkgsFor.${system}.native.nixComponents.nix-manual;
|
2024-06-26 11:47:13 +03:00
|
|
|
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
|
|
|
|
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
|
2024-06-04 16:28:27 +03:00
|
|
|
}
|
2024-06-26 03:03:21 +03:00
|
|
|
# We need to flatten recursive attribute sets of derivations to pass `flake check`.
|
|
|
|
// flatMapAttrs
|
|
|
|
{ # Components we'll iterate over in the upcoming lambda
|
2024-11-07 14:46:37 +02:00
|
|
|
"nix" = { };
|
2024-08-14 23:04:35 +03:00
|
|
|
"nix-util" = { };
|
|
|
|
"nix-util-c" = { };
|
|
|
|
"nix-util-test-support" = { };
|
|
|
|
"nix-util-tests" = { };
|
|
|
|
|
|
|
|
"nix-store" = { };
|
|
|
|
"nix-store-c" = { };
|
|
|
|
"nix-store-test-support" = { };
|
|
|
|
"nix-store-tests" = { };
|
|
|
|
|
|
|
|
"nix-fetchers" = { };
|
|
|
|
"nix-fetchers-tests" = { };
|
|
|
|
|
|
|
|
"nix-expr" = { };
|
|
|
|
"nix-expr-c" = { };
|
|
|
|
"nix-expr-test-support" = { };
|
|
|
|
"nix-expr-tests" = { };
|
|
|
|
|
|
|
|
"nix-flake" = { };
|
|
|
|
"nix-flake-tests" = { };
|
|
|
|
|
|
|
|
"nix-main" = { };
|
|
|
|
"nix-main-c" = { };
|
|
|
|
|
|
|
|
"nix-cmd" = { };
|
|
|
|
|
|
|
|
"nix-cli" = { };
|
|
|
|
|
|
|
|
"nix-functional-tests" = { supportsCross = false; };
|
|
|
|
|
|
|
|
"nix-perl-bindings" = { supportsCross = false; };
|
2024-11-07 14:46:37 +02:00
|
|
|
"nix-ng" = { };
|
2024-06-26 03:03:21 +03:00
|
|
|
}
|
2024-08-14 23:04:35 +03:00
|
|
|
(pkgName: { supportsCross ? true }: {
|
2024-06-26 03:03:21 +03:00
|
|
|
# These attributes go right into `packages.<system>`.
|
2024-06-26 03:44:21 +03:00
|
|
|
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
|
|
|
|
"${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName};
|
2024-06-26 03:03:21 +03:00
|
|
|
}
|
2024-08-14 23:04:35 +03:00
|
|
|
// lib.optionalAttrs supportsCross (flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: {
|
2024-06-26 03:03:21 +03:00
|
|
|
# These attributes go right into `packages.<system>`.
|
2024-06-26 03:44:21 +03:00
|
|
|
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
|
2024-08-14 23:04:35 +03:00
|
|
|
}))
|
2024-06-26 03:03:21 +03:00
|
|
|
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: {
|
|
|
|
# These attributes go right into `packages.<system>`.
|
2024-06-26 03:44:21 +03:00
|
|
|
"${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName};
|
2024-06-26 03:03:21 +03:00
|
|
|
})
|
|
|
|
)
|
2024-06-04 16:28:27 +03:00
|
|
|
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
2022-01-26 15:31:23 +02:00
|
|
|
dockerImage =
|
|
|
|
let
|
2022-03-02 04:40:18 +02:00
|
|
|
pkgs = nixpkgsFor.${system}.native;
|
2024-08-13 23:15:56 +03:00
|
|
|
image = import ./docker.nix { inherit pkgs; tag = pkgs.nix.version; };
|
2022-01-26 15:31:23 +02:00
|
|
|
in
|
|
|
|
pkgs.runCommand
|
2024-08-13 23:15:56 +03:00
|
|
|
"docker-image-tarball-${pkgs.nix.version}"
|
2022-01-26 15:31:23 +02:00
|
|
|
{ meta.description = "Docker image with Nix for ${system}"; }
|
|
|
|
''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
image=$out/image.tar.gz
|
|
|
|
ln -s ${image} $image
|
|
|
|
echo "file binary-dist $image" >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
2024-06-04 16:28:27 +03:00
|
|
|
});
|
2022-03-02 04:40:18 +02:00
|
|
|
|
|
|
|
devShells = let
|
2024-11-04 21:04:21 +02:00
|
|
|
makeShell = import ./packaging/dev-shell.nix { inherit lib devFlake; };
|
2024-11-06 06:22:43 +02:00
|
|
|
prefixAttrs = prefix: lib.concatMapAttrs (k: v: { "${prefix}-${k}" = v; });
|
2024-11-04 21:04:21 +02:00
|
|
|
in
|
2022-03-02 04:40:18 +02:00
|
|
|
forAllSystems (system:
|
2024-11-04 22:13:10 +02:00
|
|
|
prefixAttrs "native" (forAllStdenvs (stdenvName: makeShell {
|
|
|
|
pkgs = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages";
|
|
|
|
})) //
|
|
|
|
lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.isDarwin) (
|
|
|
|
prefixAttrs "static" (forAllStdenvs (stdenvName: makeShell {
|
|
|
|
pkgs = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".pkgsStatic;
|
|
|
|
})) //
|
|
|
|
prefixAttrs "cross" (forAllCrossSystems (crossSystem: makeShell {
|
|
|
|
pkgs = nixpkgsFor.${system}.cross.${crossSystem};
|
|
|
|
}))
|
|
|
|
) //
|
|
|
|
{
|
|
|
|
default = self.devShells.${system}.native-stdenvPackages;
|
|
|
|
}
|
2022-03-02 04:40:18 +02:00
|
|
|
);
|
2019-04-08 18:28:05 +03:00
|
|
|
};
|
|
|
|
}
|