mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Clean up packaging a bit
- Multiple choices of stdenv are handled more consistently, especially for the dev shells which were previously not done correctly. - Some stray nix code was moving into the `packaging` directory
This commit is contained in:
parent
43a170a554
commit
69fde530a6
6 changed files with 48 additions and 57 deletions
72
flake.nix
72
flake.nix
|
@ -66,14 +66,7 @@
|
||||||
|
|
||||||
forAllCrossSystems = lib.genAttrs crossSystems;
|
forAllCrossSystems = lib.genAttrs crossSystems;
|
||||||
|
|
||||||
forAllStdenvs = f:
|
forAllStdenvs = lib.genAttrs stdenvs;
|
||||||
lib.listToAttrs
|
|
||||||
(map
|
|
||||||
(stdenvName: {
|
|
||||||
name = "${stdenvName}Packages";
|
|
||||||
value = f stdenvName;
|
|
||||||
})
|
|
||||||
stdenvs);
|
|
||||||
|
|
||||||
|
|
||||||
# We don't apply flake-parts to the whole flake so that non-development attributes
|
# We don't apply flake-parts to the whole flake so that non-development attributes
|
||||||
|
@ -89,32 +82,29 @@
|
||||||
# Memoize nixpkgs for different platforms for efficiency.
|
# Memoize nixpkgs for different platforms for efficiency.
|
||||||
nixpkgsFor = forAllSystems
|
nixpkgsFor = forAllSystems
|
||||||
(system: let
|
(system: let
|
||||||
make-pkgs = crossSystem: stdenv: import nixpkgs {
|
make-pkgs = crossSystem:
|
||||||
localSystem = {
|
forAllStdenvs (stdenv: import nixpkgs {
|
||||||
inherit system;
|
localSystem = {
|
||||||
};
|
inherit system;
|
||||||
crossSystem = if crossSystem == null then null else {
|
};
|
||||||
config = crossSystem;
|
crossSystem = if crossSystem == null then null else {
|
||||||
} // lib.optionalAttrs (crossSystem == "x86_64-unknown-freebsd13") {
|
config = crossSystem;
|
||||||
useLLVM = true;
|
} // lib.optionalAttrs (crossSystem == "x86_64-unknown-freebsd13") {
|
||||||
};
|
useLLVM = true;
|
||||||
overlays = [
|
};
|
||||||
(overlayFor (p: p.${stdenv}))
|
overlays = [
|
||||||
];
|
(overlayFor (pkgs: pkgs.${stdenv}))
|
||||||
};
|
];
|
||||||
stdenvs = forAllStdenvs (make-pkgs null);
|
});
|
||||||
native = stdenvs.stdenvPackages;
|
in rec {
|
||||||
in {
|
nativeForStdenv = make-pkgs null;
|
||||||
inherit stdenvs native;
|
crossForStdenv = forAllCrossSystems make-pkgs;
|
||||||
static = native.pkgsStatic;
|
# Alias for convenience
|
||||||
llvm = native.pkgsLLVM;
|
native = nativeForStdenv.stdenv;
|
||||||
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
|
cross = forAllCrossSystems (crossSystem:
|
||||||
|
crossForStdenv.${crossSystem}.stdenv);
|
||||||
});
|
});
|
||||||
|
|
||||||
binaryTarball = nix: pkgs: pkgs.callPackage ./scripts/binary-tarball.nix {
|
|
||||||
inherit nix;
|
|
||||||
};
|
|
||||||
|
|
||||||
overlayFor = getStdenv: final: prev:
|
overlayFor = getStdenv: final: prev:
|
||||||
let
|
let
|
||||||
stdenv = getStdenv final;
|
stdenv = getStdenv final;
|
||||||
|
@ -175,7 +165,6 @@
|
||||||
hydraJobs = import ./packaging/hydra.nix {
|
hydraJobs = import ./packaging/hydra.nix {
|
||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
binaryTarball
|
|
||||||
forAllCrossSystems
|
forAllCrossSystems
|
||||||
forAllSystems
|
forAllSystems
|
||||||
lib
|
lib
|
||||||
|
@ -211,7 +200,7 @@
|
||||||
# TODO: enable static builds for darwin, blocked on:
|
# TODO: enable static builds for darwin, blocked on:
|
||||||
# https://github.com/NixOS/nixpkgs/issues/320448
|
# https://github.com/NixOS/nixpkgs/issues/320448
|
||||||
# TODO: disabled to speed up GHA CI.
|
# TODO: disabled to speed up GHA CI.
|
||||||
#"static-" = nixpkgsFor.${system}.static;
|
#"static-" = nixpkgsFor.${system}.native.pkgsStatic;
|
||||||
})
|
})
|
||||||
(nixpkgsPrefix: nixpkgs:
|
(nixpkgsPrefix: nixpkgs:
|
||||||
flatMapAttrs nixpkgs.nixComponents
|
flatMapAttrs nixpkgs.nixComponents
|
||||||
|
@ -282,8 +271,8 @@
|
||||||
(pkgName: { supportsCross ? true }: {
|
(pkgName: { supportsCross ? true }: {
|
||||||
# These attributes go right into `packages.<system>`.
|
# These attributes go right into `packages.<system>`.
|
||||||
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
|
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
|
||||||
"${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName};
|
"${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents.${pkgName};
|
||||||
"${pkgName}-llvm" = nixpkgsFor.${system}.llvm.nixComponents.${pkgName};
|
"${pkgName}-llvm" = nixpkgsFor.${system}.native.pkgsLLVM.nixComponents.${pkgName};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs supportsCross (flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: {
|
// lib.optionalAttrs supportsCross (flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: {
|
||||||
# These attributes go right into `packages.<system>`.
|
# These attributes go right into `packages.<system>`.
|
||||||
|
@ -291,7 +280,7 @@
|
||||||
}))
|
}))
|
||||||
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: {
|
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: {
|
||||||
# These attributes go right into `packages.<system>`.
|
# These attributes go right into `packages.<system>`.
|
||||||
"${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName};
|
"${pkgName}-${stdenvName}" = nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents.${pkgName};
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||||
|
@ -317,21 +306,22 @@
|
||||||
in
|
in
|
||||||
forAllSystems (system:
|
forAllSystems (system:
|
||||||
prefixAttrs "native" (forAllStdenvs (stdenvName: makeShell {
|
prefixAttrs "native" (forAllStdenvs (stdenvName: makeShell {
|
||||||
pkgs = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages";
|
pkgs = nixpkgsFor.${system}.nativeForStdenv.${stdenvName};
|
||||||
})) //
|
})) //
|
||||||
lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.isDarwin) (
|
lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.isDarwin) (
|
||||||
prefixAttrs "static" (forAllStdenvs (stdenvName: makeShell {
|
prefixAttrs "static" (forAllStdenvs (stdenvName: makeShell {
|
||||||
pkgs = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".pkgsStatic;
|
pkgs = nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.pkgsStatic;
|
||||||
})) //
|
})) //
|
||||||
prefixAttrs "llvm" (forAllStdenvs (stdenvName: makeShell {
|
prefixAttrs "llvm" (forAllStdenvs (stdenvName: makeShell {
|
||||||
pkgs = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".pkgsLLVM;
|
pkgs = nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.pkgsLLVM;
|
||||||
})) //
|
})) //
|
||||||
prefixAttrs "cross" (forAllCrossSystems (crossSystem: makeShell {
|
prefixAttrs "cross" (forAllCrossSystems (crossSystem: makeShell {
|
||||||
pkgs = nixpkgsFor.${system}.cross.${crossSystem};
|
pkgs = nixpkgsFor.${system}.cross.${crossSystem};
|
||||||
}))
|
}))
|
||||||
) //
|
) //
|
||||||
{
|
{
|
||||||
default = self.devShells.${system}.native-stdenvPackages;
|
native = self.devShells.${system}.native-stdenv;
|
||||||
|
default = self.devShells.${system}.native;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,18 +22,18 @@ in
|
||||||
|
|
||||||
runCommand "nix-binary-tarball-${version}" env ''
|
runCommand "nix-binary-tarball-${version}" env ''
|
||||||
cp ${installerClosureInfo}/registration $TMPDIR/reginfo
|
cp ${installerClosureInfo}/registration $TMPDIR/reginfo
|
||||||
cp ${./create-darwin-volume.sh} $TMPDIR/create-darwin-volume.sh
|
cp ${../scripts/create-darwin-volume.sh} $TMPDIR/create-darwin-volume.sh
|
||||||
substitute ${./install-nix-from-tarball.sh} $TMPDIR/install \
|
substitute ${../scripts/install-nix-from-tarball.sh} $TMPDIR/install \
|
||||||
--subst-var-by nix ${nix} \
|
--subst-var-by nix ${nix} \
|
||||||
--subst-var-by cacert ${cacert}
|
--subst-var-by cacert ${cacert}
|
||||||
|
|
||||||
substitute ${./install-darwin-multi-user.sh} $TMPDIR/install-darwin-multi-user.sh \
|
substitute ${../scripts/install-darwin-multi-user.sh} $TMPDIR/install-darwin-multi-user.sh \
|
||||||
--subst-var-by nix ${nix} \
|
--subst-var-by nix ${nix} \
|
||||||
--subst-var-by cacert ${cacert}
|
--subst-var-by cacert ${cacert}
|
||||||
substitute ${./install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
|
substitute ${../scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
|
||||||
--subst-var-by nix ${nix} \
|
--subst-var-by nix ${nix} \
|
||||||
--subst-var-by cacert ${cacert}
|
--subst-var-by cacert ${cacert}
|
||||||
substitute ${./install-multi-user.sh} $TMPDIR/install-multi-user \
|
substitute ${../scripts/install-multi-user.sh} $TMPDIR/install-multi-user \
|
||||||
--subst-var-by nix ${nix} \
|
--subst-var-by nix ${nix} \
|
||||||
--subst-var-by cacert ${cacert}
|
--subst-var-by cacert ${cacert}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{ inputs
|
{ inputs
|
||||||
, binaryTarball
|
|
||||||
, forAllCrossSystems
|
, forAllCrossSystems
|
||||||
, forAllSystems
|
, forAllSystems
|
||||||
, lib
|
, lib
|
||||||
|
@ -12,7 +11,7 @@ let
|
||||||
inherit (inputs) nixpkgs nixpkgs-regression;
|
inherit (inputs) nixpkgs nixpkgs-regression;
|
||||||
|
|
||||||
installScriptFor = tarballs:
|
installScriptFor = tarballs:
|
||||||
nixpkgsFor.x86_64-linux.native.callPackage ../scripts/installer.nix {
|
nixpkgsFor.x86_64-linux.native.callPackage ./installer {
|
||||||
inherit tarballs;
|
inherit tarballs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ in
|
||||||
[ "i686-linux" ];
|
[ "i686-linux" ];
|
||||||
|
|
||||||
buildStatic = forAllPackages (pkgName:
|
buildStatic = forAllPackages (pkgName:
|
||||||
lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.static.nixComponents.${pkgName}));
|
lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.native.pkgsStatic.nixComponents.${pkgName}));
|
||||||
|
|
||||||
buildCross = forAllPackages (pkgName:
|
buildCross = forAllPackages (pkgName:
|
||||||
# Hack to avoid non-evaling package
|
# Hack to avoid non-evaling package
|
||||||
|
@ -99,13 +98,12 @@ in
|
||||||
# Binary tarball for various platforms, containing a Nix store
|
# Binary tarball for various platforms, containing a Nix store
|
||||||
# with the closure of 'nix' package, and the second half of
|
# with the closure of 'nix' package, and the second half of
|
||||||
# the installation script.
|
# the installation script.
|
||||||
binaryTarball = forAllSystems (system: binaryTarball nixpkgsFor.${system}.native.nix nixpkgsFor.${system}.native);
|
binaryTarball = forAllSystems (system:
|
||||||
|
nixpkgsFor.${system}.native.callPackage ./binary-tarball.nix {});
|
||||||
|
|
||||||
binaryTarballCross = lib.genAttrs [ "x86_64-linux" ] (system:
|
binaryTarballCross = lib.genAttrs [ "x86_64-linux" ] (system:
|
||||||
forAllCrossSystems (crossSystem:
|
forAllCrossSystems (crossSystem:
|
||||||
binaryTarball
|
nixpkgsFor.${system}.cross.${crossSystem}.callPackage ./binary-tarball.nix {}));
|
||||||
nixpkgsFor.${system}.cross.${crossSystem}.nix
|
|
||||||
nixpkgsFor.${system}.cross.${crossSystem}));
|
|
||||||
|
|
||||||
# The first half of the installation script. This is uploaded
|
# The first half of the installation script. This is uploaded
|
||||||
# to https://nixos.org/nix/install. It downloads the binary
|
# to https://nixos.org/nix/install. It downloads the binary
|
||||||
|
@ -124,7 +122,7 @@ in
|
||||||
self.hydraJobs.binaryTarballCross."x86_64-linux"."riscv64-unknown-linux-gnu"
|
self.hydraJobs.binaryTarballCross."x86_64-linux"."riscv64-unknown-linux-gnu"
|
||||||
];
|
];
|
||||||
|
|
||||||
installerScriptForGHA = forAllSystems (system: nixpkgsFor.${system}.native.callPackage ../scripts/installer.nix {
|
installerScriptForGHA = forAllSystems (system: nixpkgsFor.${system}.native.callPackage ./installer {
|
||||||
tarballs = [ self.hydraJobs.binaryTarball.${system} ];
|
tarballs = [ self.hydraJobs.binaryTarball.${system} ];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -147,7 +145,10 @@ in
|
||||||
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-external-api-docs;
|
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-external-api-docs;
|
||||||
|
|
||||||
# System tests.
|
# System tests.
|
||||||
tests = import ../tests/nixos { inherit lib nixpkgs nixpkgsFor self; } // {
|
tests = import ../tests/nixos {
|
||||||
|
inherit lib nixpkgs nixpkgsFor;
|
||||||
|
inherit (self.inputs) nixpkgs-23-11;
|
||||||
|
} // {
|
||||||
|
|
||||||
# Make sure that nix-env still produces the exact same result
|
# Make sure that nix-env still produces the exact same result
|
||||||
# on a particular version of Nixpkgs.
|
# on a particular version of Nixpkgs.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, nixpkgs, nixpkgsFor, self }:
|
{ lib, nixpkgs, nixpkgsFor, nixpkgs-23-11 }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ let
|
||||||
otherNixes.nix_2_13.setNixPackage = { lib, pkgs, ... }: {
|
otherNixes.nix_2_13.setNixPackage = { lib, pkgs, ... }: {
|
||||||
imports = [ checkOverrideNixVersion ];
|
imports = [ checkOverrideNixVersion ];
|
||||||
nix.package = lib.mkForce (
|
nix.package = lib.mkForce (
|
||||||
self.inputs.nixpkgs-23-11.legacyPackages.${pkgs.stdenv.hostPlatform.system}.nixVersions.nix_2_13.overrideAttrs (o: {
|
nixpkgs-23-11.legacyPackages.${pkgs.stdenv.hostPlatform.system}.nixVersions.nix_2_13.overrideAttrs (o: {
|
||||||
meta = o.meta // { knownVulnerabilities = []; };
|
meta = o.meta // { knownVulnerabilities = []; };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue