1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Merge pull request #12352 from NixOS/nixfmt-on-2.24

Apply nixfmt (backport 2.24)
This commit is contained in:
Robert Hensing 2025-01-24 22:01:53 +01:00 committed by GitHub
commit a28791a91e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
298 changed files with 8061 additions and 5605 deletions

View file

@ -1,10 +1,9 @@
(import (import (
( let
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in lock = builtins.fromJSON (builtins.readFile ./flake.lock);
fetchTarball { in
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; fetchTarball {
sha256 = lock.nodes.flake-compat.locked.narHash; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
} sha256 = lock.nodes.flake-compat.locked.narHash;
) }
{ src = ./.; } ) { src = ./.; }).defaultNix
).defaultNix

View file

@ -5,7 +5,15 @@ in
builtinsInfo: builtinsInfo:
let let
showBuiltin = name: { doc, type ? null, args ? [ ], experimental-feature ? null, impure-only ? false }: showBuiltin =
name:
{
doc,
type ? null,
args ? [ ],
experimental-feature ? null,
impure-only ? false,
}:
let let
type' = optionalString (type != null) " (${type})"; type' = optionalString (type != null) " (${type})";

View file

@ -32,7 +32,13 @@ let
commandInfo = fromJSON commandDump; commandInfo = fromJSON commandDump;
showCommand = { command, details, filename, toplevel }: showCommand =
{
command,
details,
filename,
toplevel,
}:
let let
result = '' result = ''
@ -56,26 +62,27 @@ let
${maybeOptions} ${maybeOptions}
''; '';
showSynopsis = command: args: showSynopsis =
command: args:
let let
showArgument = arg: "*${arg.label}*" + optionalString (! arg ? arity) "..."; showArgument = arg: "*${arg.label}*" + optionalString (!arg ? arity) "...";
arguments = concatStringsSep " " (map showArgument args); arguments = concatStringsSep " " (map showArgument args);
in '' in
''
`${command}` [*option*...] ${arguments} `${command}` [*option*...] ${arguments}
''; '';
maybeSubcommands = optionalString (details ? commands && details.commands != {}) maybeSubcommands = optionalString (details ? commands && details.commands != { }) ''
'' where *subcommand* is one of the following:
where *subcommand* is one of the following:
${subcommands} ${subcommands}
''; '';
subcommands = if length categories > 1 subcommands = if length categories > 1 then listCategories else listSubcommands details.commands;
then listCategories
else listSubcommands details.commands;
categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues details.commands))); categories = sort (x: y: x.id < y.id) (
unique (map (cmd: cmd.category) (attrValues details.commands))
);
listCategories = concatStrings (map showCategory categories); listCategories = concatStrings (map showCategory categories);
@ -99,38 +106,39 @@ let
${allStores} ${allStores}
''; '';
index = replaceStrings index =
[ "@store-types@" "./local-store.md" "./local-daemon-store.md" ] replaceStrings
[ storesOverview "#local-store" "#local-daemon-store" ] [ "@store-types@" "./local-store.md" "./local-daemon-store.md" ]
details.doc; [ storesOverview "#local-store" "#local-daemon-store" ]
details.doc;
storesOverview = storesOverview =
let let
showEntry = store: showEntry = store: "- [${store.name}](#${store.slug})";
"- [${store.name}](#${store.slug})";
in in
concatStringsSep "\n" (map showEntry storesList) + "\n"; concatStringsSep "\n" (map showEntry storesList) + "\n";
allStores = concatStringsSep "\n" (attrValues storePages); allStores = concatStringsSep "\n" (attrValues storePages);
storePages = listToAttrs storePages = listToAttrs (
(map (s: { name = s.filename; value = s.page; }) storesList); map (s: {
name = s.filename;
value = s.page;
}) storesList
);
storesList = showStoreDocs { storesList = showStoreDocs {
storeInfo = commandInfo.stores; storeInfo = commandInfo.stores;
inherit inlineHTML; inherit inlineHTML;
}; };
hasInfix = infix: content: hasInfix =
infix: content:
builtins.stringLength content != builtins.stringLength (replaceStrings [ infix ] [ "" ] content); builtins.stringLength content != builtins.stringLength (replaceStrings [ infix ] [ "" ] content);
in in
optionalString (details ? doc) ( optionalString (details ? doc) (
# An alternate implementation with builtins.match stack overflowed on some systems. # An alternate implementation with builtins.match stack overflowed on some systems.
if hasInfix "@store-types@" details.doc if hasInfix "@store-types@" details.doc then help-stores else details.doc
then help-stores
else details.doc
); );
maybeOptions = maybeOptions =
let let
allVisibleOptions = filterAttrs allVisibleOptions = filterAttrs (_: o: !o.hiddenCategory) (details.flags // toplevel.flags);
(_: o: ! o.hiddenCategory)
(details.flags // toplevel.flags);
in in
optionalString (allVisibleOptions != { }) '' optionalString (allVisibleOptions != { }) ''
# Options # Options
@ -142,55 +150,73 @@ let
> See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags. > See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.
''; '';
showOptions = inlineHTML: allOptions: showOptions =
inlineHTML: allOptions:
let let
showCategory = cat: opts: '' showCategory = cat: opts: ''
${optionalString (cat != "") "## ${cat}"} ${optionalString (cat != "") "## ${cat}"}
${concatStringsSep "\n" (attrValues (mapAttrs showOption opts))} ${concatStringsSep "\n" (attrValues (mapAttrs showOption opts))}
''; '';
showOption = name: option: showOption =
name: option:
let let
result = trim '' result = trim ''
- ${item} - ${item}
${option.description} ${option.description}
''; '';
item = if inlineHTML item =
then ''<span id="opt-${name}">[`--${name}`](#opt-${name})</span> ${shortName} ${labels}'' if inlineHTML then
else "`--${name}` ${shortName} ${labels}"; ''<span id="opt-${name}">[`--${name}`](#opt-${name})</span> ${shortName} ${labels}''
shortName = optionalString else
(option ? shortName) "`--${name}` ${shortName} ${labels}";
("/ `-${option.shortName}`"); shortName = optionalString (option ? shortName) ("/ `-${option.shortName}`");
labels = optionalString labels = optionalString (option ? labels) (concatStringsSep " " (map (s: "*${s}*") option.labels));
(option ? labels) in
(concatStringsSep " " (map (s: "*${s}*") option.labels)); result;
in result; categories =
categories = mapAttrs mapAttrs
# Convert each group from a list of key-value pairs back to an attrset # Convert each group from a list of key-value pairs back to an attrset
(_: listToAttrs) (_: listToAttrs)
(groupBy (groupBy (cmd: cmd.value.category) (attrsToList allOptions));
(cmd: cmd.value.category) in
(attrsToList allOptions)); concatStrings (attrValues (mapAttrs showCategory categories));
in concatStrings (attrValues (mapAttrs showCategory categories)); in
in squash result; squash result;
appendName = filename: name: (if filename == "nix" then "nix3" else filename) + "-" + name; appendName = filename: name: (if filename == "nix" then "nix3" else filename) + "-" + name;
processCommand = { command, details, filename, toplevel }: processCommand =
{
command,
details,
filename,
toplevel,
}:
let let
cmd = { cmd = {
inherit command; inherit command;
name = filename + ".md"; name = filename + ".md";
value = showCommand { inherit command details filename toplevel; }; value = showCommand {
inherit
command
details
filename
toplevel
;
};
}; };
subcommand = subCmd: processCommand { subcommand =
command = command + " " + subCmd; subCmd:
details = details.commands.${subCmd}; processCommand {
filename = appendName filename subCmd; command = command + " " + subCmd;
inherit toplevel; details = details.commands.${subCmd};
}; filename = appendName filename subCmd;
in [ cmd ] ++ concatMap subcommand (attrNames details.commands or {}); inherit toplevel;
};
in
[ cmd ] ++ concatMap subcommand (attrNames details.commands or { });
manpages = processCommand { manpages = processCommand {
command = "nix"; command = "nix";
@ -199,9 +225,11 @@ let
toplevel = commandInfo.args; toplevel = commandInfo.args;
}; };
tableOfContents = let tableOfContents =
showEntry = page: let
" - [${page.command}](command-ref/new-cli/${page.name})"; showEntry = page: " - [${page.command}](command-ref/new-cli/${page.name})";
in concatStringsSep "\n" (map showEntry manpages) + "\n"; in
concatStringsSep "\n" (map showEntry manpages) + "\n";
in (listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; } in
(listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; }

View file

@ -1,67 +1,99 @@
let let
inherit (builtins) attrValues concatStringsSep isAttrs isBool mapAttrs; inherit (builtins)
inherit (import <nix/utils.nix>) concatStrings indent optionalString squash; attrValues
concatStringsSep
isAttrs
isBool
mapAttrs
;
inherit (import <nix/utils.nix>)
concatStrings
indent
optionalString
squash
;
in in
# `inlineHTML` is a hack to accommodate inconsistent output from `lowdown` # `inlineHTML` is a hack to accommodate inconsistent output from `lowdown`
{ prefix, inlineHTML ? true }: settingsInfo: {
prefix,
inlineHTML ? true,
}:
settingsInfo:
let let
showSetting = prefix: setting: { description, documentDefault, defaultValue, aliases, value, experimentalFeature }: showSetting =
prefix: setting:
{
description,
documentDefault,
defaultValue,
aliases,
value,
experimentalFeature,
}:
let let
result = squash '' result = squash ''
- ${item} - ${item}
${indent " " body} ${indent " " body}
''; '';
item = if inlineHTML item =
then ''<span id="${prefix}-${setting}">[`${setting}`](#${prefix}-${setting})</span>'' if inlineHTML then
else "`${setting}`"; ''<span id="${prefix}-${setting}">[`${setting}`](#${prefix}-${setting})</span>''
else
"`${setting}`";
# separate body to cleanly handle indentation # separate body to cleanly handle indentation
body = '' body = ''
${experimentalFeatureNote} ${experimentalFeatureNote}
${description} ${description}
**Default:** ${showDefault documentDefault defaultValue} **Default:** ${showDefault documentDefault defaultValue}
${showAliases aliases} ${showAliases aliases}
''; '';
experimentalFeatureNote = optionalString (experimentalFeature != null) '' experimentalFeatureNote = optionalString (experimentalFeature != null) ''
> **Warning** > **Warning**
> >
> This setting is part of an > This setting is part of an
> [experimental feature](@docroot@/development/experimental-features.md). > [experimental feature](@docroot@/development/experimental-features.md).
> >
> To change this setting, make sure the > To change this setting, make sure the
> [`${experimentalFeature}` experimental feature](@docroot@/development/experimental-features.md#xp-feature-${experimentalFeature}) > [`${experimentalFeature}` experimental feature](@docroot@/development/experimental-features.md#xp-feature-${experimentalFeature})
> is enabled. > is enabled.
> For example, include the following in [`nix.conf`](@docroot@/command-ref/conf-file.md): > For example, include the following in [`nix.conf`](@docroot@/command-ref/conf-file.md):
> >
> ``` > ```
> extra-experimental-features = ${experimentalFeature} > extra-experimental-features = ${experimentalFeature}
> ${setting} = ... > ${setting} = ...
> ``` > ```
''; '';
showDefault = documentDefault: defaultValue: showDefault =
documentDefault: defaultValue:
if documentDefault then if documentDefault then
# a StringMap value type is specified as a string, but # a StringMap value type is specified as a string, but
# this shows the value type. The empty stringmap is `null` in # this shows the value type. The empty stringmap is `null` in
# JSON, but that converts to `{ }` here. # JSON, but that converts to `{ }` here.
if defaultValue == "" || defaultValue == [] || isAttrs defaultValue if defaultValue == "" || defaultValue == [ ] || isAttrs defaultValue then
then "*empty*" "*empty*"
else if isBool defaultValue then else if isBool defaultValue then
if defaultValue then "`true`" else "`false`" if defaultValue then "`true`" else "`false`"
else "`${toString defaultValue}`" else
else "*machine-specific*"; "`${toString defaultValue}`"
else
"*machine-specific*";
showAliases = aliases: showAliases =
optionalString (aliases != []) aliases:
"**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}"; optionalString (aliases != [ ])
"**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}";
in result; in
result;
in concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo)) in
concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo))

View file

@ -1,6 +1,20 @@
let let
inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings; inherit (builtins)
inherit (import <nix/utils.nix>) optionalString filterAttrs trim squash toLower unique indent; attrNames
listToAttrs
concatStringsSep
readFile
replaceStrings
;
inherit (import <nix/utils.nix>)
optionalString
filterAttrs
trim
squash
toLower
unique
indent
;
showSettings = import <nix/generate-settings.nix>; showSettings = import <nix/generate-settings.nix>;
in in
@ -14,7 +28,13 @@ in
let let
showStore = { name, slug }: { settings, doc, experimentalFeature }: showStore =
{ name, slug }:
{
settings,
doc,
experimentalFeature,
}:
let let
result = squash '' result = squash ''
# ${name} # ${name}
@ -25,7 +45,10 @@ let
## Settings ## Settings
${showSettings { prefix = "store-${slug}"; inherit inlineHTML; } settings} ${showSettings {
prefix = "store-${slug}";
inherit inlineHTML;
} settings}
''; '';
experimentalFeatureNote = optionalString (experimentalFeature != null) '' experimentalFeatureNote = optionalString (experimentalFeature != null) ''
@ -43,15 +66,15 @@ let
> extra-experimental-features = ${experimentalFeature} > extra-experimental-features = ${experimentalFeature}
> ``` > ```
''; '';
in result; in
result;
storesList = map storesList = map (name: rec {
(name: rec { inherit name;
inherit name; slug = replaceStrings [ " " ] [ "-" ] (toLower name);
slug = replaceStrings [ " " ] [ "-" ] (toLower name); filename = "${slug}.md";
filename = "${slug}.md"; page = showStore { inherit name slug; } storeInfo.${name};
page = showStore { inherit name slug; } storeInfo.${name}; }) (attrNames storeInfo);
})
(attrNames storeInfo);
in storesList in
storesList

View file

@ -1,5 +1,11 @@
let let
inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings; inherit (builtins)
attrNames
listToAttrs
concatStringsSep
readFile
replaceStrings
;
showSettings = import <nix/generate-settings.nix>; showSettings = import <nix/generate-settings.nix>;
showStoreDocs = import <nix/generate-store-info.nix>; showStoreDocs = import <nix/generate-store-info.nix>;
in in
@ -14,26 +20,26 @@ let
index = index =
let let
showEntry = store: showEntry = store: "- [${store.name}](./${store.filename})";
"- [${store.name}](./${store.filename})";
in in
concatStringsSep "\n" (map showEntry storesList); concatStringsSep "\n" (map showEntry storesList);
"index.md" = replaceStrings "index.md" = replaceStrings [ "@store-types@" ] [ index ] (readFile ./src/store/types/index.md.in);
[ "@store-types@" ] [ index ]
(readFile ./src/store/types/index.md.in);
tableOfContents = tableOfContents =
let let
showEntry = store: showEntry = store: " - [${store.name}](store/types/${store.filename})";
" - [${store.name}](store/types/${store.filename})";
in in
concatStringsSep "\n" (map showEntry storesList) + "\n"; concatStringsSep "\n" (map showEntry storesList) + "\n";
"SUMMARY.md" = tableOfContents; "SUMMARY.md" = tableOfContents;
storePages = listToAttrs storePages = listToAttrs (
(map (s: { name = s.filename; value = s.page; }) storesList); map (s: {
name = s.filename;
value = s.page;
}) storesList
);
in in
storePages // { inherit "index.md" "SUMMARY.md"; } storePages // { inherit "index.md" "SUMMARY.md"; }

View file

@ -2,8 +2,8 @@ with builtins;
with import <nix/utils.nix>; with import <nix/utils.nix>;
let let
showExperimentalFeature = name: doc: showExperimentalFeature = name: doc: ''
'' - [`${name}`](@docroot@/development/experimental-features.md#xp-feature-${name})
- [`${name}`](@docroot@/development/experimental-features.md#xp-feature-${name}) '';
''; in
in xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps))) xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps)))

View file

@ -2,7 +2,8 @@ with builtins;
with import <nix/utils.nix>; with import <nix/utils.nix>;
let let
showExperimentalFeature = name: doc: showExperimentalFeature =
name: doc:
squash '' squash ''
## [`${name}`]{#xp-feature-${name}} ## [`${name}`]{#xp-feature-${name}}

View file

@ -11,10 +11,15 @@ rec {
concatStrings = concatStringsSep ""; concatStrings = concatStringsSep "";
attrsToList = a: attrsToList =
map (name: { inherit name; value = a.${name}; }) (builtins.attrNames a); a:
map (name: {
inherit name;
value = a.${name};
}) (builtins.attrNames a);
replaceStringsRec = from: to: string: replaceStringsRec =
from: to: string:
# recursively replace occurrences of `from` with `to` within `string` # recursively replace occurrences of `from` with `to` within `string`
# example: # example:
# replaceStringRec "--" "-" "hello-----world" # replaceStringRec "--" "-" "hello-----world"
@ -22,16 +27,18 @@ rec {
let let
replaced = replaceStrings [ from ] [ to ] string; replaced = replaceStrings [ from ] [ to ] string;
in in
if replaced == string then string else replaceStringsRec from to replaced; if replaced == string then string else replaceStringsRec from to replaced;
toLower = replaceStrings upperChars lowerChars; toLower = replaceStrings upperChars lowerChars;
squash = replaceStringsRec "\n\n\n" "\n\n"; squash = replaceStringsRec "\n\n\n" "\n\n";
trim = string: trim =
string:
# trim trailing spaces and squash non-leading spaces # trim trailing spaces and squash non-leading spaces
let let
trimLine = line: trimLine =
line:
let let
# separate leading spaces from the rest # separate leading spaces from the rest
parts = split "(^ *)" line; parts = split "(^ *)" line;
@ -39,19 +46,30 @@ rec {
rest = elemAt parts 2; rest = elemAt parts 2;
# drop trailing spaces # drop trailing spaces
body = head (split " *$" rest); body = head (split " *$" rest);
in spaces + replaceStringsRec " " " " body; in
in concatStringsSep "\n" (map trimLine (splitLines string)); spaces + replaceStringsRec " " " " body;
in
concatStringsSep "\n" (map trimLine (splitLines string));
# FIXME: O(n^2) # FIXME: O(n^2)
unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) []; unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [ ];
nameValuePair = name: value: { inherit name value; }; nameValuePair = name: value: { inherit name value; };
filterAttrs = pred: set: filterAttrs =
listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); pred: set:
listToAttrs (
concatMap (
name:
let
v = set.${name};
in
if pred name v then [ (nameValuePair name v) ] else [ ]
) (attrNames set)
);
optionalString = cond: string: if cond then string else ""; optionalString = cond: string: if cond then string else "";
indent = prefix: s: indent =
concatStringsSep "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s)); prefix: s: concatStringsSep "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s));
} }

View file

@ -1,70 +1,72 @@
{ pkgs ? import <nixpkgs> { } {
, lib ? pkgs.lib pkgs ? import <nixpkgs> { },
, name ? "nix" lib ? pkgs.lib,
, tag ? "latest" name ? "nix",
, bundleNixpkgs ? true tag ? "latest",
, channelName ? "nixpkgs" bundleNixpkgs ? true,
, channelURL ? "https://nixos.org/channels/nixpkgs-unstable" channelName ? "nixpkgs",
, extraPkgs ? [] channelURL ? "https://nixos.org/channels/nixpkgs-unstable",
, maxLayers ? 100 extraPkgs ? [ ],
, nixConf ? {} maxLayers ? 100,
, flake-registry ? null nixConf ? { },
flake-registry ? null,
}: }:
let let
defaultPkgs = with pkgs; [ defaultPkgs =
nix with pkgs;
bashInteractive [
coreutils-full nix
gnutar bashInteractive
gzip coreutils-full
gnugrep gnutar
which gzip
curl gnugrep
less which
wget curl
man less
cacert.out wget
findutils man
iana-etc cacert.out
git findutils
openssh iana-etc
] ++ extraPkgs; git
openssh
]
++ extraPkgs;
users = { users =
{
root = { root = {
uid = 0; uid = 0;
shell = "${pkgs.bashInteractive}/bin/bash"; shell = "${pkgs.bashInteractive}/bin/bash";
home = "/root"; home = "/root";
gid = 0; gid = 0;
groups = [ "root" ]; groups = [ "root" ];
description = "System administrator"; description = "System administrator";
}; };
nobody = { nobody = {
uid = 65534; uid = 65534;
shell = "${pkgs.shadow}/bin/nologin"; shell = "${pkgs.shadow}/bin/nologin";
home = "/var/empty"; home = "/var/empty";
gid = 65534; gid = 65534;
groups = [ "nobody" ]; groups = [ "nobody" ];
description = "Unprivileged account (don't use!)"; description = "Unprivileged account (don't use!)";
}; };
} // lib.listToAttrs ( }
map // lib.listToAttrs (
( map (n: {
n: { name = "nixbld${toString n}";
name = "nixbld${toString n}"; value = {
value = { uid = 30000 + n;
uid = 30000 + n; gid = 30000;
gid = 30000; groups = [ "nixbld" ];
groups = [ "nixbld" ]; description = "Nix build user ${toString n}";
description = "Nix build user ${toString n}"; };
}; }) (lib.lists.range 1 32)
} );
)
(lib.lists.range 1 32)
);
groups = { groups = {
root.gid = 0; root.gid = 0;
@ -74,24 +76,20 @@ let
userToPasswd = ( userToPasswd = (
k: k:
{ uid {
, gid ? 65534 uid,
, home ? "/var/empty" gid ? 65534,
, description ? "" home ? "/var/empty",
, shell ? "/bin/false" description ? "",
, groups ? [ ] shell ? "/bin/false",
}: "${k}:x:${toString uid}:${toString gid}:${description}:${home}:${shell}" groups ? [ ],
); }:
passwdContents = ( "${k}:x:${toString uid}:${toString gid}:${description}:${home}:${shell}"
lib.concatStringsSep "\n"
(lib.attrValues (lib.mapAttrs userToPasswd users))
); );
passwdContents = (lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs userToPasswd users)));
userToShadow = k: { ... }: "${k}:!:1::::::"; userToShadow = k: { ... }: "${k}:!:1::::::";
shadowContents = ( shadowContents = (lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs userToShadow users)));
lib.concatStringsSep "\n"
(lib.attrValues (lib.mapAttrs userToShadow users))
);
# Map groups to members # Map groups to members
# { # {
@ -101,42 +99,35 @@ let
let let
# Create a flat list of user/group mappings # Create a flat list of user/group mappings
mappings = ( mappings = (
builtins.foldl' builtins.foldl' (
( acc: user:
acc: user: let
let groups = users.${user}.groups or [ ];
groups = users.${user}.groups or [ ]; in
in acc
acc ++ map ++ map (group: {
(group: { inherit user group;
inherit user group; }) groups
}) ) [ ] (lib.attrNames users)
groups
)
[ ]
(lib.attrNames users)
); );
in in
( (builtins.foldl' (
builtins.foldl' acc: v:
( acc
acc: v: acc // { // {
${v.group} = acc.${v.group} or [ ] ++ [ v.user ]; ${v.group} = acc.${v.group} or [ ] ++ [ v.user ];
} }
) ) { } mappings)
{ }
mappings)
); );
groupToGroup = k: { gid }: groupToGroup =
k:
{ gid }:
let let
members = groupMemberMap.${k} or [ ]; members = groupMemberMap.${k} or [ ];
in in
"${k}:x:${toString gid}:${lib.concatStringsSep "," members}"; "${k}:x:${toString gid}:${lib.concatStringsSep "," members}";
groupContents = ( groupContents = (lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs groupToGroup groups)));
lib.concatStringsSep "\n"
(lib.attrValues (lib.mapAttrs groupToGroup groups))
);
defaultNixConf = { defaultNixConf = {
sandbox = "false"; sandbox = "false";
@ -144,11 +135,17 @@ let
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
}; };
nixConfContents = (lib.concatStringsSep "\n" (lib.mapAttrsFlatten (n: v: nixConfContents =
let (lib.concatStringsSep "\n" (
vStr = if builtins.isList v then lib.concatStringsSep " " v else v; lib.mapAttrsFlatten (
in n: v:
"${n} = ${vStr}") (defaultNixConf // nixConf))) + "\n"; let
vStr = if builtins.isList v then lib.concatStringsSep " " v else v;
in
"${n} = ${vStr}"
) (defaultNixConf // nixConf)
))
+ "\n";
baseSystem = baseSystem =
let let
@ -167,21 +164,29 @@ let
manifest = pkgs.buildPackages.runCommand "manifest.nix" { } '' manifest = pkgs.buildPackages.runCommand "manifest.nix" { } ''
cat > $out <<EOF cat > $out <<EOF
[ [
${lib.concatStringsSep "\n" (builtins.map (drv: let ${lib.concatStringsSep "\n" (
outputs = drv.outputsToInstall or [ "out" ]; builtins.map (
in '' drv:
{ let
${lib.concatStringsSep "\n" (builtins.map (output: '' outputs = drv.outputsToInstall or [ "out" ];
${output} = { outPath = "${lib.getOutput output drv}"; }; in
'') outputs)} ''
outputs = [ ${lib.concatStringsSep " " (builtins.map (x: "\"${x}\"") outputs)} ]; {
name = "${drv.name}"; ${lib.concatStringsSep "\n" (
outPath = "${drv}"; builtins.map (output: ''
system = "${drv.system}"; ${output} = { outPath = "${lib.getOutput output drv}"; };
type = "derivation"; '') outputs
meta = { }; )}
} outputs = [ ${lib.concatStringsSep " " (builtins.map (x: "\"${x}\"") outputs)} ];
'') defaultPkgs)} name = "${drv.name}";
outPath = "${drv}";
system = "${drv.system}";
type = "derivation";
meta = { };
}
''
) defaultPkgs
)}
] ]
EOF EOF
''; '';
@ -190,16 +195,22 @@ let
cp -a ${rootEnv}/* $out/ cp -a ${rootEnv}/* $out/
ln -s ${manifest} $out/manifest.nix ln -s ${manifest} $out/manifest.nix
''; '';
flake-registry-path = if (flake-registry == null) then flake-registry-path =
null if (flake-registry == null) then
else if (builtins.readFileType (toString flake-registry)) == "directory" then null
"${flake-registry}/flake-registry.json" else if (builtins.readFileType (toString flake-registry)) == "directory" then
else "${flake-registry}/flake-registry.json"
flake-registry; else
flake-registry;
in in
pkgs.runCommand "base-system" pkgs.runCommand "base-system"
{ {
inherit passwdContents groupContents shadowContents nixConfContents; inherit
passwdContents
groupContents
shadowContents
nixConfContents
;
passAsFile = [ passAsFile = [
"passwdContents" "passwdContents"
"groupContents" "groupContents"
@ -208,62 +219,66 @@ let
]; ];
allowSubstitutes = false; allowSubstitutes = false;
preferLocalBuild = true; preferLocalBuild = true;
} ('' }
env (
set -x ''
mkdir -p $out/etc env
set -x
mkdir -p $out/etc
mkdir -p $out/etc/ssl/certs mkdir -p $out/etc/ssl/certs
ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs
cat $passwdContentsPath > $out/etc/passwd cat $passwdContentsPath > $out/etc/passwd
echo "" >> $out/etc/passwd echo "" >> $out/etc/passwd
cat $groupContentsPath > $out/etc/group cat $groupContentsPath > $out/etc/group
echo "" >> $out/etc/group echo "" >> $out/etc/group
cat $shadowContentsPath > $out/etc/shadow cat $shadowContentsPath > $out/etc/shadow
echo "" >> $out/etc/shadow echo "" >> $out/etc/shadow
mkdir -p $out/usr mkdir -p $out/usr
ln -s /nix/var/nix/profiles/share $out/usr/ ln -s /nix/var/nix/profiles/share $out/usr/
mkdir -p $out/nix/var/nix/gcroots mkdir -p $out/nix/var/nix/gcroots
mkdir $out/tmp mkdir $out/tmp
mkdir -p $out/var/tmp mkdir -p $out/var/tmp
mkdir -p $out/etc/nix mkdir -p $out/etc/nix
cat $nixConfContentsPath > $out/etc/nix/nix.conf cat $nixConfContentsPath > $out/etc/nix/nix.conf
mkdir -p $out/root mkdir -p $out/root
mkdir -p $out/nix/var/nix/profiles/per-user/root mkdir -p $out/nix/var/nix/profiles/per-user/root
ln -s ${profile} $out/nix/var/nix/profiles/default-1-link ln -s ${profile} $out/nix/var/nix/profiles/default-1-link
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
ln -s /nix/var/nix/profiles/default $out/root/.nix-profile ln -s /nix/var/nix/profiles/default $out/root/.nix-profile
ln -s ${channel} $out/nix/var/nix/profiles/per-user/root/channels-1-link ln -s ${channel} $out/nix/var/nix/profiles/per-user/root/channels-1-link
ln -s /nix/var/nix/profiles/per-user/root/channels-1-link $out/nix/var/nix/profiles/per-user/root/channels ln -s /nix/var/nix/profiles/per-user/root/channels-1-link $out/nix/var/nix/profiles/per-user/root/channels
mkdir -p $out/root/.nix-defexpr mkdir -p $out/root/.nix-defexpr
ln -s /nix/var/nix/profiles/per-user/root/channels $out/root/.nix-defexpr/channels ln -s /nix/var/nix/profiles/per-user/root/channels $out/root/.nix-defexpr/channels
echo "${channelURL} ${channelName}" > $out/root/.nix-channels echo "${channelURL} ${channelName}" > $out/root/.nix-channels
mkdir -p $out/bin $out/usr/bin mkdir -p $out/bin $out/usr/bin
ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env
ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh
'' + (lib.optionalString (flake-registry-path != null) '' ''
nixCacheDir="/root/.cache/nix" + (lib.optionalString (flake-registry-path != null) ''
mkdir -p $out$nixCacheDir nixCacheDir="/root/.cache/nix"
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json" mkdir -p $out$nixCacheDir
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
mkdir -p $out/nix/var/nix/gcroots/auto ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
rootName=$(${pkgs.nix}/bin/nix --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath)) mkdir -p $out/nix/var/nix/gcroots/auto
ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName rootName=$(${pkgs.nix}/bin/nix --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
'')); ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName
'')
);
in in
pkgs.dockerTools.buildLayeredImageWithNixDb { pkgs.dockerTools.buildLayeredImageWithNixDb {
@ -285,15 +300,19 @@ pkgs.dockerTools.buildLayeredImageWithNixDb {
Cmd = [ "/root/.nix-profile/bin/bash" ]; Cmd = [ "/root/.nix-profile/bin/bash" ];
Env = [ Env = [
"USER=root" "USER=root"
"PATH=${lib.concatStringsSep ":" [ "PATH=${
"/root/.nix-profile/bin" lib.concatStringsSep ":" [
"/nix/var/nix/profiles/default/bin" "/root/.nix-profile/bin"
"/nix/var/nix/profiles/default/sbin" "/nix/var/nix/profiles/default/bin"
]}" "/nix/var/nix/profiles/default/sbin"
"MANPATH=${lib.concatStringsSep ":" [ ]
"/root/.nix-profile/share/man" }"
"/nix/var/nix/profiles/default/share/man" "MANPATH=${
]}" lib.concatStringsSep ":" [
"/root/.nix-profile/share/man"
"/nix/var/nix/profiles/default/share/man"
]
}"
"SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" "SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
"GIT_SSL_CAINFO=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" "GIT_SSL_CAINFO=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
"NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" "NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"

567
flake.nix
View file

@ -4,8 +4,14 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446"; inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
inputs.flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; inputs.flake-compat = {
inputs.libgit2 = { url = "github:libgit2/libgit2/v1.8.1"; flake = false; }; url = "github:edolstra/flake-compat";
flake = false;
};
inputs.libgit2 = {
url = "github:libgit2/libgit2/v1.8.1";
flake = false;
};
# dev tooling # dev tooling
inputs.flake-parts.url = "github:hercules-ci/flake-parts"; inputs.flake-parts.url = "github:hercules-ci/flake-parts";
@ -18,8 +24,14 @@
inputs.git-hooks-nix.inputs.flake-compat.follows = ""; inputs.git-hooks-nix.inputs.flake-compat.follows = "";
inputs.git-hooks-nix.inputs.gitignore.follows = ""; inputs.git-hooks-nix.inputs.gitignore.follows = "";
outputs = inputs@{ self, nixpkgs, nixpkgs-regression, libgit2, ... }: outputs =
inputs@{
self,
nixpkgs,
nixpkgs-regression,
libgit2,
...
}:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
@ -28,14 +40,23 @@
version = lib.fileContents ./.version + versionSuffix; version = lib.fileContents ./.version + versionSuffix;
versionSuffix = versionSuffix =
if officialRelease if officialRelease then
then "" ""
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}"; else
"pre${
builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")
}_${self.shortRev or "dirty"}";
linux32BitSystems = [ "i686-linux" ]; linux32BitSystems = [ "i686-linux" ];
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ]; linux64BitSystems = [
"x86_64-linux"
"aarch64-linux"
];
linuxSystems = linux32BitSystems ++ linux64BitSystems; linuxSystems = linux32BitSystems ++ linux64BitSystems;
darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ]; darwinSystems = [
"x86_64-darwin"
"aarch64-darwin"
];
systems = linuxSystems ++ darwinSystems; systems = linuxSystems ++ darwinSystems;
crossSystems = [ crossSystems = [
@ -64,62 +85,76 @@
(Provided that the names are unique.) (Provided that the names are unique.)
See https://nixos.org/manual/nixpkgs/stable/index.html#function-library-lib.attrsets.concatMapAttrs See https://nixos.org/manual/nixpkgs/stable/index.html#function-library-lib.attrsets.concatMapAttrs
*/ */
flatMapAttrs = attrs: f: lib.concatMapAttrs f attrs; flatMapAttrs = attrs: f: lib.concatMapAttrs f attrs;
forAllSystems = lib.genAttrs systems; forAllSystems = lib.genAttrs systems;
forAllCrossSystems = lib.genAttrs crossSystems; forAllCrossSystems = lib.genAttrs crossSystems;
forAllStdenvs = f: forAllStdenvs =
lib.listToAttrs f:
(map lib.listToAttrs (
(stdenvName: { map (stdenvName: {
name = "${stdenvName}Packages"; name = "${stdenvName}Packages";
value = f stdenvName; value = f stdenvName;
}) }) stdenvs
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
# load without fetching any development inputs. # load without fetching any development inputs.
devFlake = inputs.flake-parts.lib.mkFlake { inherit inputs; } { devFlake = inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ ./maintainers/flake-module.nix ]; imports = [ ./maintainers/flake-module.nix ];
systems = lib.subtractLists crossSystems systems; systems = lib.subtractLists crossSystems systems;
perSystem = { system, ... }: { perSystem =
_module.args.pkgs = nixpkgsFor.${system}.native; { system, ... }:
}; {
_module.args.pkgs = nixpkgsFor.${system}.native;
};
}; };
# Memoize nixpkgs for different platforms for efficiency. # Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems nixpkgsFor = forAllSystems (
(system: let system:
make-pkgs = crossSystem: stdenv: import nixpkgs { let
localSystem = { make-pkgs =
inherit system; crossSystem: stdenv:
import nixpkgs {
localSystem = {
inherit system;
};
crossSystem =
if crossSystem == null then
null
else
{
config = crossSystem;
}
// lib.optionalAttrs (crossSystem == "x86_64-unknown-freebsd13") {
useLLVM = true;
};
overlays = [
(overlayFor (p: p.${stdenv}))
];
}; };
crossSystem = if crossSystem == null then null else {
config = crossSystem;
} // lib.optionalAttrs (crossSystem == "x86_64-unknown-freebsd13") {
useLLVM = true;
};
overlays = [
(overlayFor (p: p.${stdenv}))
];
};
stdenvs = forAllStdenvs (make-pkgs null); stdenvs = forAllStdenvs (make-pkgs null);
native = stdenvs.stdenvPackages; native = stdenvs.stdenvPackages;
in { in
{
inherit stdenvs native; inherit stdenvs native;
static = native.pkgsStatic; static = native.pkgsStatic;
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv"); cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
}); }
);
binaryTarball = nix: pkgs: pkgs.callPackage ./scripts/binary-tarball.nix { binaryTarball =
inherit nix; 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;
in in
@ -134,10 +169,12 @@
# The dependencies are in their own scope, so that they don't have to be # The dependencies are in their own scope, so that they don't have to be
# in Nixpkgs top level `pkgs` or `nixComponents`. # in Nixpkgs top level `pkgs` or `nixComponents`.
nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix { nixDependencies = lib.makeScope final.newScope (
inherit inputs stdenv versionSuffix; import ./packaging/dependencies.nix {
pkgs = final; inherit inputs stdenv versionSuffix;
}); pkgs = final;
}
);
nix = final.nixComponents.nix; nix = final.nixComponents.nix;
@ -149,13 +186,20 @@
# See https://github.com/NixOS/nixpkgs/pull/214409 # See https://github.com/NixOS/nixpkgs/pull/214409
# Remove when fixed in this flake's nixpkgs # Remove when fixed in this flake's nixpkgs
pre-commit = pre-commit =
if prev.stdenv.hostPlatform.system == "i686-linux" if prev.stdenv.hostPlatform.system == "i686-linux" then
then (prev.pre-commit.override (o: { dotnet-sdk = ""; })).overridePythonAttrs (o: { doCheck = false; }) (prev.pre-commit.override (o: {
else prev.pre-commit; dotnet-sdk = "";
})).overridePythonAttrs
(o: {
doCheck = false;
})
else
prev.pre-commit;
}; };
in { in
{
# A Nixpkgs overlay that overrides the 'nix' and # A Nixpkgs overlay that overrides the 'nix' and
# 'nix-perl-bindings' packages. # 'nix-perl-bindings' packages.
overlays.default = overlayFor (p: p.stdenv); overlays.default = overlayFor (p: p.stdenv);
@ -173,53 +217,69 @@
; ;
}; };
checks = forAllSystems (system: { checks = forAllSystems (
installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system}; system:
installTests = self.hydraJobs.installTests.${system}; {
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system}; installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system};
rl-next = installTests = self.hydraJobs.installTests.${system};
let pkgs = nixpkgsFor.${system}.native; nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } '' rl-next =
LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out let
''; pkgs = nixpkgsFor.${system}.native;
repl-completion = nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.nix { }; in
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) { pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
dockerImage = self.hydraJobs.dockerImage.${system}; LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out
} // (lib.optionalAttrs (!(builtins.elem system linux32BitSystems))) { '';
# Some perl dependencies are broken on i686-linux. repl-completion = nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.nix { };
# Since the support is only best-effort there, disable the perl }
# bindings // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
dockerImage = self.hydraJobs.dockerImage.${system};
}
// (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
# Temporarily disabled because GitHub Actions OOM issues. Once # Temporarily disabled because GitHub Actions OOM issues. Once
# the old build system is gone and we are back to one build # the old build system is gone and we are back to one build
# system, we should reenable this. # system, we should reenable this.
#perlBindings = self.hydraJobs.perlBindings.${system}; #perlBindings = self.hydraJobs.perlBindings.${system};
} }
# Add "passthru" tests # Add "passthru" tests
// flatMapAttrs ({ //
"" = nixpkgsFor.${system}.native; flatMapAttrs
} // lib.optionalAttrs (! nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) { (
# TODO: enable static builds for darwin, blocked on: {
# https://github.com/NixOS/nixpkgs/issues/320448 "" = nixpkgsFor.${system}.native;
"static-" = nixpkgsFor.${system}.static; }
}) // lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) {
(nixpkgsPrefix: nixpkgs: # TODO: enable static builds for darwin, blocked on:
flatMapAttrs nixpkgs.nixComponents # https://github.com/NixOS/nixpkgs/issues/320448
(pkgName: pkg: "static-" = nixpkgsFor.${system}.static;
flatMapAttrs pkg.tests or {} }
(testName: test: {
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
})
) )
) (
// devFlake.checks.${system} or {} nixpkgsPrefix: nixpkgs:
flatMapAttrs nixpkgs.nixComponents (
pkgName: pkg:
flatMapAttrs pkg.tests or { } (
testName: test: {
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
}
)
)
)
// devFlake.checks.${system} or { }
); );
packages = forAllSystems (system: packages = forAllSystems (
{ # Here we put attributes that map 1:1 into packages.<system>, ie 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. # for which we don't apply the full build matrix such as cross or static.
inherit (nixpkgsFor.${system}.native) inherit (nixpkgsFor.${system}.native)
changelog-d; changelog-d
;
default = self.packages.${system}.nix; default = self.packages.${system}.nix;
binaryTarball = self.hydraJobs.binaryTarball.${system}; binaryTarball = self.hydraJobs.binaryTarball.${system};
installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system}; installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system};
@ -227,148 +287,191 @@
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs; nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
} }
# We need to flatten recursive attribute sets of derivations to pass `flake check`. # We need to flatten recursive attribute sets of derivations to pass `flake check`.
// flatMapAttrs //
{ # Components we'll iterate over in the upcoming lambda flatMapAttrs
"nix" = { };
# 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 these.
#"nix-util" = { };
#"nix-store" = { };
#"nix-fetchers" = { };
}
(pkgName: {}: {
# These attributes go right into `packages.<system>`.
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
"${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName};
}
// flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: {
# These attributes go right into `packages.<system>`.
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
})
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: {
# These attributes go right into `packages.<system>`.
"${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName};
})
)
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
dockerImage =
let
pkgs = nixpkgsFor.${system}.native;
image = import ./docker.nix { inherit pkgs; tag = version; };
in
pkgs.runCommand
"docker-image-tarball-${version}"
{ 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
'';
});
devShells = let
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs:
let
modular = devFlake.getSystem stdenv.buildPlatform.system;
transformFlag = prefix: flag:
assert builtins.isString flag;
let
rest = builtins.substring 2 (builtins.stringLength flag) flag;
in
"-D${prefix}:${rest}";
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags;
in {
pname = "shell-for-" + attrs.pname;
# Remove the version suffix to avoid unnecessary attempts to substitute in nix develop
version = lib.fileContents ./.version;
name = attrs.pname;
installFlags = "sysconfdir=$(out)/etc";
shellHook = ''
PATH=$prefix/bin:$PATH
unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH
# Make bash completion work.
XDG_DATA_DIRS+=:$out/share
'';
# We use this shell with the local checkout, not unpackPhase.
src = null;
env = {
# Needed for Meson to find Boost.
# https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_INCLUDEDIR = "${lib.getDev pkgs.nixDependencies.boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib pkgs.nixDependencies.boost}/lib";
# For `make format`, to work without installing pre-commit
_NIX_PRE_COMMIT_HOOKS_CONFIG =
"${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" modular.pre-commit.settings.rawConfig}";
};
mesonFlags =
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents.nix-store.mesonFlags)
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents.nix-fetchers.mesonFlags)
++ lib.optionals havePerl (map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents.nix-perl-bindings.mesonFlags))
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents.nix-cmd.mesonFlags)
;
nativeBuildInputs = attrs.nativeBuildInputs or []
++ pkgs.nixComponents.nix-util.nativeBuildInputs
++ pkgs.nixComponents.nix-store.nativeBuildInputs
++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs
++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ lib.optional
(!stdenv.buildPlatform.canExecute stdenv.hostPlatform
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
&& !(stdenv.hostPlatform.isWindows && stdenv.buildPlatform.isDarwin)
&& stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages
&& lib.meta.availableOn stdenv.buildPlatform (stdenv.hostPlatform.emulator pkgs.buildPackages))
pkgs.buildPackages.mesonEmulatorHook
++ [
pkgs.buildPackages.cmake
pkgs.buildPackages.shellcheck
pkgs.buildPackages.changelog-d
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install"
modular.pre-commit.settings.installationScript)
]
# TODO: Remove the darwin check once
# https://github.com/NixOS/nixpkgs/pull/291814 is available
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) pkgs.buildPackages.clang-tools;
buildInputs = attrs.buildInputs or []
++ [
pkgs.gtest
pkgs.rapidcheck
]
++ lib.optional havePerl pkgs.perl
;
});
in
forAllSystems (system:
let
makeShells = prefix: pkgs:
lib.mapAttrs'
(k: v: lib.nameValuePair "${prefix}-${k}" v)
(forAllStdenvs (stdenvName: makeShell pkgs pkgs.${stdenvName}));
in
(makeShells "native" nixpkgsFor.${system}.native) //
(lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.isDarwin)
(makeShells "static" nixpkgsFor.${system}.static) //
(forAllCrossSystems (crossSystem: let pkgs = nixpkgsFor.${system}.cross.${crossSystem}; in makeShell pkgs pkgs.stdenv))) //
{ {
default = self.devShells.${system}.native-stdenvPackages; # Components we'll iterate over in the upcoming lambda
"nix" = { };
# 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 these.
#"nix-util" = { };
#"nix-store" = { };
#"nix-fetchers" = { };
} }
(
pkgName:
{ }:
{
# These attributes go right into `packages.<system>`.
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
"${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName};
}
// flatMapAttrs (lib.genAttrs crossSystems (_: { })) (
crossSystem:
{ }:
{
# These attributes go right into `packages.<system>`.
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
}
)
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (
stdenvName:
{ }:
{
# These attributes go right into `packages.<system>`.
"${pkgName}-${stdenvName}" =
nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName};
}
)
)
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
dockerImage =
let
pkgs = nixpkgsFor.${system}.native;
image = import ./docker.nix {
inherit pkgs;
tag = version;
};
in
pkgs.runCommand "docker-image-tarball-${version}"
{ 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
'';
}
);
devShells =
let
makeShell =
pkgs: stdenv:
(pkgs.nix.override {
inherit stdenv;
forDevShell = true;
}).overrideAttrs
(
attrs:
let
modular = devFlake.getSystem stdenv.buildPlatform.system;
transformFlag =
prefix: flag:
assert builtins.isString flag;
let
rest = builtins.substring 2 (builtins.stringLength flag) flag;
in
"-D${prefix}:${rest}";
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags;
in
{
pname = "shell-for-" + attrs.pname;
# Remove the version suffix to avoid unnecessary attempts to substitute in nix develop
version = lib.fileContents ./.version;
name = attrs.pname;
installFlags = "sysconfdir=$(out)/etc";
shellHook = ''
PATH=$prefix/bin:$PATH
unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH
# Make bash completion work.
XDG_DATA_DIRS+=:$out/share
'';
# We use this shell with the local checkout, not unpackPhase.
src = null;
env = {
# Needed for Meson to find Boost.
# https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_INCLUDEDIR = "${lib.getDev pkgs.nixDependencies.boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib pkgs.nixDependencies.boost}/lib";
# For `make format`, to work without installing pre-commit
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
modular.pre-commit.settings.rawConfig
}";
};
mesonFlags =
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents.nix-store.mesonFlags)
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents.nix-fetchers.mesonFlags)
++ lib.optionals havePerl (
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents.nix-perl-bindings.mesonFlags)
)
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents.nix-cmd.mesonFlags);
nativeBuildInputs =
attrs.nativeBuildInputs or [ ]
++ pkgs.nixComponents.nix-util.nativeBuildInputs
++ pkgs.nixComponents.nix-store.nativeBuildInputs
++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs
++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ lib.optional (
!stdenv.buildPlatform.canExecute stdenv.hostPlatform
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
&& !(stdenv.hostPlatform.isWindows && stdenv.buildPlatform.isDarwin)
&& stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages
&& lib.meta.availableOn stdenv.buildPlatform (stdenv.hostPlatform.emulator pkgs.buildPackages)
) pkgs.buildPackages.mesonEmulatorHook
++ [
pkgs.buildPackages.cmake
pkgs.buildPackages.shellcheck
pkgs.buildPackages.changelog-d
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript)
]
# TODO: Remove the darwin check once
# https://github.com/NixOS/nixpkgs/pull/291814 is available
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
++ lib.optional (
stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform
) pkgs.buildPackages.clang-tools;
buildInputs =
attrs.buildInputs or [ ]
++ [
pkgs.gtest
pkgs.rapidcheck
]
++ lib.optional havePerl pkgs.perl;
}
);
in
forAllSystems (
system:
let
makeShells =
prefix: pkgs:
lib.mapAttrs' (k: v: lib.nameValuePair "${prefix}-${k}" v) (
forAllStdenvs (stdenvName: makeShell pkgs pkgs.${stdenvName})
);
in
(makeShells "native" nixpkgsFor.${system}.native)
// (
lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.isDarwin) (
makeShells "static" nixpkgsFor.${system}.static
)
// (forAllCrossSystems (
crossSystem:
let
pkgs = nixpkgsFor.${system}.cross.${crossSystem};
in
makeShell pkgs pkgs.stdenv
))
)
// {
default = self.devShells.${system}.native-stdenvPackages;
}
); );
}; };
} }

File diff suppressed because it is too large Load diff

View file

@ -1,115 +1,116 @@
{ lib {
, stdenv lib,
, releaseTools stdenv,
, autoconf-archive releaseTools,
, autoreconfHook autoconf-archive,
, aws-sdk-cpp autoreconfHook,
, boehmgc aws-sdk-cpp,
, nlohmann_json boehmgc,
, bison nlohmann_json,
, boost bison,
, brotli boost,
, bzip2 brotli,
, curl bzip2,
, editline curl,
, readline editline,
, flex readline,
, git flex,
, gtest git,
, jq gtest,
, libarchive jq,
, libcpuid libarchive,
, libgit2 libcpuid,
, libseccomp libgit2,
, libsodium libseccomp,
, man libsodium,
, darwin man,
, lowdown darwin,
, mdbook lowdown,
, mdbook-linkcheck mdbook,
, mercurial mdbook-linkcheck,
, openssh mercurial,
, openssl openssh,
, pkg-config openssl,
, rapidcheck pkg-config,
, sqlite rapidcheck,
, toml11 sqlite,
, unixtools toml11,
, xz unixtools,
xz,
, busybox-sandbox-shell ? null busybox-sandbox-shell ? null,
# Configuration Options # Configuration Options
#: #:
# This probably seems like too many degrees of freedom, but it # This probably seems like too many degrees of freedom, but it
# faithfully reflects how the underlying configure + make build system # faithfully reflects how the underlying configure + make build system
# work. The top-level flake.nix will choose useful combinations of these # work. The top-level flake.nix will choose useful combinations of these
# options to CI. # options to CI.
, pname ? "nix" pname ? "nix",
, versionSuffix ? "" versionSuffix ? "",
# Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix # Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix
, doBuild ? true doBuild ? true,
# Run the unit tests as part of the build. See `installUnitTests` for an # Run the unit tests as part of the build. See `installUnitTests` for an
# alternative to this. # alternative to this.
, doCheck ? __forDefaults.canRunInstalled doCheck ? __forDefaults.canRunInstalled,
# Run the functional tests as part of the build. # Run the functional tests as part of the build.
, doInstallCheck ? test-client != null || __forDefaults.canRunInstalled doInstallCheck ? test-client != null || __forDefaults.canRunInstalled,
# Check test coverage of Nix. Probably want to use with at least # Check test coverage of Nix. Probably want to use with at least
# one of `doCHeck` or `doInstallCheck` enabled. # one of `doCHeck` or `doInstallCheck` enabled.
, withCoverageChecks ? false withCoverageChecks ? false,
# Whether to build the regular manual # Whether to build the regular manual
, enableManual ? __forDefaults.canRunInstalled enableManual ? __forDefaults.canRunInstalled,
# Whether to use garbage collection for the Nix language evaluator. # Whether to use garbage collection for the Nix language evaluator.
# #
# If it is disabled, we just leak memory, but this is not as bad as it # If it is disabled, we just leak memory, but this is not as bad as it
# sounds so long as evaluation just takes places within short-lived # sounds so long as evaluation just takes places within short-lived
# processes. (When the process exits, the memory is reclaimed; it is # processes. (When the process exits, the memory is reclaimed; it is
# only leaked *within* the process.) # only leaked *within* the process.)
# #
# Temporarily disabled on Windows because the `GC_throw_bad_alloc` # Temporarily disabled on Windows because the `GC_throw_bad_alloc`
# symbol is missing during linking. # symbol is missing during linking.
# #
# Disabled on OpenBSD because of missing `_data_start` symbol while linking # Disabled on OpenBSD because of missing `_data_start` symbol while linking
, enableGC ? !stdenv.hostPlatform.isWindows && !stdenv.hostPlatform.isOpenBSD enableGC ? !stdenv.hostPlatform.isWindows && !stdenv.hostPlatform.isOpenBSD,
# Whether to enable Markdown rendering in the Nix binary. # Whether to enable Markdown rendering in the Nix binary.
, enableMarkdown ? !stdenv.hostPlatform.isWindows enableMarkdown ? !stdenv.hostPlatform.isWindows,
# Which interactive line editor library to use for Nix's repl. # Which interactive line editor library to use for Nix's repl.
# #
# Currently supported choices are: # Currently supported choices are:
# #
# - editline (default) # - editline (default)
# - readline # - readline
, readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline" readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline",
# Whether to install unit tests. This is useful when cross compiling # Whether to install unit tests. This is useful when cross compiling
# since we cannot run them natively during the build, but can do so # since we cannot run them natively during the build, but can do so
# later. # later.
, installUnitTests ? doBuild && !__forDefaults.canExecuteHost installUnitTests ? doBuild && !__forDefaults.canExecuteHost,
# For running the functional tests against a pre-built Nix. Probably # For running the functional tests against a pre-built Nix. Probably
# want to use in conjunction with `doBuild = false;`. # want to use in conjunction with `doBuild = false;`.
, test-daemon ? null test-daemon ? null,
, test-client ? null test-client ? null,
# Avoid setting things that would interfere with a functioning devShell # Avoid setting things that would interfere with a functioning devShell
, forDevShell ? false forDevShell ? false,
# Not a real argument, just the only way to approximate let-binding some # Not a real argument, just the only way to approximate let-binding some
# stuff for argument defaults. # stuff for argument defaults.
, __forDefaults ? { __forDefaults ? {
canExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform; canExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
canRunInstalled = doBuild && __forDefaults.canExecuteHost; canRunInstalled = doBuild && __forDefaults.canExecuteHost;
} },
}: }:
let let
@ -125,250 +126,304 @@ let
}; };
mkDerivation = mkDerivation =
if withCoverageChecks if withCoverageChecks then
then
# TODO support `finalAttrs` args function in # TODO support `finalAttrs` args function in
# `releaseTools.coverageAnalysis`. # `releaseTools.coverageAnalysis`.
argsFun: argsFun:
releaseTools.coverageAnalysis (let args = argsFun args; in args) releaseTools.coverageAnalysis (
else stdenv.mkDerivation; let
args = argsFun args;
in
args
)
else
stdenv.mkDerivation;
in in
mkDerivation (finalAttrs: let mkDerivation (
finalAttrs:
let
inherit (finalAttrs) inherit (finalAttrs)
doCheck doCheck
doInstallCheck doInstallCheck
; ;
doBuild = !finalAttrs.dontBuild; doBuild = !finalAttrs.dontBuild;
# Either running the unit tests during the build, or installing them # Either running the unit tests during the build, or installing them
# to be run later, requiresthe unit tests to be built. # to be run later, requiresthe unit tests to be built.
buildUnitTests = doCheck || installUnitTests; buildUnitTests = doCheck || installUnitTests;
in { in
inherit pname version; {
inherit pname version;
src = src =
let let
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.; baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
in in
fileset.toSource { fileset.toSource {
root = ./.; root = ./.;
fileset = fileset.intersection baseFiles (fileset.unions ([ fileset = fileset.intersection baseFiles (
# For configure fileset.unions (
./.version [
./configure.ac # For configure
./m4 ./.version
# TODO: do we really need README.md? It doesn't seem used in the build. ./configure.ac
./README.md ./m4
# This could be put behind a conditional # TODO: do we really need README.md? It doesn't seem used in the build.
./maintainers/local.mk ./README.md
# For make, regardless of what we are building # This could be put behind a conditional
./local.mk ./maintainers/local.mk
./Makefile # For make, regardless of what we are building
./Makefile.config.in ./local.mk
./mk ./Makefile
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts) ./Makefile.config.in
] ++ lib.optionals doBuild [ ./mk
./doc (fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
./misc ]
./precompiled-headers.h ++ lib.optionals doBuild [
(fileset.difference ./src ./src/perl) ./doc
./COPYING ./misc
./scripts/local.mk ./precompiled-headers.h
] ++ lib.optionals enableManual [ (fileset.difference ./src ./src/perl)
./doc/manual ./COPYING
] ++ lib.optionals buildUnitTests [ ./scripts/local.mk
./tests/unit ]
] ++ lib.optionals doInstallCheck [ ++ lib.optionals enableManual [
./tests/functional ./doc/manual
])); ]
++ lib.optionals buildUnitTests [
./tests/unit
]
++ lib.optionals doInstallCheck [
./tests/functional
]
)
);
}; };
VERSION_SUFFIX = versionSuffix; VERSION_SUFFIX = versionSuffix;
outputs = [ "out" ] outputs =
++ lib.optional doBuild "dev" [ "out" ]
# If we are doing just build or just docs, the one thing will use ++ lib.optional doBuild "dev"
# "out". We only need additional outputs if we are doing both. # If we are doing just build or just docs, the one thing will use
++ lib.optional (doBuild && enableManual) "doc" # "out". We only need additional outputs if we are doing both.
++ lib.optional installUnitTests "check" ++ lib.optional (doBuild && enableManual) "doc"
++ lib.optional doCheck "testresults" ++ lib.optional installUnitTests "check"
; ++ lib.optional doCheck "testresults";
nativeBuildInputs = [ nativeBuildInputs =
autoconf-archive [
autoreconfHook autoconf-archive
pkg-config autoreconfHook
] ++ lib.optionals doBuild [ pkg-config
bison ]
flex ++ lib.optionals doBuild [
] ++ lib.optionals enableManual [ bison
(lib.getBin lowdown) flex
mdbook ]
mdbook-linkcheck ++ lib.optionals enableManual [
] ++ lib.optionals doInstallCheck [ (lib.getBin lowdown)
git mdbook
mercurial mdbook-linkcheck
openssh ]
] ++ lib.optionals (doInstallCheck || enableManual) [ ++ lib.optionals doInstallCheck [
jq # Also for custom mdBook preprocessor. git
] ++ lib.optionals enableManual [ mercurial
man openssh
] ++ lib.optional stdenv.hostPlatform.isStatic unixtools.hexdump ]
; ++ lib.optionals (doInstallCheck || enableManual) [
jq # Also for custom mdBook preprocessor.
]
++ lib.optionals enableManual [
man
]
++ lib.optional stdenv.hostPlatform.isStatic unixtools.hexdump;
buildInputs = lib.optionals doBuild ( buildInputs = lib.optionals doBuild (
[ [
brotli brotli
bzip2 bzip2
curl curl
libarchive libarchive
libgit2 libgit2
libsodium libsodium
openssl openssl
sqlite sqlite
toml11 toml11
xz xz
({ inherit readline editline; }.${readlineFlavor}) ({ inherit readline editline; }.${readlineFlavor})
] ++ lib.optionals enableMarkdown [ ]
lowdown ++ lib.optionals enableMarkdown [
] ++ lib.optionals buildUnitTests [ lowdown
gtest ]
rapidcheck ++ lib.optionals buildUnitTests [
] ++ lib.optional stdenv.isLinux libseccomp gtest
++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.libs.sandbox rapidcheck
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid ]
# There have been issues building these dependencies ++ lib.optional stdenv.isLinux libseccomp
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin)) ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.libs.sandbox
aws-sdk-cpp ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
); # There have been issues building these dependencies
++ lib.optional (
stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin)
) aws-sdk-cpp
);
propagatedBuildInputs = lib.optionals doBuild ([ propagatedBuildInputs = lib.optionals doBuild (
boost [
nlohmann_json boost
] ++ lib.optional enableGC boehmgc nlohmann_json
); ]
++ lib.optional enableGC boehmgc
);
dontBuild = !attrs.doBuild; dontBuild = !attrs.doBuild;
doCheck = attrs.doCheck; doCheck = attrs.doCheck;
configureFlags = [ configureFlags =
(lib.enableFeature doBuild "build") [
(lib.enableFeature buildUnitTests "unit-tests") (lib.enableFeature doBuild "build")
(lib.enableFeature doInstallCheck "functional-tests") (lib.enableFeature buildUnitTests "unit-tests")
(lib.enableFeature enableManual "doc-gen") (lib.enableFeature doInstallCheck "functional-tests")
(lib.enableFeature enableGC "gc") (lib.enableFeature enableManual "doc-gen")
(lib.enableFeature enableMarkdown "markdown") (lib.enableFeature enableGC "gc")
(lib.enableFeature installUnitTests "install-unit-tests") (lib.enableFeature enableMarkdown "markdown")
(lib.withFeatureAs true "readline-flavor" readlineFlavor) (lib.enableFeature installUnitTests "install-unit-tests")
] ++ lib.optionals (!forDevShell) [ (lib.withFeatureAs true "readline-flavor" readlineFlavor)
"--sysconfdir=/etc" ]
] ++ lib.optionals installUnitTests [ ++ lib.optionals (!forDevShell) [
"--with-check-bin-dir=${builtins.placeholder "check"}/bin" "--sysconfdir=/etc"
"--with-check-lib-dir=${builtins.placeholder "check"}/lib" ]
] ++ lib.optionals (doBuild) [ ++ lib.optionals installUnitTests [
"--with-boost=${boost}/lib" "--with-check-bin-dir=${builtins.placeholder "check"}/bin"
] ++ lib.optionals (doBuild && stdenv.isLinux) [ "--with-check-lib-dir=${builtins.placeholder "check"}/lib"
"--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox" ]
] ++ lib.optional (doBuild && stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) ++ lib.optionals (doBuild) [
"LDFLAGS=-fuse-ld=gold" "--with-boost=${boost}/lib"
++ lib.optional (doBuild && stdenv.hostPlatform.isStatic) "--enable-embedded-sandbox-shell" ]
; ++ lib.optionals (doBuild && stdenv.isLinux) [
"--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
]
++ lib.optional (
doBuild && stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")
) "LDFLAGS=-fuse-ld=gold"
++ lib.optional (doBuild && stdenv.hostPlatform.isStatic) "--enable-embedded-sandbox-shell";
enableParallelBuilding = true; enableParallelBuilding = true;
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1"; makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";
preCheck = '' preCheck = ''
mkdir $testresults mkdir $testresults
'';
installTargets = lib.optional doBuild "install";
installFlags = "sysconfdir=$(out)/etc";
# In this case we are probably just running tests, and so there isn't
# anything to install, we just make an empty directory to signify tests
# succeeded.
installPhase = if finalAttrs.installTargets != [] then null else ''
mkdir -p $out
'';
postInstall = lib.optionalString doBuild (
lib.optionalString stdenv.hostPlatform.isStatic ''
mkdir -p $out/nix-support
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
''
) + lib.optionalString enableManual ''
mkdir -p ''${!outputDoc}/nix-support
echo "doc manual ''${!outputDoc}/share/doc/nix/manual" >> ''${!outputDoc}/nix-support/hydra-build-products
'';
# So the check output gets links for DLLs in the out output.
preFixup = lib.optionalString (stdenv.hostPlatform.isWindows && builtins.elem "check" finalAttrs.outputs) ''
ln -s "$check/lib/"*.dll "$check/bin"
ln -s "$out/bin/"*.dll "$check/bin"
'';
doInstallCheck = attrs.doInstallCheck;
installCheckFlags = "sysconfdir=$(out)/etc";
# Work around buggy detection in stdenv.
installCheckTarget = "installcheck";
# Work around weird bug where it doesn't think there is a Makefile.
installCheckPhase = if (!doBuild && doInstallCheck) then ''
runHook preInstallCheck
mkdir -p src/nix-channel
make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
'' else null;
# Needed for tests if we are not doing a build, but testing existing
# built Nix.
preInstallCheck =
lib.optionalString (! doBuild) ''
mkdir -p src/nix-channel
''
# See https://github.com/NixOS/nix/issues/2523
# Occurs often in tests since https://github.com/NixOS/nix/pull/9900
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
''; '';
separateDebugInfo = !stdenv.hostPlatform.isStatic; installTargets = lib.optional doBuild "install";
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564 installFlags = "sysconfdir=$(out)/etc";
strictDeps = !withCoverageChecks;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie"; # In this case we are probably just running tests, and so there isn't
# anything to install, we just make an empty directory to signify tests
# succeeded.
installPhase =
if finalAttrs.installTargets != [ ] then
null
else
''
mkdir -p $out
'';
meta = { postInstall =
platforms = lib.platforms.unix ++ lib.platforms.windows; lib.optionalString doBuild (
mainProgram = "nix"; lib.optionalString stdenv.hostPlatform.isStatic ''
broken = !(lib.all (a: a) [ mkdir -p $out/nix-support
# We cannot run or install unit tests if we don't build them or echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
# Nix proper (which they depend on). ''
(installUnitTests -> doBuild) )
(doCheck -> doBuild) + lib.optionalString enableManual ''
# The build process for the manual currently requires extracting mkdir -p ''${!outputDoc}/nix-support
# data from the Nix executable we are trying to document. echo "doc manual ''${!outputDoc}/share/doc/nix/manual" >> ''${!outputDoc}/nix-support/hydra-build-products
(enableManual -> doBuild) '';
]);
};
} // lib.optionalAttrs withCoverageChecks { # So the check output gets links for DLLs in the out output.
lcovFilter = [ "*/boost/*" "*-tab.*" ]; preFixup =
lib.optionalString (stdenv.hostPlatform.isWindows && builtins.elem "check" finalAttrs.outputs)
''
ln -s "$check/lib/"*.dll "$check/bin"
ln -s "$out/bin/"*.dll "$check/bin"
'';
hardeningDisable = ["fortify"]; doInstallCheck = attrs.doInstallCheck;
NIX_CFLAGS_COMPILE = "-DCOVERAGE=1"; installCheckFlags = "sysconfdir=$(out)/etc";
# Work around buggy detection in stdenv.
installCheckTarget = "installcheck";
dontInstall = false; # Work around weird bug where it doesn't think there is a Makefile.
} // lib.optionalAttrs (test-daemon != null) { installCheckPhase =
NIX_DAEMON_PACKAGE = test-daemon; if (!doBuild && doInstallCheck) then
} // lib.optionalAttrs (test-client != null) { ''
NIX_CLIENT_PACKAGE = test-client; runHook preInstallCheck
}) mkdir -p src/nix-channel
make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
''
else
null;
# Needed for tests if we are not doing a build, but testing existing
# built Nix.
preInstallCheck =
lib.optionalString (!doBuild) ''
mkdir -p src/nix-channel
''
# See https://github.com/NixOS/nix/issues/2523
# Occurs often in tests since https://github.com/NixOS/nix/pull/9900
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
'';
separateDebugInfo = !stdenv.hostPlatform.isStatic;
# TODO Always true after https://github.com/NixOS/nixpkgs/issues/318564
strictDeps = !withCoverageChecks;
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
mainProgram = "nix";
broken =
!(lib.all (a: a) [
# We cannot run or install unit tests if we don't build them or
# Nix proper (which they depend on).
(installUnitTests -> doBuild)
(doCheck -> doBuild)
# The build process for the manual currently requires extracting
# data from the Nix executable we are trying to document.
(enableManual -> doBuild)
]);
};
}
// lib.optionalAttrs withCoverageChecks {
lcovFilter = [
"*/boost/*"
"*-tab.*"
];
hardeningDisable = [ "fortify" ];
NIX_CFLAGS_COMPILE = "-DCOVERAGE=1";
dontInstall = false;
}
// lib.optionalAttrs (test-daemon != null) {
NIX_DAEMON_PACKAGE = test-daemon;
}
// lib.optionalAttrs (test-client != null) {
NIX_CLIENT_PACKAGE = test-client;
}
)

View file

@ -20,9 +20,7 @@ let
root = ../.; root = ../.;
stdenv = if prevStdenv.isDarwin && prevStdenv.isx86_64 stdenv = if prevStdenv.isDarwin && prevStdenv.isx86_64 then darwinStdenv else prevStdenv;
then darwinStdenv
else prevStdenv;
# Fix the following error with the default x86_64-darwin SDK: # Fix the following error with the default x86_64-darwin SDK:
# #
@ -39,7 +37,8 @@ let
# Indirection for Nixpkgs to override when package.nix files are vendored # Indirection for Nixpkgs to override when package.nix files are vendored
filesetToSource = lib.fileset.toSource; filesetToSource = lib.fileset.toSource;
localSourceLayer = finalAttrs: prevAttrs: localSourceLayer =
finalAttrs: prevAttrs:
let let
workDirPath = workDirPath =
# Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has # Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has
@ -48,8 +47,13 @@ let
prevAttrs.workDir; prevAttrs.workDir;
workDirSubpath = lib.path.removePrefix root workDirPath; workDirSubpath = lib.path.removePrefix root workDirPath;
sources = assert prevAttrs.fileset._type == "fileset"; prevAttrs.fileset; sources =
src = lib.fileset.toSource { fileset = sources; inherit root; }; assert prevAttrs.fileset._type == "fileset";
prevAttrs.fileset;
src = lib.fileset.toSource {
fileset = sources;
inherit root;
};
in in
{ {
@ -63,30 +67,35 @@ let
# Work around weird `--as-needed` linker behavior with BSD, see # Work around weird `--as-needed` linker behavior with BSD, see
# https://github.com/mesonbuild/meson/issues/3593 # https://github.com/mesonbuild/meson/issues/3593
bsdNoLinkAsNeeded = finalAttrs: prevAttrs: bsdNoLinkAsNeeded =
finalAttrs: prevAttrs:
lib.optionalAttrs stdenv.hostPlatform.isBSD { lib.optionalAttrs stdenv.hostPlatform.isBSD {
mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or []; mesonFlags = [ (lib.mesonBool "b_asneeded" false) ] ++ prevAttrs.mesonFlags or [ ];
}; };
miscGoodPractice = finalAttrs: prevAttrs: miscGoodPractice = finalAttrs: prevAttrs: {
{ strictDeps = prevAttrs.strictDeps or true;
strictDeps = prevAttrs.strictDeps or true; enableParallelBuilding = true;
enableParallelBuilding = true; };
};
in in
scope: { scope: {
inherit stdenv versionSuffix; inherit stdenv versionSuffix;
version = lib.fileContents ../.version + versionSuffix; version = lib.fileContents ../.version + versionSuffix;
aws-sdk-cpp = (pkgs.aws-sdk-cpp.override { aws-sdk-cpp =
apis = [ "s3" "transfer" ]; (pkgs.aws-sdk-cpp.override {
customMemoryManagement = false; apis = [
}).overrideAttrs { "s3"
# only a stripped down version is built, which takes a lot less resources "transfer"
# to build, so we don't need a "big-parallel" machine. ];
requiredSystemFeatures = [ ]; customMemoryManagement = false;
}; }).overrideAttrs
{
# only a stripped down version is built, which takes a lot less resources
# to build, so we don't need a "big-parallel" machine.
requiredSystemFeatures = [ ];
};
libseccomp = pkgs.libseccomp.overrideAttrs (_: rec { libseccomp = pkgs.libseccomp.overrideAttrs (_: rec {
version = "2.5.5"; version = "2.5.5";
@ -101,48 +110,50 @@ scope: {
}; };
# TODO Hack until https://github.com/NixOS/nixpkgs/issues/45462 is fixed. # TODO Hack until https://github.com/NixOS/nixpkgs/issues/45462 is fixed.
boost = (pkgs.boost.override { boost =
extraB2Args = [ (pkgs.boost.override {
"--with-container" extraB2Args = [
"--with-context" "--with-container"
"--with-coroutine" "--with-context"
]; "--with-coroutine"
}).overrideAttrs (old: { ];
# Need to remove `--with-*` to use `--with-libraries=...` }).overrideAttrs
buildPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.buildPhase; (old: {
installPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.installPhase; # Need to remove `--with-*` to use `--with-libraries=...`
}); buildPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.buildPhase;
installPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.installPhase;
});
libgit2 = pkgs.libgit2.overrideAttrs (attrs: { libgit2 = pkgs.libgit2.overrideAttrs (attrs: {
src = inputs.libgit2; src = inputs.libgit2;
version = inputs.libgit2.lastModifiedDate; version = inputs.libgit2.lastModifiedDate;
cmakeFlags = attrs.cmakeFlags or [] cmakeFlags = attrs.cmakeFlags or [ ] ++ [ "-DUSE_SSH=exec" ];
++ [ "-DUSE_SSH=exec" ];
}); });
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or (pkgs.busybox.override { busybox-sandbox-shell =
useMusl = true; pkgs.busybox-sandbox-shell or (pkgs.busybox.override {
enableStatic = true; useMusl = true;
enableMinimal = true; enableStatic = true;
extraConfig = '' enableMinimal = true;
CONFIG_FEATURE_FANCY_ECHO y extraConfig = ''
CONFIG_FEATURE_SH_MATH y CONFIG_FEATURE_FANCY_ECHO y
CONFIG_FEATURE_SH_MATH_64 y CONFIG_FEATURE_SH_MATH y
CONFIG_FEATURE_SH_MATH_64 y
CONFIG_ASH y CONFIG_ASH y
CONFIG_ASH_OPTIMIZE_FOR_SIZE y CONFIG_ASH_OPTIMIZE_FOR_SIZE y
CONFIG_ASH_ALIAS y CONFIG_ASH_ALIAS y
CONFIG_ASH_BASH_COMPAT y CONFIG_ASH_BASH_COMPAT y
CONFIG_ASH_CMDCMD y CONFIG_ASH_CMDCMD y
CONFIG_ASH_ECHO y CONFIG_ASH_ECHO y
CONFIG_ASH_GETOPTS y CONFIG_ASH_GETOPTS y
CONFIG_ASH_INTERNAL_GLOB y CONFIG_ASH_INTERNAL_GLOB y
CONFIG_ASH_JOB_CONTROL y CONFIG_ASH_JOB_CONTROL y
CONFIG_ASH_PRINTF y CONFIG_ASH_PRINTF y
CONFIG_ASH_TEST y CONFIG_ASH_TEST y
''; '';
}); });
# TODO change in Nixpkgs, Windows works fine. First commit of # TODO change in Nixpkgs, Windows works fine. First commit of
# https://github.com/NixOS/nixpkgs/pull/322977 backported will fix. # https://github.com/NixOS/nixpkgs/pull/322977 backported will fix.
@ -152,14 +163,14 @@ scope: {
inherit resolvePath filesetToSource; inherit resolvePath filesetToSource;
mkMesonDerivation = f: let mkMesonDerivation =
exts = [ f:
miscGoodPractice let
bsdNoLinkAsNeeded exts = [
localSourceLayer miscGoodPractice
]; bsdNoLinkAsNeeded
in stdenv.mkDerivation localSourceLayer
(lib.extends ];
(lib.foldr lib.composeExtensions (_: _: {}) exts) in
f); stdenv.mkDerivation (lib.extends (lib.foldr lib.composeExtensions (_: _: { }) exts) f);
} }

View file

@ -1,28 +1,31 @@
{ inputs {
, binaryTarball inputs,
, forAllCrossSystems binaryTarball,
, forAllSystems forAllCrossSystems,
, lib forAllSystems,
, linux64BitSystems lib,
, nixpkgsFor linux64BitSystems,
, self nixpkgsFor,
self,
}: }:
let 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 ../scripts/installer.nix {
inherit tarballs; inherit tarballs;
}; };
testNixVersions = pkgs: client: daemon: testNixVersions =
pkgs: client: daemon:
pkgs.callPackage ../package.nix { pkgs.callPackage ../package.nix {
pname = pname =
"nix-tests" "nix-tests"
+ lib.optionalString + lib.optionalString (
(lib.versionAtLeast daemon.version "2.4pre20211005" && lib.versionAtLeast daemon.version "2.4pre20211005"
lib.versionAtLeast client.version "2.4pre20211005") && lib.versionAtLeast client.version "2.4pre20211005"
"-${client.version}-against-${daemon.version}"; ) "-${client.version}-against-${daemon.version}";
test-client = client; test-client = client;
test-daemon = daemon; test-daemon = daemon;
@ -59,27 +62,35 @@ let
in in
{ {
# Binary package for various platforms. # Binary package for various platforms.
build = forAllPackages (pkgName: build = forAllPackages (
forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.${pkgName})); pkgName: forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.${pkgName})
);
shellInputs = forAllSystems (system: self.devShells.${system}.default.inputDerivation); shellInputs = forAllSystems (system: self.devShells.${system}.default.inputDerivation);
buildStatic = forAllPackages (pkgName: buildStatic = forAllPackages (
lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.static.nixComponents.${pkgName})); pkgName:
lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.static.nixComponents.${pkgName})
buildCross = forAllPackages (pkgName:
forAllCrossSystems (crossSystem:
lib.genAttrs [ "x86_64-linux" ] (system: nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName})));
buildNoGc = forAllSystems (system:
self.packages.${system}.nix.override { enableGC = false; }
); );
buildCross = forAllPackages (
pkgName:
forAllCrossSystems (
crossSystem:
lib.genAttrs [ "x86_64-linux" ] (
system: nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName}
)
)
);
buildNoGc = forAllSystems (system: self.packages.${system}.nix.override { enableGC = false; });
buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nix_noTests); buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nix_noTests);
# Toggles some settings for better coverage. Windows needs these # Toggles some settings for better coverage. Windows needs these
# library combinations, and Debian build Nix with GNU readline too. # library combinations, and Debian build Nix with GNU readline too.
buildReadlineNoMarkdown = forAllSystems (system: buildReadlineNoMarkdown = forAllSystems (
system:
self.packages.${system}.nix.override { self.packages.${system}.nix.override {
enableMarkdown = false; enableMarkdown = false;
readlineFlavor = "readline"; readlineFlavor = "readline";
@ -92,13 +103,18 @@ 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: binaryTarball nixpkgsFor.${system}.native.nix nixpkgsFor.${system}.native
);
binaryTarballCross = lib.genAttrs [ "x86_64-linux" ] (system: binaryTarballCross = lib.genAttrs [ "x86_64-linux" ] (
forAllCrossSystems (crossSystem: system:
binaryTarball forAllCrossSystems (
nixpkgsFor.${system}.cross.${crossSystem}.nix crossSystem:
nixpkgsFor.${system}.cross.${crossSystem})); binaryTarball 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
@ -117,9 +133,12 @@ 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 (
tarballs = [ self.hydraJobs.binaryTarball.${system} ]; system:
}); nixpkgsFor.${system}.native.callPackage ../scripts/installer.nix {
tarballs = [ self.hydraJobs.binaryTarball.${system} ];
}
);
# docker image with Nix inside # docker image with Nix inside
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage); dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
@ -137,16 +156,24 @@ 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
self
;
}
// {
# 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.
evalNixpkgs = evalNixpkgs =
let let
inherit (nixpkgsFor.x86_64-linux.native) runCommand nix; inherit (nixpkgsFor.x86_64-linux.native) runCommand nix;
in in
runCommand "eval-nixos" { buildInputs = [ nix ]; } runCommand "eval-nixos" { buildInputs = [ nix ]; } ''
''
type -p nix-env type -p nix-env
# Note: we're filtering out nixos-install-tools because https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1020530593. # Note: we're filtering out nixos-install-tools because https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1020530593.
( (
@ -157,36 +184,36 @@ in
mkdir $out mkdir $out
''; '';
nixpkgsLibTests = nixpkgsLibTests = forAllSystems (
forAllSystems (system: system:
import (nixpkgs + "/lib/tests/test-with-nix.nix") import (nixpkgs + "/lib/tests/test-with-nix.nix") {
{ lib = nixpkgsFor.${system}.native.lib;
lib = nixpkgsFor.${system}.native.lib; nix = self.packages.${system}.nix;
nix = self.packages.${system}.nix; pkgs = nixpkgsFor.${system}.native;
pkgs = nixpkgsFor.${system}.native; }
}
); );
}; };
metrics.nixpkgs = import "${nixpkgs-regression}/pkgs/top-level/metrics.nix" { metrics.nixpkgs = import "${nixpkgs-regression}/pkgs/top-level/metrics.nix" {
pkgs = nixpkgsFor.x86_64-linux.native; pkgs = nixpkgsFor.x86_64-linux.native;
nixpkgs = nixpkgs-regression; nixpkgs = nixpkgs-regression;
}; };
installTests = forAllSystems (system: installTests = forAllSystems (
let pkgs = nixpkgsFor.${system}.native; in system:
pkgs.runCommand "install-tests" let
{ pkgs = nixpkgsFor.${system}.native;
againstSelf = testNixVersions pkgs pkgs.nix pkgs.pkgs.nix; in
againstCurrentLatest = pkgs.runCommand "install-tests" {
# FIXME: temporarily disable this on macOS because of #3605. againstSelf = testNixVersions pkgs pkgs.nix pkgs.pkgs.nix;
if system == "x86_64-linux" againstCurrentLatest =
then testNixVersions pkgs pkgs.nix pkgs.nixVersions.latest # FIXME: temporarily disable this on macOS because of #3605.
else null; if system == "x86_64-linux" then testNixVersions pkgs pkgs.nix pkgs.nixVersions.latest else null;
# Disabled because the latest stable version doesn't handle # Disabled because the latest stable version doesn't handle
# `NIX_DAEMON_SOCKET_PATH` which is required for the tests to work # `NIX_DAEMON_SOCKET_PATH` which is required for the tests to work
# againstLatestStable = testNixVersions pkgs pkgs.nix pkgs.nixStable; # againstLatestStable = testNixVersions pkgs pkgs.nix pkgs.nixStable;
} "touch $out"); } "touch $out"
);
installerTests = import ../tests/installer { installerTests = import ../tests/installer {
binaryTarballs = self.hydraJobs.binaryTarball; binaryTarballs = self.hydraJobs.binaryTarball;

View file

@ -1,14 +1,18 @@
{ runCommand {
, system runCommand,
, buildPackages system,
, cacert buildPackages,
, nix cacert,
nix,
}: }:
let let
installerClosureInfo = buildPackages.closureInfo { installerClosureInfo = buildPackages.closureInfo {
rootPaths = [ nix cacert ]; rootPaths = [
nix
cacert
];
}; };
inherit (nix) version; inherit (nix) version;

View file

@ -1,36 +1,42 @@
{ lib {
, runCommand lib,
, nix runCommand,
, tarballs nix,
tarballs,
}: }:
runCommand "installer-script" { runCommand "installer-script"
buildInputs = [ nix ]; {
} '' buildInputs = [ nix ];
mkdir -p $out/nix-support
# Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
tarballPath() {
# Remove the store prefix
local path=''${1#${builtins.storeDir}/}
# Get the path relative to the derivation root
local rest=''${path#*/}
# Get the derivation hash
local drvHash=''${path%%-*}
echo "$drvHash/$rest"
} }
''
mkdir -p $out/nix-support
substitute ${./install.in} $out/install \ # Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
${lib.concatMapStrings tarballPath() {
(tarball: let # Remove the store prefix
inherit (tarball.stdenv.hostPlatform) system; local path=''${1#${builtins.storeDir}/}
in '' \ # Get the path relative to the derivation root
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \ local rest=''${path#*/}
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \ # Get the derivation hash
'' local drvHash=''${path%%-*}
) echo "$drvHash/$rest"
tarballs }
} --replace '@nixVersion@' ${nix.version}
echo "file installer $out/install" >> $out/nix-support/hydra-build-products substitute ${./install.in} $out/install \
'' ${
lib.concatMapStrings (
tarball:
let
inherit (tarball.stdenv.hostPlatform) system;
in
''
\
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \
''
) tarballs
} --replace '@nixVersion@' ${nix.version}
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
''

View file

@ -1,13 +1,14 @@
{ lib {
, mkMesonDerivation lib,
mkMesonDerivation,
, meson meson,
, ninja ninja,
, doxygen doxygen,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -42,11 +43,10 @@ mkMesonDerivation (finalAttrs: {
doxygen doxygen
]; ];
preConfigure = preConfigure = ''
'' chmod u+w ./.version
chmod u+w ./.version echo ${finalAttrs.version} > ./.version
echo ${finalAttrs.version} > ./.version '';
'';
postInstall = '' postInstall = ''
mkdir -p ''${!outputDoc}/nix-support mkdir -p ''${!outputDoc}/nix-support

View file

@ -1,13 +1,14 @@
{ lib {
, mkMesonDerivation lib,
mkMesonDerivation,
, meson meson,
, ninja ninja,
, doxygen doxygen,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -19,17 +20,19 @@ mkMesonDerivation (finalAttrs: {
inherit version; inherit version;
workDir = ./.; workDir = ./.;
fileset = let fileset =
cpp = fileset.fileFilter (file: file.hasExt "cc" || file.hasExt "hh"); let
in fileset.unions [ cpp = fileset.fileFilter (file: file.hasExt "cc" || file.hasExt "hh");
./.version in
../../.version fileset.unions [
./meson.build ./.version
./doxygen.cfg.in ../../.version
# Source is not compiled, but still must be available for Doxygen ./meson.build
# to gather comments. ./doxygen.cfg.in
(cpp ../.) # Source is not compiled, but still must be available for Doxygen
]; # to gather comments.
(cpp ../.)
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -37,11 +40,10 @@ mkMesonDerivation (finalAttrs: {
doxygen doxygen
]; ];
preConfigure = preConfigure = ''
'' chmod u+w ./.version
chmod u+w ./.version echo ${finalAttrs.version} > ./.version
echo ${finalAttrs.version} > ./.version '';
'';
postInstall = '' postInstall = ''
mkdir -p ''${!outputDoc}/nix-support mkdir -p ''${!outputDoc}/nix-support

View file

@ -1,37 +1,38 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util nix-util,
, nix-store nix-store,
, nix-fetchers nix-fetchers,
, nix-expr nix-expr,
, nix-flake nix-flake,
, nix-main nix-main,
, editline editline,
, readline readline,
, lowdown lowdown,
, nlohmann_json nlohmann_json,
# Configuration Options # Configuration Options
, version version,
# Whether to enable Markdown rendering in the Nix binary. # Whether to enable Markdown rendering in the Nix binary.
, enableMarkdown ? !stdenv.hostPlatform.isWindows enableMarkdown ? !stdenv.hostPlatform.isWindows,
# Which interactive line editor library to use for Nix's repl. # Which interactive line editor library to use for Nix's repl.
# #
# Currently supported choices are: # Currently supported choices are:
# #
# - editline (default) # - editline (default)
# - readline # - readline
, readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline" readlineFlavor ? if stdenv.hostPlatform.isWindows then "readline" else "editline",
}: }:
let let
@ -54,7 +55,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -89,9 +93,12 @@ mkMesonDerivation (finalAttrs: {
(lib.mesonOption "readline-flavor" readlineFlavor) (lib.mesonOption "readline-flavor" readlineFlavor)
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,17 +1,18 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
mkMesonDerivation,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-store-c nix-store-c,
, nix-expr nix-expr,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -35,7 +36,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.) (fileset.fileFilter (file: file.hasExt "h") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -59,9 +63,12 @@ mkMesonDerivation (finalAttrs: {
mesonFlags = [ mesonFlags = [
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -17,69 +17,69 @@ let
# Resolve a input spec into a node name. An input spec is # Resolve a input spec into a node name. An input spec is
# either a node name, or a 'follows' path from the root # either a node name, or a 'follows' path from the root
# node. # node.
resolveInput = inputSpec: resolveInput =
if builtins.isList inputSpec inputSpec: if builtins.isList inputSpec then getInputByPath lockFile.root inputSpec else inputSpec;
then getInputByPath lockFile.root inputSpec
else inputSpec;
# Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the
# root node, returning the final node. # root node, returning the final node.
getInputByPath = nodeName: path: getInputByPath =
if path == [] nodeName: path:
then nodeName if path == [ ] then
nodeName
else else
getInputByPath getInputByPath
# Since this could be a 'follows' input, call resolveInput. # Since this could be a 'follows' input, call resolveInput.
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path}) (resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
(builtins.tail path); (builtins.tail path);
allNodes = allNodes = builtins.mapAttrs (
builtins.mapAttrs key: node:
(key: node: let
let
sourceInfo = sourceInfo =
if overrides ? ${key} if overrides ? ${key} then
then overrides.${key}.sourceInfo
overrides.${key}.sourceInfo else
else # FIXME: remove obsolete node.info.
# FIXME: remove obsolete node.info. fetchTree (node.info or { } // removeAttrs node.locked [ "dir" ]);
fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
subdir = overrides.${key}.dir or node.locked.dir or ""; subdir = overrides.${key}.dir or node.locked.dir or "";
outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir); outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
flake = import (outPath + "/flake.nix"); flake = import (outPath + "/flake.nix");
inputs = builtins.mapAttrs inputs = builtins.mapAttrs (inputName: inputSpec: allNodes.${resolveInput inputSpec}) (
(inputName: inputSpec: allNodes.${resolveInput inputSpec}) node.inputs or { }
(node.inputs or {}); );
outputs = flake.outputs (inputs // { self = result; }); outputs = flake.outputs (inputs // { self = result; });
result = result =
outputs outputs
# We add the sourceInfo attribute for its metadata, as they are # We add the sourceInfo attribute for its metadata, as they are
# relevant metadata for the flake. However, the outPath of the # relevant metadata for the flake. However, the outPath of the
# sourceInfo does not necessarily match the outPath of the flake, # sourceInfo does not necessarily match the outPath of the flake,
# as the flake may be in a subdirectory of a source. # as the flake may be in a subdirectory of a source.
# This is shadowed in the next // # This is shadowed in the next //
// sourceInfo // sourceInfo
// { // {
# This shadows the sourceInfo.outPath # This shadows the sourceInfo.outPath
inherit outPath; inherit outPath;
inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake"; inherit inputs;
}; inherit outputs;
inherit sourceInfo;
_type = "flake";
};
in in
if node.flake or true then if node.flake or true then
assert builtins.isFunction flake.outputs; assert builtins.isFunction flake.outputs;
result result
else else
sourceInfo sourceInfo
) ) lockFile.nodes;
lockFile.nodes;
in allNodes.${lockFile.root} in
allNodes.${lockFile.root}

View file

@ -1,40 +1,72 @@
{ system ? "" # obsolete {
, url system ? "", # obsolete
, hash ? "" # an SRI hash url,
hash ? "", # an SRI hash
# Legacy hash specification # Legacy hash specification
, md5 ? "", sha1 ? "", sha256 ? "", sha512 ? "" md5 ? "",
, outputHash ? sha1 ? "",
if hash != "" then hash else if sha512 != "" then sha512 else if sha1 != "" then sha1 else if md5 != "" then md5 else sha256 sha256 ? "",
, outputHashAlgo ? sha512 ? "",
if hash != "" then "" else if sha512 != "" then "sha512" else if sha1 != "" then "sha1" else if md5 != "" then "md5" else "sha256" outputHash ?
if hash != "" then
hash
else if sha512 != "" then
sha512
else if sha1 != "" then
sha1
else if md5 != "" then
md5
else
sha256,
outputHashAlgo ?
if hash != "" then
""
else if sha512 != "" then
"sha512"
else if sha1 != "" then
"sha1"
else if md5 != "" then
"md5"
else
"sha256",
, executable ? false executable ? false,
, unpack ? false unpack ? false,
, name ? baseNameOf (toString url) name ? baseNameOf (toString url),
, impure ? false impure ? false,
}: }:
derivation ({ derivation (
builder = "builtin:fetchurl"; {
builder = "builtin:fetchurl";
# New-style output content requirements. # New-style output content requirements.
outputHashMode = if unpack || executable then "recursive" else "flat"; outputHashMode = if unpack || executable then "recursive" else "flat";
inherit name url executable unpack; inherit
name
url
executable
unpack
;
system = "builtin"; system = "builtin";
# No need to double the amount of network traffic # No need to double the amount of network traffic
preferLocalBuild = true; preferLocalBuild = true;
# This attribute does nothing; it's here to avoid changing evaluation results. # This attribute does nothing; it's here to avoid changing evaluation results.
impureEnvVars = [ impureEnvVars = [
"http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" "http_proxy"
]; "https_proxy"
"ftp_proxy"
"all_proxy"
"no_proxy"
];
# To make "nix-prefetch-url" work. # To make "nix-prefetch-url" work.
urls = [ url ]; urls = [ url ];
} // (if impure }
then { __impure = true; } // (if impure then { __impure = true; } else { inherit outputHashAlgo outputHash; })
else { inherit outputHashAlgo outputHash; })) )

View file

@ -1,21 +1,27 @@
attrs @ { drvPath, outputs, name, ... }: attrs@{
drvPath,
outputs,
name,
...
}:
let let
commonAttrs = (builtins.listToAttrs outputsList) // commonAttrs = (builtins.listToAttrs outputsList) // {
{ all = map (x: x.value) outputsList; all = map (x: x.value) outputsList;
inherit drvPath name; inherit drvPath name;
type = "derivation"; type = "derivation";
}; };
outputToAttrListElement = outputName: outputToAttrListElement = outputName: {
{ name = outputName; name = outputName;
value = commonAttrs // { value = commonAttrs // {
outPath = builtins.getAttr outputName attrs; outPath = builtins.getAttr outputName attrs;
inherit outputName; inherit outputName;
};
}; };
};
outputsList = map outputToAttrListElement outputs; outputsList = map outputToAttrListElement outputs;
in (builtins.head outputsList).value in
(builtins.head outputsList).value

View file

@ -1,37 +1,38 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, bison bison,
, flex flex,
, cmake # for resolving toml11 dep cmake, # for resolving toml11 dep
, nix-util nix-util,
, nix-store nix-store,
, nix-fetchers nix-fetchers,
, boost boost,
, boehmgc boehmgc,
, nlohmann_json nlohmann_json,
, toml11 toml11,
# Configuration Options # Configuration Options
, version version,
# Whether to use garbage collection for the Nix language evaluator. # Whether to use garbage collection for the Nix language evaluator.
# #
# If it is disabled, we just leak memory, but this is not as bad as it # If it is disabled, we just leak memory, but this is not as bad as it
# sounds so long as evaluation just takes places within short-lived # sounds so long as evaluation just takes places within short-lived
# processes. (When the process exits, the memory is reclaimed; it is # processes. (When the process exits, the memory is reclaimed; it is
# only leaked *within* the process.) # only leaked *within* the process.)
# #
# Temporarily disabled on Windows because the `GC_throw_bad_alloc` # Temporarily disabled on Windows because the `GC_throw_bad_alloc`
# symbol is missing during linking. # symbol is missing during linking.
, enableGC ? !stdenv.hostPlatform.isWindows enableGC ? !stdenv.hostPlatform.isWindows,
}: }:
let let
@ -58,7 +59,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "nix") ./.) (fileset.fileFilter (file: file.hasExt "nix") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -93,14 +97,18 @@ mkMesonDerivation (finalAttrs: {
(lib.mesonEnable "gc" enableGC) (lib.mesonEnable "gc" enableGC)
]; ];
env = { env =
# Needed for Meson to find Boost. {
# https://github.com/NixOS/nixpkgs/issues/86131. # Needed for Meson to find Boost.
BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; # https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
} // lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
LDFLAGS = "-fuse-ld=gold"; }
}; // lib.optionalAttrs
(stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -26,27 +26,34 @@
Note that `derivation` is very bare-bones, and provides almost no commands during the build. Note that `derivation` is very bare-bones, and provides almost no commands during the build.
Most likely, you'll want to use functions like `stdenv.mkDerivation` in Nixpkgs to set up a basic environment. Most likely, you'll want to use functions like `stdenv.mkDerivation` in Nixpkgs to set up a basic environment.
*/ */
drvAttrs @ { outputs ? [ "out" ], ... }: drvAttrs@{
outputs ? [ "out" ],
...
}:
let let
strict = derivationStrict drvAttrs; strict = derivationStrict drvAttrs;
commonAttrs = drvAttrs // (builtins.listToAttrs outputsList) // commonAttrs =
{ all = map (x: x.value) outputsList; drvAttrs
// (builtins.listToAttrs outputsList)
// {
all = map (x: x.value) outputsList;
inherit drvAttrs; inherit drvAttrs;
}; };
outputToAttrListElement = outputName: outputToAttrListElement = outputName: {
{ name = outputName; name = outputName;
value = commonAttrs // { value = commonAttrs // {
outPath = builtins.getAttr outputName strict; outPath = builtins.getAttr outputName strict;
drvPath = strict.drvPath; drvPath = strict.drvPath;
type = "derivation"; type = "derivation";
inherit outputName; inherit outputName;
};
}; };
};
outputsList = map outputToAttrListElement outputs; outputsList = map outputToAttrListElement outputs;
in (builtins.head outputsList).value in
(builtins.head outputsList).value

View file

@ -1,21 +1,22 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util nix-util,
, nix-store nix-store,
, nlohmann_json nlohmann_json,
, libgit2 libgit2,
, man man,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -37,7 +38,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -63,9 +67,12 @@ mkMesonDerivation (finalAttrs: {
echo ${version} > ../../.version echo ${version} > ../../.version
''; '';
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,23 +1,24 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util nix-util,
, nix-store nix-store,
, nix-fetchers nix-fetchers,
, nix-expr nix-expr,
, nlohmann_json nlohmann_json,
, libgit2 libgit2,
, man man,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -39,7 +40,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -63,9 +67,12 @@ mkMesonDerivation (finalAttrs: {
echo ${version} > ../../.version echo ${version} > ../../.version
''; '';
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,20 +1,21 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util-c nix-util-c,
, nix-store nix-store,
, nix-store-c nix-store-c,
, nix-main nix-main,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -38,7 +39,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.) (fileset.fileFilter (file: file.hasExt "h") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -64,9 +68,12 @@ mkMesonDerivation (finalAttrs: {
mesonFlags = [ mesonFlags = [
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,20 +1,21 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, openssl openssl,
, nix-util nix-util,
, nix-store nix-store,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -36,7 +37,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -58,9 +62,12 @@ mkMesonDerivation (finalAttrs: {
echo ${version} > ../../.version echo ${version} > ../../.version
''; '';
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,18 +1,19 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util-c nix-util-c,
, nix-store nix-store,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -36,7 +37,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.) (fileset.fileFilter (file: file.hasExt "h") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -60,9 +64,12 @@ mkMesonDerivation (finalAttrs: {
mesonFlags = [ mesonFlags = [
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,29 +1,30 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, unixtools unixtools,
, darwin darwin,
, nix-util nix-util,
, boost boost,
, curl curl,
, aws-sdk-cpp aws-sdk-cpp,
, libseccomp libseccomp,
, nlohmann_json nlohmann_json,
, sqlite sqlite,
, busybox-sandbox-shell ? null busybox-sandbox-shell ? null,
# Configuration Options # Configuration Options
, version version,
, embeddedSandboxShell ? stdenv.hostPlatform.isStatic embeddedSandboxShell ? stdenv.hostPlatform.isStatic,
}: }:
let let
@ -52,7 +53,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "sql") ./.) (fileset.fileFilter (file: file.hasExt "sql") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -60,16 +64,18 @@ mkMesonDerivation (finalAttrs: {
pkg-config pkg-config
] ++ lib.optional embeddedSandboxShell unixtools.hexdump; ] ++ lib.optional embeddedSandboxShell unixtools.hexdump;
buildInputs = [ buildInputs =
boost [
curl boost
sqlite curl
] ++ lib.optional stdenv.hostPlatform.isLinux libseccomp sqlite
]
++ lib.optional stdenv.hostPlatform.isLinux libseccomp
# There have been issues building these dependencies # There have been issues building these dependencies
++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.libs.sandbox ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.libs.sandbox
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin)) ++ lib.optional (
aws-sdk-cpp stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin)
; ) aws-sdk-cpp;
propagatedBuildInputs = [ propagatedBuildInputs = [
nix-util nix-util
@ -84,21 +90,27 @@ mkMesonDerivation (finalAttrs: {
echo ${version} > ../../.version echo ${version} > ../../.version
''; '';
mesonFlags = [ mesonFlags =
(lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux) [
(lib.mesonBool "embedded-sandbox-shell" embeddedSandboxShell) (lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux)
] ++ lib.optionals stdenv.hostPlatform.isLinux [ (lib.mesonBool "embedded-sandbox-shell" embeddedSandboxShell)
(lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox") ]
]; ++ lib.optionals stdenv.hostPlatform.isLinux [
(lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox")
];
env = { env =
# Needed for Meson to find Boost. {
# https://github.com/NixOS/nixpkgs/issues/86131. # Needed for Meson to find Boost.
BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; # https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
} // lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
LDFLAGS = "-fuse-ld=gold"; }
}; // lib.optionalAttrs
(stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,17 +1,18 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-util nix-util,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -35,7 +36,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "h") ./.) (fileset.fileFilter (file: file.hasExt "h") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -58,9 +62,12 @@ mkMesonDerivation (finalAttrs: {
mesonFlags = [ mesonFlags = [
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,23 +1,24 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, boost boost,
, brotli brotli,
, libarchive libarchive,
, libcpuid libcpuid,
, libsodium libsodium,
, nlohmann_json nlohmann_json,
, openssl openssl,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -43,7 +44,10 @@ mkMesonDerivation (finalAttrs: {
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
outputs = [ "out" "dev" ]; outputs = [
"out"
"dev"
];
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
@ -55,8 +59,7 @@ mkMesonDerivation (finalAttrs: {
brotli brotli
libsodium libsodium
openssl openssl
] ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid ] ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid;
;
propagatedBuildInputs = [ propagatedBuildInputs = [
boost boost
@ -79,14 +82,18 @@ mkMesonDerivation (finalAttrs: {
(lib.mesonEnable "cpuid" stdenv.hostPlatform.isx86_64) (lib.mesonEnable "cpuid" stdenv.hostPlatform.isx86_64)
]; ];
env = { env =
# Needed for Meson to find Boost. {
# https://github.com/NixOS/nixpkgs/issues/86131. # Needed for Meson to find Boost.
BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; # https://github.com/NixOS/nixpkgs/issues/86131.
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
} // lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
LDFLAGS = "-fuse-ld=gold"; }
}; // lib.optionalAttrs
(stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,4 +1,8 @@
{ name, channelName, src }: {
name,
channelName,
src,
}:
derivation { derivation {
builder = "builtin:unpack-channel"; builder = "builtin:unpack-channel";

View file

@ -8,13 +8,15 @@ derivation {
inherit manifest; inherit manifest;
# !!! grmbl, need structured data for passing this in a clean way. # !!! grmbl, need structured data for passing this in a clean way.
derivations = derivations = map (
map (d: d:
[ (d.meta.active or "true") [
(d.meta.priority or 5) (d.meta.active or "true")
(builtins.length d.outputs) (d.meta.priority or 5)
] ++ map (output: builtins.getAttr output d) d.outputs) (builtins.length d.outputs)
derivations; ]
++ map (output: builtins.getAttr output d) d.outputs
) derivations;
# Building user environments remotely just causes huge amounts of # Building user environments remotely just causes huge amounts of
# network traffic, so don't do that. # network traffic, so don't do that.

View file

@ -1,24 +1,25 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, releaseTools mkMesonDerivation,
releaseTools,
, meson meson,
, ninja ninja,
, pkg-config pkg-config,
, nix-store nix-store,
, nix-expr nix-expr,
, nix-main nix-main,
, nix-cmd nix-cmd,
, rapidcheck rapidcheck,
, gtest gtest,
, runCommand runCommand,
# Configuration Options # Configuration Options
, version version,
}: }:
let let
@ -30,58 +31,61 @@ mkMesonDerivation (finalAttrs: {
inherit version; inherit version;
workDir = ./.; workDir = ./.;
fileset = fileset.unions ([ fileset = fileset.unions (
../../build-utils-meson
./build-utils-meson
../../.version
./.version
./meson.build
# ./meson.options
# Symbolic links to other dirs
./build-remote
./doc
./nix-build
./nix-channel
./nix-collect-garbage
./nix-copy-closure
./nix-env
./nix-instantiate
./nix-store
# Doc nix files for --help
../../doc/manual/generate-manpage.nix
../../doc/manual/utils.nix
../../doc/manual/generate-settings.nix
../../doc/manual/generate-store-info.nix
# Other files to be included as string literals
../nix-channel/unpack-channel.nix
../nix-env/buildenv.nix
./get-env.sh
./help-stores.md
../../doc/manual/src/store/types/index.md.in
./profiles.md
../../doc/manual/src/command-ref/files/profiles.md
# Files
] ++ lib.concatMap
(dir: [
(fileset.fileFilter (file: file.hasExt "cc") dir)
(fileset.fileFilter (file: file.hasExt "hh") dir)
(fileset.fileFilter (file: file.hasExt "md") dir)
])
[ [
./. ../../build-utils-meson
../build-remote ./build-utils-meson
../nix-build ../../.version
../nix-channel ./.version
../nix-collect-garbage ./meson.build
../nix-copy-closure # ./meson.options
../nix-env
../nix-instantiate # Symbolic links to other dirs
../nix-store ./build-remote
./doc
./nix-build
./nix-channel
./nix-collect-garbage
./nix-copy-closure
./nix-env
./nix-instantiate
./nix-store
# Doc nix files for --help
../../doc/manual/generate-manpage.nix
../../doc/manual/utils.nix
../../doc/manual/generate-settings.nix
../../doc/manual/generate-store-info.nix
# Other files to be included as string literals
../nix-channel/unpack-channel.nix
../nix-env/buildenv.nix
./get-env.sh
./help-stores.md
../../doc/manual/src/store/types/index.md.in
./profiles.md
../../doc/manual/src/command-ref/files/profiles.md
# Files
] ]
++
lib.concatMap
(dir: [
(fileset.fileFilter (file: file.hasExt "cc") dir)
(fileset.fileFilter (file: file.hasExt "hh") dir)
(fileset.fileFilter (file: file.hasExt "md") dir)
])
[
./.
../build-remote
../nix-build
../nix-channel
../nix-collect-garbage
../nix-copy-closure
../nix-env
../nix-instantiate
../nix-store
]
); );
nativeBuildInputs = [ nativeBuildInputs = [
@ -108,9 +112,12 @@ mkMesonDerivation (finalAttrs: {
mesonFlags = [ mesonFlags = [
]; ];
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { env =
LDFLAGS = "-fuse-ld=gold"; lib.optionalAttrs
}; (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
{
LDFLAGS = "-fuse-ld=gold";
};
separateDebugInfo = !stdenv.hostPlatform.isStatic; separateDebugInfo = !stdenv.hostPlatform.isStatic;

View file

@ -1,77 +1,83 @@
{ lib {
, stdenv lib,
, mkMesonDerivation stdenv,
, perl mkMesonDerivation,
, perlPackages perl,
, meson perlPackages,
, ninja meson,
, pkg-config ninja,
, nix-store pkg-config,
, darwin nix-store,
, version darwin,
, curl version,
, bzip2 curl,
, libsodium bzip2,
libsodium,
}: }:
let let
inherit (lib) fileset; inherit (lib) fileset;
in in
perl.pkgs.toPerlModule (mkMesonDerivation (finalAttrs: { perl.pkgs.toPerlModule (
pname = "nix-perl"; mkMesonDerivation (finalAttrs: {
inherit version; pname = "nix-perl";
inherit version;
workDir = ./.; workDir = ./.;
fileset = fileset.unions ([ fileset = fileset.unions (
./.version [
../../.version ./.version
./MANIFEST ../../.version
./lib ./MANIFEST
./meson.build ./lib
./meson.options ./meson.build
] ++ lib.optionals finalAttrs.doCheck [ ./meson.options
./.yath.rc.in ]
./t ++ lib.optionals finalAttrs.doCheck [
]); ./.yath.rc.in
./t
]
);
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
ninja ninja
pkg-config pkg-config
perl perl
curl curl
]; ];
buildInputs = [ buildInputs = [
nix-store nix-store
bzip2 bzip2
libsodium libsodium
]; ];
# `perlPackages.Test2Harness` is marked broken for Darwin # `perlPackages.Test2Harness` is marked broken for Darwin
doCheck = !stdenv.isDarwin; doCheck = !stdenv.isDarwin;
nativeCheckInputs = [ nativeCheckInputs = [
perlPackages.Test2Harness perlPackages.Test2Harness
]; ];
preConfigure = preConfigure =
# "Inline" .version so its not a symlink, and includes the suffix # "Inline" .version so its not a symlink, and includes the suffix
'' ''
chmod u+w .version chmod u+w .version
echo ${finalAttrs.version} > .version echo ${finalAttrs.version} > .version
''; '';
mesonFlags = [ mesonFlags = [
(lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}") (lib.mesonOption "dbi_path" "${perlPackages.DBI}/${perl.libPrefix}")
(lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}") (lib.mesonOption "dbd_sqlite_path" "${perlPackages.DBDSQLite}/${perl.libPrefix}")
(lib.mesonEnable "tests" finalAttrs.doCheck) (lib.mesonEnable "tests" finalAttrs.doCheck)
]; ];
mesonCheckFlags = [ mesonCheckFlags = [
"--print-errorlogs" "--print-errorlogs"
]; ];
strictDeps = false; strictDeps = false;
})) })
)

View file

@ -1,6 +1,25 @@
let let
sixteenBytes = "0123456789abcdef"; sixteenBytes = "0123456789abcdef";
times16 = s: builtins.concatStringsSep "" [s s s s s s s s s s s s s s s s]; times16 =
s:
builtins.concatStringsSep "" [
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
s
];
exp = n: x: if n == 1 then x else times16 (exp (n - 1) x); exp = n: x: if n == 1 then x else times16 (exp (n - 1) x);
sixteenMegabyte = exp 6 sixteenBytes; sixteenMegabyte = exp 6 sixteenBytes;
in in

View file

@ -4,24 +4,39 @@ with import ./config.nix;
let let
mkDerivation = args: mkDerivation =
derivation ({ args:
inherit system; derivation (
builder = busybox; {
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' inherit system;
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; builder = busybox;
eval "$buildCommand" args = [
'')]; "sh"
outputHashMode = "recursive"; "-e"
outputHashAlgo = "sha256"; args.builder or (builtins.toFile "builder-${args.name}.sh" ''
} // removeAttrs args ["builder" "meta" "passthru"]) if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi;
// { meta = args.meta or {}; passthru = args.passthru or {}; }; eval "$buildCommand"
'')
];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
// removeAttrs args [
"builder"
"meta"
"passthru"
]
)
// {
meta = args.meta or { };
passthru = args.passthru or { };
};
input1 = mkDerivation { input1 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-1"; name = "build-remote-input-1";
buildCommand = "echo hi-input1; echo FOO > $out"; buildCommand = "echo hi-input1; echo FOO > $out";
requiredSystemFeatures = ["foo"]; requiredSystemFeatures = [ "foo" ];
outputHash = "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="; outputHash = "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=";
}; };
@ -29,7 +44,7 @@ let
shell = busybox; shell = busybox;
name = "build-remote-input-2"; name = "build-remote-input-2";
buildCommand = "echo hi; echo BAR > $out"; buildCommand = "echo hi; echo BAR > $out";
requiredSystemFeatures = ["bar"]; requiredSystemFeatures = [ "bar" ];
outputHash = "sha256-XArauVH91AVwP9hBBQNlkX9ccuPpSYx9o0zeIHb6e+Q="; outputHash = "sha256-XArauVH91AVwP9hBBQNlkX9ccuPpSYx9o0zeIHb6e+Q=";
}; };
@ -41,21 +56,20 @@ let
read x < ${input2} read x < ${input2}
echo $x BAZ > $out echo $x BAZ > $out
''; '';
requiredSystemFeatures = ["baz"]; requiredSystemFeatures = [ "baz" ];
outputHash = "sha256-daKAcPp/+BYMQsVi/YYMlCKoNAxCNDsaivwSHgQqD2s="; outputHash = "sha256-daKAcPp/+BYMQsVi/YYMlCKoNAxCNDsaivwSHgQqD2s=";
}; };
in in
mkDerivation { mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote"; name = "build-remote";
passthru = { inherit input1 input2 input3; }; passthru = { inherit input1 input2 input3; };
buildCommand = buildCommand = ''
'' read x < ${input1}
read x < ${input1} read y < ${input3}
read y < ${input3} echo "$x $y" > $out
echo "$x $y" > $out '';
''; outputHash = "sha256-5SxbkUw6xe2l9TE1uwCvTtTDysD1vhRor38OtDF0LqQ=";
outputHash = "sha256-5SxbkUw6xe2l9TE1uwCvTtTDysD1vhRor38OtDF0LqQ="; }
}

View file

@ -1,39 +1,61 @@
{ busybox, contentAddressed ? false }: {
busybox,
contentAddressed ? false,
}:
with import ./config.nix; with import ./config.nix;
let let
caArgs = if contentAddressed then { caArgs =
outputHashMode = "recursive"; if contentAddressed then
outputHashAlgo = "sha256"; {
__contentAddressed = true; outputHashMode = "recursive";
} else {}; outputHashAlgo = "sha256";
__contentAddressed = true;
}
else
{ };
mkDerivation = args: mkDerivation =
derivation ({ args:
inherit system; derivation (
builder = busybox; {
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' inherit system;
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; builder = busybox;
eval "$buildCommand" args = [
'')]; "sh"
} // removeAttrs args ["builder" "meta" "passthru"] "-e"
// caArgs) args.builder or (builtins.toFile "builder-${args.name}.sh" ''
// { meta = args.meta or {}; passthru = args.passthru or {}; }; if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi;
eval "$buildCommand"
'')
];
}
// removeAttrs args [
"builder"
"meta"
"passthru"
]
// caArgs
)
// {
meta = args.meta or { };
passthru = args.passthru or { };
};
input1 = mkDerivation { input1 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-1"; name = "build-remote-input-1";
buildCommand = "echo hi-input1; echo FOO > $out"; buildCommand = "echo hi-input1; echo FOO > $out";
requiredSystemFeatures = ["foo"]; requiredSystemFeatures = [ "foo" ];
}; };
input2 = mkDerivation { input2 = mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote-input-2"; name = "build-remote-input-2";
buildCommand = "echo hi; echo BAR > $out"; buildCommand = "echo hi; echo BAR > $out";
requiredSystemFeatures = ["bar"]; requiredSystemFeatures = [ "bar" ];
}; };
input3 = mkDerivation { input3 = mkDerivation {
@ -44,19 +66,18 @@ let
read x < ${input2} read x < ${input2}
echo $x BAZ > $out echo $x BAZ > $out
''; '';
requiredSystemFeatures = ["baz"]; requiredSystemFeatures = [ "baz" ];
}; };
in in
mkDerivation { mkDerivation {
shell = busybox; shell = busybox;
name = "build-remote"; name = "build-remote";
passthru = { inherit input1 input2 input3; }; passthru = { inherit input1 input2 input3; };
buildCommand = buildCommand = ''
'' read x < ${input1}
read x < ${input1} read y < ${input3}
read y < ${input3} echo "$x $y" > $out
echo "$x $y" > $out '';
''; }
}

View file

@ -1 +1,5 @@
{ inNixShell ? false, ... }@args: import ./shell.nix (args // { contentAddressed = true; }) {
inNixShell ? false,
...
}@args:
import ./shell.nix (args // { contentAddressed = true; })

View file

@ -1,13 +1,21 @@
with import ./config.nix; with import ./config.nix;
let mkCADerivation = args: mkDerivation ({ let
__contentAddressed = true; mkCADerivation =
outputHashMode = "recursive"; args:
outputHashAlgo = "sha256"; mkDerivation (
} // args); {
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
// args
);
in in
{ seed ? 0 }: {
seed ? 0,
}:
# A simple content-addressed derivation. # A simple content-addressed derivation.
# The derivation can be arbitrarily modified by passing a different `seed`, # The derivation can be arbitrarily modified by passing a different `seed`,
# but the output will always be the same # but the output will always be the same
@ -23,7 +31,11 @@ rec {
}; };
rootCA = mkCADerivation { rootCA = mkCADerivation {
name = "rootCA"; name = "rootCA";
outputs = [ "out" "dev" "foo" ]; outputs = [
"out"
"dev"
"foo"
];
buildCommand = '' buildCommand = ''
echo "building a CA derivation" echo "building a CA derivation"
echo "The seed is ${toString seed}" echo "The seed is ${toString seed}"

View file

@ -1,3 +1,3 @@
{ {
outputs = { self }: import ./content-addressed.nix {}; outputs = { self }: import ./content-addressed.nix { };
} }

View file

@ -1,10 +1,16 @@
with import ./config.nix; with import ./config.nix;
let mkCADerivation = args: mkDerivation ({ let
__contentAddressed = true; mkCADerivation =
outputHashMode = "recursive"; args:
outputHashAlgo = "sha256"; mkDerivation (
} // args); {
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
// args
);
in in
rec { rec {
@ -15,13 +21,15 @@ rec {
echo $(date) > $out/current-time echo $(date) > $out/current-time
''; '';
}; };
dep = seed: mkCADerivation { dep =
name = "dep"; seed:
inherit seed; mkCADerivation {
buildCommand = '' name = "dep";
echo ${currentTime} > $out inherit seed;
''; buildCommand = ''
}; echo ${currentTime} > $out
'';
};
dep1 = dep 1; dep1 = dep 1;
dep2 = dep 2; dep2 = dep 2;
toplevel = mkCADerivation { toplevel = mkCADerivation {
@ -32,4 +40,3 @@ rec {
''; '';
}; };
} }

View file

@ -1,7 +1,6 @@
# A derivation that would certainly fail if several builders tried to # A derivation that would certainly fail if several builders tried to
# build it at once. # build it at once.
with import ./config.nix; with import ./config.nix;
mkDerivation { mkDerivation {

View file

@ -2,11 +2,16 @@ with import ./config.nix;
rec { rec {
dep = import ./dependencies.nix {}; dep = import ./dependencies.nix { };
makeTest = nr: args: mkDerivation ({ makeTest =
name = "check-refs-" + toString nr; nr: args:
} // args); mkDerivation (
{
name = "check-refs-" + toString nr;
}
// args
);
src = builtins.toFile "aux-ref" "bla bla"; src = builtins.toFile "aux-ref" "bla bla";
@ -22,31 +27,31 @@ rec {
test3 = makeTest 3 { test3 = makeTest 3 {
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
allowedReferences = []; allowedReferences = [ ];
inherit dep; inherit dep;
}; };
test4 = makeTest 4 { test4 = makeTest 4 {
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
allowedReferences = [dep]; allowedReferences = [ dep ];
inherit dep; inherit dep;
}; };
test5 = makeTest 5 { test5 = makeTest 5 {
builder = builtins.toFile "builder.sh" "mkdir $out"; builder = builtins.toFile "builder.sh" "mkdir $out";
allowedReferences = []; allowedReferences = [ ];
inherit dep; inherit dep;
}; };
test6 = makeTest 6 { test6 = makeTest 6 {
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link";
allowedReferences = []; allowedReferences = [ ];
inherit dep; inherit dep;
}; };
test7 = makeTest 7 { test7 = makeTest 7 {
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link";
allowedReferences = ["out"]; allowedReferences = [ "out" ];
inherit dep; inherit dep;
}; };
@ -58,19 +63,19 @@ rec {
test9 = makeTest 9 { test9 = makeTest 9 {
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
inherit dep; inherit dep;
disallowedReferences = [dep]; disallowedReferences = [ dep ];
}; };
test10 = makeTest 10 { test10 = makeTest 10 {
builder = builtins.toFile "builder.sh" "mkdir $out; echo $test5; ln -s $dep $out/link"; builder = builtins.toFile "builder.sh" "mkdir $out; echo $test5; ln -s $dep $out/link";
inherit dep test5; inherit dep test5;
disallowedReferences = [test5]; disallowedReferences = [ test5 ];
}; };
test11 = makeTest 11 { test11 = makeTest 11 {
__structuredAttrs = true; __structuredAttrs = true;
unsafeDiscardReferences.out = true; unsafeDiscardReferences.out = true;
outputChecks.out.allowedReferences = []; outputChecks.out.allowedReferences = [ ];
buildCommand = ''echo ${dep} > "''${outputs[out]}"''; buildCommand = ''echo ${dep} > "''${outputs[out]}"'';
}; };

View file

@ -22,36 +22,48 @@ rec {
''; '';
}; };
makeTest = nr: allowreqs: mkDerivation { makeTest =
name = "check-reqs-" + toString nr; nr: allowreqs:
inherit deps; mkDerivation {
builder = builtins.toFile "builder.sh" '' name = "check-reqs-" + toString nr;
mkdir $out inherit deps;
ln -s $deps $out/depdir1 builder = builtins.toFile "builder.sh" ''
''; mkdir $out
allowedRequisites = allowreqs; ln -s $deps $out/depdir1
}; '';
allowedRequisites = allowreqs;
};
# When specifying all the requisites, the build succeeds. # When specifying all the requisites, the build succeeds.
test1 = makeTest 1 [ dep1 dep2 deps ]; test1 = makeTest 1 [
dep1
dep2
deps
];
# But missing anything it fails. # But missing anything it fails.
test2 = makeTest 2 [ dep2 deps ]; test2 = makeTest 2 [
test3 = makeTest 3 [ dep1 deps ]; dep2
deps
];
test3 = makeTest 3 [
dep1
deps
];
test4 = makeTest 4 [ deps ]; test4 = makeTest 4 [ deps ];
test5 = makeTest 5 []; test5 = makeTest 5 [ ];
test6 = mkDerivation { test6 = mkDerivation {
name = "check-reqs"; name = "check-reqs";
inherit deps; inherit deps;
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1";
disallowedRequisites = [dep1]; disallowedRequisites = [ dep1 ];
}; };
test7 = mkDerivation { test7 = mkDerivation {
name = "check-reqs"; name = "check-reqs";
inherit deps; inherit deps;
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1"; builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1";
disallowedRequisites = [test1]; disallowedRequisites = [ test1 ];
}; };
} }

View file

@ -1,4 +1,6 @@
{checkBuildId ? 0}: {
checkBuildId ? 0,
}:
with import ./config.nix; with import ./config.nix;
@ -6,41 +8,38 @@ with import ./config.nix;
nondeterministic = mkDerivation { nondeterministic = mkDerivation {
inherit checkBuildId; inherit checkBuildId;
name = "nondeterministic"; name = "nondeterministic";
buildCommand = buildCommand = ''
'' mkdir $out
mkdir $out date +%s.%N > $out/date
date +%s.%N > $out/date echo "CHECK_TMPDIR=$TMPDIR"
echo "CHECK_TMPDIR=$TMPDIR" echo "checkBuildId=$checkBuildId"
echo "checkBuildId=$checkBuildId" echo "$checkBuildId" > $TMPDIR/checkBuildId
echo "$checkBuildId" > $TMPDIR/checkBuildId '';
'';
}; };
deterministic = mkDerivation { deterministic = mkDerivation {
inherit checkBuildId; inherit checkBuildId;
name = "deterministic"; name = "deterministic";
buildCommand = buildCommand = ''
'' mkdir $out
mkdir $out echo date > $out/date
echo date > $out/date echo "CHECK_TMPDIR=$TMPDIR"
echo "CHECK_TMPDIR=$TMPDIR" echo "checkBuildId=$checkBuildId"
echo "checkBuildId=$checkBuildId" echo "$checkBuildId" > $TMPDIR/checkBuildId
echo "$checkBuildId" > $TMPDIR/checkBuildId '';
'';
}; };
failed = mkDerivation { failed = mkDerivation {
inherit checkBuildId; inherit checkBuildId;
name = "failed"; name = "failed";
buildCommand = buildCommand = ''
'' mkdir $out
mkdir $out echo date > $out/date
echo date > $out/date echo "CHECK_TMPDIR=$TMPDIR"
echo "CHECK_TMPDIR=$TMPDIR" echo "checkBuildId=$checkBuildId"
echo "checkBuildId=$checkBuildId" echo "$checkBuildId" > $TMPDIR/checkBuildId
echo "$checkBuildId" > $TMPDIR/checkBuildId false
false '';
'';
}; };
hashmismatch = import <nix/fetchurl.nix> { hashmismatch = import <nix/fetchurl.nix> {

View file

@ -1,4 +1,6 @@
{ hashInvalidator ? "" }: {
hashInvalidator ? "",
}:
with import ./config.nix; with import ./config.nix;
let let

View file

@ -2,5 +2,8 @@ derivation {
name = "advanced-attributes-defaults"; name = "advanced-attributes-defaults";
system = "my-system"; system = "my-system";
builder = "/bin/bash"; builder = "/bin/bash";
args = [ "-c" "echo hello > $out" ]; args = [
"-c"
"echo hello > $out"
];
} }

View file

@ -2,7 +2,13 @@ derivation {
name = "advanced-attributes-structured-attrs-defaults"; name = "advanced-attributes-structured-attrs-defaults";
system = "my-system"; system = "my-system";
builder = "/bin/bash"; builder = "/bin/bash";
args = [ "-c" "echo hello > $out" ]; args = [
outputs = [ "out" "dev" ]; "-c"
"echo hello > $out"
];
outputs = [
"out"
"dev"
];
__structuredAttrs = true; __structuredAttrs = true;
} }

View file

@ -4,42 +4,58 @@ let
inherit system; inherit system;
name = "foo"; name = "foo";
builder = "/bin/bash"; builder = "/bin/bash";
args = ["-c" "echo foo > $out"]; args = [
"-c"
"echo foo > $out"
];
}; };
bar = derivation { bar = derivation {
inherit system; inherit system;
name = "bar"; name = "bar";
builder = "/bin/bash"; builder = "/bin/bash";
args = ["-c" "echo bar > $out"]; args = [
"-c"
"echo bar > $out"
];
}; };
in in
derivation { derivation {
inherit system; inherit system;
name = "advanced-attributes-structured-attrs"; name = "advanced-attributes-structured-attrs";
builder = "/bin/bash"; builder = "/bin/bash";
args = [ "-c" "echo hello > $out" ]; args = [
"-c"
"echo hello > $out"
];
__sandboxProfile = "sandcastle"; __sandboxProfile = "sandcastle";
__noChroot = true; __noChroot = true;
__impureHostDeps = ["/usr/bin/ditto"]; __impureHostDeps = [ "/usr/bin/ditto" ];
impureEnvVars = ["UNICORN"]; impureEnvVars = [ "UNICORN" ];
__darwinAllowLocalNetworking = true; __darwinAllowLocalNetworking = true;
outputs = [ "out" "bin" "dev" ]; outputs = [
"out"
"bin"
"dev"
];
__structuredAttrs = true; __structuredAttrs = true;
outputChecks = { outputChecks = {
out = { out = {
allowedReferences = [foo]; allowedReferences = [ foo ];
allowedRequisites = [foo]; allowedRequisites = [ foo ];
}; };
bin = { bin = {
disallowedReferences = [bar]; disallowedReferences = [ bar ];
disallowedRequisites = [bar]; disallowedRequisites = [ bar ];
}; };
dev = { dev = {
maxSize = 789; maxSize = 789;
maxClosureSize = 5909; maxClosureSize = 5909;
}; };
}; };
requiredSystemFeatures = ["rainbow" "uid-range"]; requiredSystemFeatures = [
"rainbow"
"uid-range"
];
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
} }

View file

@ -4,30 +4,42 @@ let
inherit system; inherit system;
name = "foo"; name = "foo";
builder = "/bin/bash"; builder = "/bin/bash";
args = ["-c" "echo foo > $out"]; args = [
"-c"
"echo foo > $out"
];
}; };
bar = derivation { bar = derivation {
inherit system; inherit system;
name = "bar"; name = "bar";
builder = "/bin/bash"; builder = "/bin/bash";
args = ["-c" "echo bar > $out"]; args = [
"-c"
"echo bar > $out"
];
}; };
in in
derivation { derivation {
inherit system; inherit system;
name = "advanced-attributes"; name = "advanced-attributes";
builder = "/bin/bash"; builder = "/bin/bash";
args = [ "-c" "echo hello > $out" ]; args = [
"-c"
"echo hello > $out"
];
__sandboxProfile = "sandcastle"; __sandboxProfile = "sandcastle";
__noChroot = true; __noChroot = true;
__impureHostDeps = ["/usr/bin/ditto"]; __impureHostDeps = [ "/usr/bin/ditto" ];
impureEnvVars = ["UNICORN"]; impureEnvVars = [ "UNICORN" ];
__darwinAllowLocalNetworking = true; __darwinAllowLocalNetworking = true;
allowedReferences = [foo]; allowedReferences = [ foo ];
allowedRequisites = [foo]; allowedRequisites = [ foo ];
disallowedReferences = [bar]; disallowedReferences = [ bar ];
disallowedRequisites = [bar]; disallowedRequisites = [ bar ];
requiredSystemFeatures = ["rainbow" "uid-range"]; requiredSystemFeatures = [
"rainbow"
"uid-range"
];
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
} }

View file

@ -1,6 +1,8 @@
with import ./config.nix; with import ./config.nix;
let innerName = "foo"; in let
innerName = "foo";
in
mkDerivation rec { mkDerivation rec {
name = "${innerName}.drv"; name = "${innerName}.drv";

View file

@ -2,28 +2,33 @@ with import ./config.nix;
rec { rec {
printRefs = printRefs = ''
'' echo $exportReferencesGraph
echo $exportReferencesGraph while read path; do
while read path; do read drv
read drv read nrRefs
read nrRefs echo "$path has $nrRefs references"
echo "$path has $nrRefs references" echo "$path" >> $out
echo "$path" >> $out for ((n = 0; n < $nrRefs; n++)); do read ref; echo "ref $ref"; test -e "$ref"; done
for ((n = 0; n < $nrRefs; n++)); do read ref; echo "ref $ref"; test -e "$ref"; done done < refs
done < refs '';
'';
foo."bar.runtimeGraph" = mkDerivation { foo."bar.runtimeGraph" = mkDerivation {
name = "dependencies"; name = "dependencies";
builder = builtins.toFile "build-graph-builder" "${printRefs}"; builder = builtins.toFile "build-graph-builder" "${printRefs}";
exportReferencesGraph = ["refs" (import ./dependencies.nix {})]; exportReferencesGraph = [
"refs"
(import ./dependencies.nix { })
];
}; };
foo."bar.buildGraph" = mkDerivation { foo."bar.buildGraph" = mkDerivation {
name = "dependencies"; name = "dependencies";
builder = builtins.toFile "build-graph-builder" "${printRefs}"; builder = builtins.toFile "build-graph-builder" "${printRefs}";
exportReferencesGraph = ["refs" (import ./dependencies.nix {}).drvPath]; exportReferencesGraph = [
"refs"
(import ./dependencies.nix { }).drvPath
];
}; };
} }

View file

@ -2,16 +2,29 @@
with import ./config.nix; with import ./config.nix;
let let
mkDerivation = args: mkDerivation =
derivation ({ args:
inherit system; derivation (
builder = busybox; {
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' inherit system;
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; builder = busybox;
eval "$buildCommand" args = [
'')]; "sh"
} // removeAttrs args ["builder" "meta"]) "-e"
// { meta = args.meta or {}; }; args.builder or (builtins.toFile "builder-${args.name}.sh" ''
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi;
eval "$buildCommand"
'')
];
}
// removeAttrs args [
"builder"
"meta"
]
)
// {
meta = args.meta or { };
};
in in
{ {

View file

@ -4,9 +4,12 @@ mkDerivation {
name = "filter"; name = "filter";
builder = builtins.toFile "builder" "ln -s $input $out"; builder = builtins.toFile "builder" "ln -s $input $out";
input = input =
let filter = path: type: let
type != "symlink" filter =
&& baseNameOf path != "foo" path: type:
&& !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path)); type != "symlink"
in builtins.filterSource filter ((builtins.getEnv "TEST_ROOT") + "/filterin"); && baseNameOf path != "foo"
&& !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path));
in
builtins.filterSource filter ((builtins.getEnv "TEST_ROOT") + "/filterin");
} }

View file

@ -2,15 +2,20 @@ with import ./config.nix;
rec { rec {
f2 = dummy: builder: mode: algo: hash: mkDerivation { f2 =
name = "fixed"; dummy: builder: mode: algo: hash:
inherit builder; mkDerivation {
outputHashMode = mode; name = "fixed";
outputHashAlgo = algo; inherit builder;
outputHash = hash; outputHashMode = mode;
inherit dummy; outputHashAlgo = algo;
impureEnvVars = ["IMPURE_VAR1" "IMPURE_VAR2"]; outputHash = hash;
}; inherit dummy;
impureEnvVars = [
"IMPURE_VAR1"
"IMPURE_VAR2"
];
};
f = f2 ""; f = f2 "";
@ -37,7 +42,8 @@ rec {
]; ];
sameAsAdd = sameAsAdd =
f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik"; f ./fixed.builder2.sh "recursive" "sha256"
"1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
bad = [ bad = [
(f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858") (f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")

View file

@ -2,38 +2,34 @@ with import ./config.nix;
rec { rec {
x1 = mkDerivation { x1 = mkDerivation {
name = "x1"; name = "x1";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo $name > $out
echo $name > $out '';
'';
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}; };
x2 = mkDerivation { x2 = mkDerivation {
name = "x2"; name = "x2";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo $name > $out
echo $name > $out '';
'';
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}; };
x3 = mkDerivation { x3 = mkDerivation {
name = "x3"; name = "x3";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo $name > $out
echo $name > $out '';
'';
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; outputHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}; };
x4 = mkDerivation { x4 = mkDerivation {
name = "x4"; name = "x4";
inherit x2 x3; inherit x2 x3;
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo $x2 $x3
echo $x2 $x3 exit 1
exit 1 '';
'';
}; };
} }

View file

@ -1,6 +1,8 @@
with import ./config.nix; with import ./config.nix;
{ lockFifo ? null }: {
lockFifo ? null,
}:
rec { rec {

View file

@ -4,14 +4,22 @@ let {
name = "dependencies-input-1"; name = "dependencies-input-1";
system = "i086-msdos"; system = "i086-msdos";
builder = "/bar/sh"; builder = "/bar/sh";
args = ["-e" "-x" ./dummy]; args = [
"-e"
"-x"
./dummy
];
}; };
input2 = derivation { input2 = derivation {
name = "dependencies-input-2"; name = "dependencies-input-2";
system = "i086-msdos"; system = "i086-msdos";
builder = "/bar/sh"; builder = "/bar/sh";
args = ["-e" "-x" ./dummy]; args = [
"-e"
"-x"
./dummy
];
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHashAlgo = "md5"; outputHashAlgo = "md5";
outputHash = "ffffffffffffffffffffffffffffffff"; outputHash = "ffffffffffffffffffffffffffffffff";
@ -21,9 +29,13 @@ let {
name = "dependencies"; name = "dependencies";
system = "i086-msdos"; system = "i086-msdos";
builder = "/bar/sh"; builder = "/bar/sh";
args = ["-e" "-x" (./dummy + "/FOOBAR/../.")]; args = [
"-e"
"-x"
(./dummy + "/FOOBAR/../.")
];
input1 = input1 + "/."; input1 = input1 + "/.";
inherit input2; inherit input2;
}; };
} }

View file

@ -1,31 +1,51 @@
{ busybox {
, seed busybox,
# If we want the final derivation output to have references to its seed,
# dependencies. Some tests need/want this, other don't. # If we want the final derivation output to have references to its
, withFinalRefs ? false # dependencies. Some tests need/want this, other don't.
withFinalRefs ? false,
}: }:
with import ./config.nix; with import ./config.nix;
let let
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1"; contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
caArgs = if contentAddressedByDefault then { caArgs =
__contentAddressed = true; if contentAddressedByDefault then
outputHashMode = "recursive"; {
outputHashAlgo = "sha256"; __contentAddressed = true;
} else {}; outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
else
{ };
mkDerivation = args: mkDerivation =
derivation ({ args:
inherit system; derivation (
builder = busybox; {
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' inherit system;
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; builder = busybox;
eval "$buildCommand" args = [
'')]; "sh"
} // removeAttrs args ["builder" "meta" "passthru"] "-e"
// caArgs) args.builder or (builtins.toFile "builder-${args.name}.sh" ''
// { meta = args.meta or {}; passthru = args.passthru or {}; }; if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi;
eval "$buildCommand"
'')
];
}
// removeAttrs args [
"builder"
"meta"
"passthru"
]
// caArgs
)
// {
meta = args.meta or { };
passthru = args.passthru or { };
};
input1 = mkDerivation { input1 = mkDerivation {
shell = busybox; shell = busybox;
@ -51,14 +71,15 @@ let
in in
mkDerivation { mkDerivation {
shell = busybox; shell = busybox;
name = "hermetic"; name = "hermetic";
passthru = { inherit input1 input2 input3; }; passthru = { inherit input1 input2 input3; };
buildCommand = buildCommand = ''
'' read x < ${input1}
read x < ${input1} read y < ${input3}
read y < ${input3} echo ${
echo ${if (builtins.trace withFinalRefs withFinalRefs) then "${input1} ${input3}" else ""} "$x $y" > $out if (builtins.trace withFinalRefs withFinalRefs) then "${input1} ${input3}" else ""
''; } "$x $y" > $out
} '';
}

View file

@ -1,10 +1,8 @@
with import ./config.nix; with import ./config.nix;
import ( import (mkDerivation {
mkDerivation { name = "foo";
name = "foo"; bla = import ./dependencies.nix { };
bla = import ./dependencies.nix {}; buildCommand = "
buildCommand = "
echo \\\"hi\\\" > $out echo \\\"hi\\\" > $out
"; ";
} })
)

View file

@ -4,10 +4,9 @@ let
bar = mkDerivation { bar = mkDerivation {
name = "bar"; name = "bar";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo 'builtins.add 123 456' > $out
echo 'builtins.add 123 456' > $out '';
'';
}; };
value = value =
@ -19,8 +18,7 @@ in
mkDerivation { mkDerivation {
name = "foo"; name = "foo";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo -n FOO${toString value} > $out
echo -n FOO${toString value} > $out '';
'';
} }

View file

@ -3,10 +3,9 @@ with import <config>;
rec { rec {
bar = mkDerivation { bar = mkDerivation {
name = "bar"; name = "bar";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo 'builtins.add 123 456' > $out
echo 'builtins.add 123 456' > $out '';
'';
}; };
value = value =
@ -16,19 +15,17 @@ rec {
result = mkDerivation { result = mkDerivation {
name = "foo"; name = "foo";
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo -n FOO${toString value} > $out
echo -n FOO${toString value} > $out '';
'';
}; };
addPath = mkDerivation { addPath = mkDerivation {
name = "add-path"; name = "add-path";
src = builtins.filterSource (path: type: true) result; src = builtins.filterSource (path: type: true) result;
builder = builtins.toFile "builder.sh" builder = builtins.toFile "builder.sh" ''
'' echo -n BLA$(cat $src) > $out
echo -n BLA$(cat $src) > $out '';
'';
}; };
step1 = mkDerivation { step1 = mkDerivation {

View file

@ -4,60 +4,58 @@ rec {
impure = mkDerivation { impure = mkDerivation {
name = "impure"; name = "impure";
outputs = [ "out" "stuff" ]; outputs = [
buildCommand = "out"
'' "stuff"
echo impure ];
x=$(< $TEST_ROOT/counter) buildCommand = ''
mkdir $out $stuff echo impure
echo $x > $out/n x=$(< $TEST_ROOT/counter)
ln -s $out/n $stuff/bla mkdir $out $stuff
printf $((x + 1)) > $TEST_ROOT/counter echo $x > $out/n
''; ln -s $out/n $stuff/bla
printf $((x + 1)) > $TEST_ROOT/counter
'';
__impure = true; __impure = true;
impureEnvVars = [ "TEST_ROOT" ]; impureEnvVars = [ "TEST_ROOT" ];
}; };
impureOnImpure = mkDerivation { impureOnImpure = mkDerivation {
name = "impure-on-impure"; name = "impure-on-impure";
buildCommand = buildCommand = ''
'' echo impure-on-impure
echo impure-on-impure x=$(< ${impure}/n)
x=$(< ${impure}/n) mkdir $out
mkdir $out printf X$x > $out/n
printf X$x > $out/n ln -s ${impure.stuff} $out/symlink
ln -s ${impure.stuff} $out/symlink ln -s $out $out/self
ln -s $out $out/self '';
'';
__impure = true; __impure = true;
}; };
# This is not allowed. # This is not allowed.
inputAddressed = mkDerivation { inputAddressed = mkDerivation {
name = "input-addressed"; name = "input-addressed";
buildCommand = buildCommand = ''
'' cat ${impure} > $out
cat ${impure} > $out '';
'';
}; };
contentAddressed = mkDerivation { contentAddressed = mkDerivation {
name = "content-addressed"; name = "content-addressed";
buildCommand = buildCommand = ''
'' echo content-addressed
echo content-addressed x=$(< ${impureOnImpure}/n)
x=$(< ${impureOnImpure}/n) printf ''${x:0:1} > $out
printf ''${x:0:1} > $out '';
'';
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash = "sha256-eBYxcgkuWuiqs4cKNgKwkb3vY/HR0vVsJnqe8itJGcQ="; outputHash = "sha256-eBYxcgkuWuiqs4cKNgKwkb3vY/HR0vVsJnqe8itJGcQ=";
}; };
inputAddressedAfterCA = mkDerivation { inputAddressedAfterCA = mkDerivation {
name = "input-addressed-after-ca"; name = "input-addressed-after-ca";
buildCommand = buildCommand = ''
'' cat ${contentAddressed} > $out
cat ${contentAddressed} > $out '';
'';
}; };
} }

View file

@ -1,4 +1,3 @@
# Run: # Run:
# GC_INITIAL_HEAP_SIZE=$[1024 * 1024] NIX_SHOW_STATS=1 nix eval -f gc-coroutine-test.nix -vvvv # GC_INITIAL_HEAP_SIZE=$[1024 * 1024] NIX_SHOW_STATS=1 nix eval -f gc-coroutine-test.nix -vvvv
@ -11,55 +10,56 @@ let
# Generate a tree of numbers, n deep, such that the numbers add up to (1 + salt) * 10^n. # Generate a tree of numbers, n deep, such that the numbers add up to (1 + salt) * 10^n.
# The salting makes the numbers all different, increasing the likelihood of catching # The salting makes the numbers all different, increasing the likelihood of catching
# any memory corruptions that might be caused by the GC or otherwise. # any memory corruptions that might be caused by the GC or otherwise.
garbage = salt: n: garbage =
if n == 0 salt: n:
then [(1 + salt)] if n == 0 then
else [ [ (1 + salt) ]
(garbage (10 * salt + 1) (n - 1)) else
(garbage (10 * salt - 1) (n - 1)) [
(garbage (10 * salt + 2) (n - 1)) (garbage (10 * salt + 1) (n - 1))
(garbage (10 * salt - 2) (n - 1)) (garbage (10 * salt - 1) (n - 1))
(garbage (10 * salt + 3) (n - 1)) (garbage (10 * salt + 2) (n - 1))
(garbage (10 * salt - 3) (n - 1)) (garbage (10 * salt - 2) (n - 1))
(garbage (10 * salt + 4) (n - 1)) (garbage (10 * salt + 3) (n - 1))
(garbage (10 * salt - 4) (n - 1)) (garbage (10 * salt - 3) (n - 1))
(garbage (10 * salt + 5) (n - 1)) (garbage (10 * salt + 4) (n - 1))
(garbage (10 * salt - 5) (n - 1)) (garbage (10 * salt - 4) (n - 1))
]; (garbage (10 * salt + 5) (n - 1))
(garbage (10 * salt - 5) (n - 1))
];
pow = base: n: pow = base: n: if n == 0 then 1 else base * (pow base (n - 1));
if n == 0
then 1
else base * (pow base (n - 1));
sumNestedLists = l: sumNestedLists = l: if isList l then foldl' (a: b: a + sumNestedLists b) 0 l else l;
if isList l
then foldl' (a: b: a + sumNestedLists b) 0 l
else l;
in in
assert sumNestedLists (garbage 0 3) == pow 10 3; assert sumNestedLists (garbage 0 3) == pow 10 3;
assert sumNestedLists (garbage 0 6) == pow 10 6; assert sumNestedLists (garbage 0 6) == pow 10 6;
builtins.foldl' builtins.foldl'
(a: b: (
assert a: b:
"${ assert
builtins.path { "${builtins.path {
path = ./src; path = ./src;
filter = path: type: filter =
# We're not doing common subexpression elimination, so this reallocates path: type:
# the fairly big tree over and over, producing a lot of garbage during # We're not doing common subexpression elimination, so this reallocates
# source filtering, whose filter runs in a coroutine. # the fairly big tree over and over, producing a lot of garbage during
assert sumNestedLists (garbage 0 3) == pow 10 3; # source filtering, whose filter runs in a coroutine.
true; assert sumNestedLists (garbage 0 3) == pow 10 3;
} true;
}" }}" == "${./src}";
== "${./src}";
# These asserts don't seem necessary, as the lambda value get corrupted first # These asserts don't seem necessary, as the lambda value get corrupted first
assert a.okay; assert a.okay;
assert b.okay; assert b.okay;
{ okay = true; } {
) okay = true;
}
)
{ okay = true; }
[
{ okay = true; } { okay = true; }
[ { okay = true; } { okay = true; } { okay = true; } ] { okay = true; }
{ okay = true; }
]

View file

@ -1,9 +1,9 @@
error: error:
… while calling the 'addDrvOutputDependencies' builtin … while calling the 'addDrvOutputDependencies' builtin
at /pwd/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix:18:4: at /pwd/lang/eval-fail-addDrvOutputDependencies-multi-elem-context.nix:25:1:
17| 24| in
18| in builtins.addDrvOutputDependencies combo-path 25| builtins.addDrvOutputDependencies combo-path
| ^ | ^
19| 26|
error: context of string '/nix/store/pg9yqs4yd85yhdm3f4i5dyaqp5jahrsz-fail.drv/nix/store/2dxd5frb715z451vbf7s8birlf3argbk-fail-2.drv' must have exactly one element, but has 2 error: context of string '/nix/store/pg9yqs4yd85yhdm3f4i5dyaqp5jahrsz-fail.drv/nix/store/2dxd5frb715z451vbf7s8birlf3argbk-fail-2.drv' must have exactly one element, but has 2

View file

@ -3,16 +3,23 @@ let
name = "fail"; name = "fail";
builder = "/bin/false"; builder = "/bin/false";
system = "x86_64-linux"; system = "x86_64-linux";
outputs = [ "out" "foo" ]; outputs = [
"out"
"foo"
];
}; };
drv1 = derivation { drv1 = derivation {
name = "fail-2"; name = "fail-2";
builder = "/bin/false"; builder = "/bin/false";
system = "x86_64-linux"; system = "x86_64-linux";
outputs = [ "out" "foo" ]; outputs = [
"out"
"foo"
];
}; };
combo-path = "${drv0.drvPath}${drv1.drvPath}"; combo-path = "${drv0.drvPath}${drv1.drvPath}";
in builtins.addDrvOutputDependencies combo-path in
builtins.addDrvOutputDependencies combo-path

View file

@ -1,9 +1,9 @@
error: error:
… while calling the 'addDrvOutputDependencies' builtin … while calling the 'addDrvOutputDependencies' builtin
at /pwd/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix:9:4: at /pwd/lang/eval-fail-addDrvOutputDependencies-wrong-element-kind.nix:13:1:
8| 12| in
9| in builtins.addDrvOutputDependencies drv.outPath 13| builtins.addDrvOutputDependencies drv.outPath
| ^ | ^
10| 14|
error: `addDrvOutputDependencies` can only act on derivations, not on a derivation output such as 'out' error: `addDrvOutputDependencies` can only act on derivations, not on a derivation output such as 'out'

View file

@ -3,7 +3,11 @@ let
name = "fail"; name = "fail";
builder = "/bin/false"; builder = "/bin/false";
system = "x86_64-linux"; system = "x86_64-linux";
outputs = [ "out" "foo" ]; outputs = [
"out"
"foo"
];
}; };
in builtins.addDrvOutputDependencies drv.outPath in
builtins.addDrvOutputDependencies drv.outPath

View file

@ -1,9 +1,9 @@
let let
countDown = n: countDown =
if n == 0 n:
then throw "kaboom" if n == 0 then
throw "kaboom"
else else
builtins.addErrorContext builtins.addErrorContext "while counting down; n = ${toString n}" ("x" + countDown (n - 1));
"while counting down; n = ${toString n}" in
("x" + countDown (n - 1)); countDown 10
in countDown 10

View file

@ -1,8 +1,8 @@
error: error:
… while evaluating the condition of the assertion '({ a = true; } == { a = true; b = true; })' … while evaluating the condition of the assertion '({ a = true; } == { a = true; b = true; })'
at /pwd/lang/eval-fail-assert-equal-attrs-names-2.nix:1:1: at /pwd/lang/eval-fail-assert-equal-attrs-names-2.nix:1:1:
1| assert { a = true; } == { a = true; b = true; }; 1| assert
| ^ | ^
2| throw "unreachable" 2| {
error: attribute names of attribute set '{ a = true; }' differs from attribute set '{ a = true; b = true; }' error: attribute names of attribute set '{ a = true; }' differs from attribute set '{ a = true; b = true; }'

View file

@ -1,2 +1,8 @@
assert { a = true; } == { a = true; b = true; }; assert
{
a = true;
} == {
a = true;
b = true;
};
throw "unreachable" throw "unreachable"

View file

@ -1,8 +1,8 @@
error: error:
… while evaluating the condition of the assertion '({ a = true; b = true; } == { a = true; })' … while evaluating the condition of the assertion '({ a = true; b = true; } == { a = true; })'
at /pwd/lang/eval-fail-assert-equal-attrs-names.nix:1:1: at /pwd/lang/eval-fail-assert-equal-attrs-names.nix:1:1:
1| assert { a = true; b = true; } == { a = true; }; 1| assert
| ^ | ^
2| throw "unreachable" 2| {
error: attribute names of attribute set '{ a = true; b = true; }' differs from attribute set '{ a = true; }' error: attribute names of attribute set '{ a = true; b = true; }' differs from attribute set '{ a = true; }'

View file

@ -1,2 +1,8 @@
assert { a = true; b = true; } == { a = true; }; assert
{
a = true;
b = true;
} == {
a = true;
};
throw "unreachable" throw "unreachable"

View file

@ -3,23 +3,23 @@ error:
at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:1:1: at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:1:1:
1| assert 1| assert
| ^ | ^
2| { foo = { type = "derivation"; outPath = "/nix/store/0"; }; } 2| {
… while comparing attribute 'foo' … while comparing attribute 'foo'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:2:5: at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:3:5:
1| assert 2| {
2| { foo = { type = "derivation"; outPath = "/nix/store/0"; }; } 3| foo = {
| ^ | ^
3| == 4| type = "derivation";
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:4:5: at /pwd/lang/eval-fail-assert-equal-derivations-extra.nix:8:5:
3| == 7| } == {
4| { foo = { type = "derivation"; outPath = "/nix/store/1"; devious = true; }; }; 8| foo = {
| ^ | ^
5| throw "unreachable" 9| type = "derivation";
… while comparing a derivation by its 'outPath' attribute … while comparing a derivation by its 'outPath' attribute

View file

@ -1,5 +1,14 @@
assert assert
{ foo = { type = "derivation"; outPath = "/nix/store/0"; }; } {
== foo = {
{ foo = { type = "derivation"; outPath = "/nix/store/1"; devious = true; }; }; type = "derivation";
throw "unreachable" outPath = "/nix/store/0";
};
} == {
foo = {
type = "derivation";
outPath = "/nix/store/1";
devious = true;
};
};
throw "unreachable"

View file

@ -3,23 +3,23 @@ error:
at /pwd/lang/eval-fail-assert-equal-derivations.nix:1:1: at /pwd/lang/eval-fail-assert-equal-derivations.nix:1:1:
1| assert 1| assert
| ^ | ^
2| { foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } 2| {
… while comparing attribute 'foo' … while comparing attribute 'foo'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-equal-derivations.nix:2:5: at /pwd/lang/eval-fail-assert-equal-derivations.nix:3:5:
1| assert 2| {
2| { foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } 3| foo = {
| ^ | ^
3| == 4| type = "derivation";
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-equal-derivations.nix:4:5: at /pwd/lang/eval-fail-assert-equal-derivations.nix:9:5:
3| == 8| } == {
4| { foo = { type = "derivation"; outPath = "/nix/store/1"; ignored = abort "not ignored"; }; }; 9| foo = {
| ^ | ^
5| throw "unreachable" 10| type = "derivation";
… while comparing a derivation by its 'outPath' attribute … while comparing a derivation by its 'outPath' attribute

View file

@ -1,5 +1,15 @@
assert assert
{ foo = { type = "derivation"; outPath = "/nix/store/0"; ignored = abort "not ignored"; }; } {
== foo = {
{ foo = { type = "derivation"; outPath = "/nix/store/1"; ignored = abort "not ignored"; }; }; type = "derivation";
throw "unreachable" outPath = "/nix/store/0";
ignored = abort "not ignored";
};
} == {
foo = {
type = "derivation";
outPath = "/nix/store/1";
ignored = abort "not ignored";
};
};
throw "unreachable"

View file

@ -2,8 +2,8 @@ error:
… while evaluating the condition of the assertion '((x: x) == (x: x))' … while evaluating the condition of the assertion '((x: x) == (x: x))'
at /pwd/lang/eval-fail-assert-equal-function-direct.nix:3:1: at /pwd/lang/eval-fail-assert-equal-function-direct.nix:3:1:
2| # This only compares a direct comparison and makes no claims about functions in nested structures. 2| # This only compares a direct comparison and makes no claims about functions in nested structures.
3| assert 3| assert (x: x) == (x: x);
| ^ | ^
4| (x: x) 4| abort "unreachable"
error: distinct functions and immediate comparisons of identical functions compare as unequal error: distinct functions and immediate comparisons of identical functions compare as unequal

View file

@ -1,7 +1,4 @@
# Note: functions in nested structures, e.g. attributes, may be optimized away by pointer identity optimization. # Note: functions in nested structures, e.g. attributes, may be optimized away by pointer identity optimization.
# This only compares a direct comparison and makes no claims about functions in nested structures. # This only compares a direct comparison and makes no claims about functions in nested structures.
assert assert (x: x) == (x: x);
(x: x) abort "unreachable"
==
(x: x);
abort "unreachable"

View file

@ -1,8 +1,8 @@
error: error:
… while evaluating the condition of the assertion '([ (1) (0) ] == [ (10) ])' … while evaluating the condition of the assertion '([ (1) (0) ] == [ (10) ])'
at /pwd/lang/eval-fail-assert-equal-list-length.nix:1:1: at /pwd/lang/eval-fail-assert-equal-list-length.nix:1:1:
1| assert [ 1 0 ] == [ 10 ]; 1| assert
| ^ | ^
2| throw "unreachable" 2| [
error: list of size '2' is not equal to list of size '1', left hand side is '[ 1 0 ]', right hand side is '[ 10 ]' error: list of size '2' is not equal to list of size '1', left hand side is '[ 1 0 ]', right hand side is '[ 10 ]'

View file

@ -1,2 +1,6 @@
assert [ 1 0 ] == [ 10 ]; assert
throw "unreachable" [
1
0
] == [ 10 ];
throw "unreachable"

View file

@ -1,2 +1,2 @@
assert ./foo == ./bar; assert ./foo == ./bar;
throw "unreachable" throw "unreachable"

View file

@ -1,74 +1,66 @@
error: error:
… while evaluating the condition of the assertion '({ a = { b = [ ({ c = { d = true; }; }) ]; }; } == { a = { b = [ ({ c = { d = false; }; }) ]; }; })' … while evaluating the condition of the assertion '({ a = { b = [ ({ c = { d = true; }; }) ]; }; } == { a = { b = [ ({ c = { d = false; }; }) ]; }; })'
at /pwd/lang/eval-fail-assert-nested-bool.nix:1:1: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:1:
1| assert 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
| ^ | ^
2| { a.b = [ { c.d = true; } ]; } 2|
… while comparing attribute 'a' … while comparing attribute 'a'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:2:5: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:10:
1| assert 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
2| { a.b = [ { c.d = true; } ]; } | ^
| ^ 2|
3| ==
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:4:5: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:44:
3| == 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
4| { a.b = [ { c.d = false; } ]; }; | ^
| ^ 2|
5|
… while comparing attribute 'b' … while comparing attribute 'b'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:2:5: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:10:
1| assert 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
2| { a.b = [ { c.d = true; } ]; } | ^
| ^ 2|
3| ==
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:4:5: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:44:
3| == 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
4| { a.b = [ { c.d = false; } ]; }; | ^
| ^ 2|
5|
… while comparing list element 0 … while comparing list element 0
… while comparing attribute 'c' … while comparing attribute 'c'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:2:15: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:20:
1| assert 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
2| { a.b = [ { c.d = true; } ]; } | ^
| ^ 2|
3| ==
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:4:15: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:54:
3| == 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
4| { a.b = [ { c.d = false; } ]; }; | ^
| ^ 2|
5|
… while comparing attribute 'd' … while comparing attribute 'd'
… where left hand side is … where left hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:2:15: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:20:
1| assert 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
2| { a.b = [ { c.d = true; } ]; } | ^
| ^ 2|
3| ==
… where right hand side is … where right hand side is
at /pwd/lang/eval-fail-assert-nested-bool.nix:4:15: at /pwd/lang/eval-fail-assert-nested-bool.nix:1:54:
3| == 1| assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
4| { a.b = [ { c.d = false; } ]; }; | ^
| ^ 2|
5|
error: boolean 'true' is not equal to boolean 'false' error: boolean 'true' is not equal to boolean 'false'

View file

@ -1,6 +1,3 @@
assert assert { a.b = [ { c.d = true; } ]; } == { a.b = [ { c.d = false; } ]; };
{ a.b = [ { c.d = true; } ]; }
==
{ a.b = [ { c.d = false; } ]; };
abort "unreachable" abort "unreachable"

View file

@ -1,30 +1,30 @@
error: error:
… while evaluating the attribute 'body' … while evaluating the attribute 'body'
at /pwd/lang/eval-fail-assert.nix:4:3: at /pwd/lang/eval-fail-assert.nix:7:3:
3| 6|
4| body = x "x"; 7| body = x "x";
| ^ | ^
5| } 8| }
… from call site … from call site
at /pwd/lang/eval-fail-assert.nix:4:10: at /pwd/lang/eval-fail-assert.nix:7:10:
3| 6|
4| body = x "x"; 7| body = x "x";
| ^ | ^
5| } 8| }
… while calling 'x' … while calling 'x'
at /pwd/lang/eval-fail-assert.nix:2:7: at /pwd/lang/eval-fail-assert.nix:3:5:
1| let { 2| x =
2| x = arg: assert arg == "y"; 123; 3| arg:
| ^ | ^
3| 4| assert arg == "y";
… while evaluating the condition of the assertion '(arg == "y")' … while evaluating the condition of the assertion '(arg == "y")'
at /pwd/lang/eval-fail-assert.nix:2:12: at /pwd/lang/eval-fail-assert.nix:4:5:
1| let { 3| arg:
2| x = arg: assert arg == "y"; 123; 4| assert arg == "y";
| ^ | ^
3| 5| 123;
error: string '"x"' is not equal to string '"y"' error: string '"x"' is not equal to string '"y"'

View file

@ -1,5 +1,8 @@
let { let {
x = arg: assert arg == "y"; 123; x =
arg:
assert arg == "y";
123;
body = x "x"; body = x "x";
} }

View file

@ -2,20 +2,20 @@ error:
… while evaluating the attribute 'puppy."${key}"' … while evaluating the attribute 'puppy."${key}"'
at /pwd/lang/eval-fail-attr-name-type.nix:3:5: at /pwd/lang/eval-fail-attr-name-type.nix:3:5:
2| attrs = { 2| attrs = {
3| puppy.doggy = {}; 3| puppy.doggy = { };
| ^ | ^
4| }; 4| };
… while evaluating an attribute name … while evaluating an attribute name
at /pwd/lang/eval-fail-attr-name-type.nix:7:17: at /pwd/lang/eval-fail-attr-name-type.nix:7:15:
6| in 6| in
7| attrs.puppy.${key} 7| attrs.puppy.${key}
| ^ | ^
8| 8|
error: expected a string but found an integer: 1 error: expected a string but found an integer: 1
at /pwd/lang/eval-fail-attr-name-type.nix:7:17: at /pwd/lang/eval-fail-attr-name-type.nix:7:15:
6| in 6| in
7| attrs.puppy.${key} 7| attrs.puppy.${key}
| ^ | ^
8| 8|

View file

@ -1,7 +1,7 @@
let let
attrs = { attrs = {
puppy.doggy = {}; puppy.doggy = { };
}; };
key = 1; key = 1;
in in
attrs.puppy.${key} attrs.puppy.${key}

View file

@ -1,5 +1,6 @@
error: undefined variable 'd' error: undefined variable 'd'
at /pwd/lang/eval-fail-attrset-merge-drops-later-rec.nix:1:26: at /pwd/lang/eval-fail-attrset-merge-drops-later-rec.nix:4:9:
1| { a.b = 1; a = rec { c = d + 2; d = 3; }; }.c 3| a = rec {
| ^ 4| c = d + 2;
2| | ^
5| d = 3;

View file

@ -1 +1,8 @@
{ a.b = 1; a = rec { c = d + 2; d = 3; }; }.c {
a.b = 1;
a = rec {
c = d + 2;
d = 3;
};
}
.c

View file

@ -1,9 +1,9 @@
error: error:
… while evaluating a path segment … while evaluating a path segment
at /pwd/lang/eval-fail-bad-string-interpolation-4.nix:9:3: at /pwd/lang/eval-fail-bad-string-interpolation-4.nix:19:3:
8| # The error message should not be too long. 18| # The error message should not be too long.
9| ''${pkgs}'' 19| ''${pkgs}''
| ^ | ^
10| 20|
error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» } error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «8 attributes elided» }; «8 attributes elided» }; «8 attributes elided» }

View file

@ -1,6 +1,16 @@
let let
# Basically a "billion laughs" attack, but toned down to simulated `pkgs`. # Basically a "billion laughs" attack, but toned down to simulated `pkgs`.
ha = x: y: { a = x y; b = x y; c = x y; d = x y; e = x y; f = x y; g = x y; h = x y; j = x y; }; ha = x: y: {
a = x y;
b = x y;
c = x y;
d = x y;
e = x y;
f = x y;
g = x y;
h = x y;
j = x y;
};
has = ha (ha (ha (ha (x: x)))) "ha"; has = ha (ha (ha (ha (x: x)))) "ha";
# A large structure that has already been evaluated. # A large structure that has already been evaluated.
pkgs = builtins.deepSeq has has; pkgs = builtins.deepSeq has has;

View file

@ -1,17 +1,17 @@
error: error:
… while evaluating the attribute 'outPath' … while evaluating the attribute 'outPath'
at <nix/derivation-internal.nix>:<number>:<number>: at <nix/derivation-internal.nix>:<number>:<number>:
<number>| value = commonAttrs // { <number>| value = commonAttrs // {
<number>| outPath = builtins.getAttr outputName strict; <number>| outPath = builtins.getAttr outputName strict;
| ^ | ^
<number>| drvPath = strict.drvPath; <number>| drvPath = strict.drvPath;
… while calling the 'getAttr' builtin … while calling the 'getAttr' builtin
at <nix/derivation-internal.nix>:<number>:<number>: at <nix/derivation-internal.nix>:<number>:<number>:
<number>| value = commonAttrs // { <number>| value = commonAttrs // {
<number>| outPath = builtins.getAttr outputName strict; <number>| outPath = builtins.getAttr outputName strict;
| ^ | ^
<number>| drvPath = strict.drvPath; <number>| drvPath = strict.drvPath;
… while calling the 'derivationStrict' builtin … while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:<number>:<number>: at <nix/derivation-internal.nix>:<number>:<number>:

View file

@ -2,13 +2,13 @@ error:
… while evaluating the attribute 'set' … while evaluating the attribute 'set'
at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:2:3: at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:2:3:
1| { 1| {
2| set = { "${"" + "b"}" = 1; }; 2| set = {
| ^ | ^
3| set = { "${"b" + ""}" = 2; }; 3| "${"" + "b"}" = 1;
error: dynamic attribute 'b' already defined at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:2:11 error: dynamic attribute 'b' already defined at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:3:5
at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:3:11: at /pwd/lang/eval-fail-dup-dynamic-attrs.nix:6:5:
2| set = { "${"" + "b"}" = 1; }; 5| set = {
3| set = { "${"b" + ""}" = 2; }; 6| "${"b" + ""}" = 2;
| ^ | ^
4| } 7| };

View file

@ -1,4 +1,8 @@
{ {
set = { "${"" + "b"}" = 1; }; set = {
set = { "${"b" + ""}" = 2; }; "${"" + "b"}" = 1;
};
set = {
"${"b" + ""}" = 2;
};
} }

View file

@ -1,51 +1,51 @@
error: error:
… from call site … from call site
at /pwd/lang/eval-fail-duplicate-traces.nix:9:3: at /pwd/lang/eval-fail-duplicate-traces.nix:6:1:
8| in 5| in
9| throwAfter 2 6| throwAfter 2
| ^ | ^
10| 7|
… while calling 'throwAfter' … while calling 'throwAfter'
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
3| let 3| let
4| throwAfter = n: 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
5| if n > 0 5| in
… from call site … from call site
at /pwd/lang/eval-fail-duplicate-traces.nix:6:10: at /pwd/lang/eval-fail-duplicate-traces.nix:4:33:
5| if n > 0 3| let
6| then throwAfter (n - 1) 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
7| else throw "Uh oh!"; 5| in
… while calling 'throwAfter' … while calling 'throwAfter'
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
3| let 3| let
4| throwAfter = n: 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
5| if n > 0 5| in
… from call site … from call site
at /pwd/lang/eval-fail-duplicate-traces.nix:6:10: at /pwd/lang/eval-fail-duplicate-traces.nix:4:33:
5| if n > 0 3| let
6| then throwAfter (n - 1) 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
7| else throw "Uh oh!"; 5| in
… while calling 'throwAfter' … while calling 'throwAfter'
at /pwd/lang/eval-fail-duplicate-traces.nix:4:16: at /pwd/lang/eval-fail-duplicate-traces.nix:4:16:
3| let 3| let
4| throwAfter = n: 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
5| if n > 0 5| in
… while calling the 'throw' builtin … while calling the 'throw' builtin
at /pwd/lang/eval-fail-duplicate-traces.nix:7:10: at /pwd/lang/eval-fail-duplicate-traces.nix:4:57:
6| then throwAfter (n - 1) 3| let
7| else throw "Uh oh!"; 4| throwAfter = n: if n > 0 then throwAfter (n - 1) else throw "Uh oh!";
| ^ | ^
8| in 5| in
error: Uh oh! error: Uh oh!

Some files were not shown because too many files have changed in this diff Show more