forked from lix-project/lix
Format Nix code with nixfmt
Change-Id: I61efeb666ff7481c05fcb247168290e86a250151
This commit is contained in:
parent
b323340538
commit
cfbcf12276
19
default.nix
19
default.nix
|
@ -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
|
|
||||||
|
|
|
@ -5,7 +5,13 @@ in
|
||||||
|
|
||||||
builtinsInfo:
|
builtinsInfo:
|
||||||
let
|
let
|
||||||
showBuiltin = name: { doc, type, impure-only }:
|
showBuiltin =
|
||||||
|
name:
|
||||||
|
{
|
||||||
|
doc,
|
||||||
|
type,
|
||||||
|
impure-only,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
type' = optionalString (type != null) " (${type})";
|
type' = optionalString (type != null) " (${type})";
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,14 @@ in
|
||||||
|
|
||||||
builtinsInfo:
|
builtinsInfo:
|
||||||
let
|
let
|
||||||
showBuiltin = name: { doc, args, arity, experimental-feature }:
|
showBuiltin =
|
||||||
|
name:
|
||||||
|
{
|
||||||
|
doc,
|
||||||
|
args,
|
||||||
|
arity,
|
||||||
|
experimental-feature,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
experimentalNotice = optionalString (experimental-feature != null) ''
|
experimentalNotice = optionalString (experimental-feature != null) ''
|
||||||
This function is only available if the [${experimental-feature}](@docroot@/contributing/experimental-features.md#xp-feature-${experimental-feature}) experimental feature is enabled.
|
This function is only available if the [${experimental-feature}](@docroot@/contributing/experimental-features.md#xp-feature-${experimental-feature}) experimental feature is enabled.
|
||||||
|
|
|
@ -1,8 +1,26 @@
|
||||||
let
|
let
|
||||||
inherit (builtins)
|
inherit (builtins)
|
||||||
attrNames attrValues fromJSON listToAttrs mapAttrs
|
attrNames
|
||||||
concatStringsSep concatMap length lessThan replaceStrings sort;
|
attrValues
|
||||||
inherit (import ./utils.nix) concatStrings optionalString filterAttrs trim squash unique showSettings;
|
fromJSON
|
||||||
|
listToAttrs
|
||||||
|
mapAttrs
|
||||||
|
concatStringsSep
|
||||||
|
concatMap
|
||||||
|
length
|
||||||
|
lessThan
|
||||||
|
replaceStrings
|
||||||
|
sort
|
||||||
|
;
|
||||||
|
inherit (import ./utils.nix)
|
||||||
|
concatStrings
|
||||||
|
optionalString
|
||||||
|
filterAttrs
|
||||||
|
trim
|
||||||
|
squash
|
||||||
|
unique
|
||||||
|
showSettings
|
||||||
|
;
|
||||||
in
|
in
|
||||||
|
|
||||||
inlineHTML: commandDump:
|
inlineHTML: commandDump:
|
||||||
|
@ -11,7 +29,13 @@ let
|
||||||
|
|
||||||
commandInfo = fromJSON commandDump;
|
commandInfo = fromJSON commandDump;
|
||||||
|
|
||||||
showCommand = { command, details, filename, toplevel }:
|
showCommand =
|
||||||
|
{
|
||||||
|
command,
|
||||||
|
details,
|
||||||
|
filename,
|
||||||
|
toplevel,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
result = ''
|
result = ''
|
||||||
|
@ -35,26 +59,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);
|
||||||
|
|
||||||
|
@ -71,11 +96,11 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# TODO: move this confusing special case out of here when implementing #8496
|
# TODO: move this confusing special case out of here when implementing #8496
|
||||||
maybeStoreDocs = optionalString
|
maybeStoreDocs = optionalString (details ? doc) (
|
||||||
(details ? doc)
|
replaceStrings [ "@stores@" ] [ storeDocs ] details.doc
|
||||||
(replaceStrings ["@stores@"] [storeDocs] details.doc);
|
);
|
||||||
|
|
||||||
maybeOptions = optionalString (details.flags != {}) ''
|
maybeOptions = optionalString (details.flags != { }) ''
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
${showOptions details.flags toplevel.flags}
|
${showOptions details.flags toplevel.flags}
|
||||||
|
@ -85,51 +110,70 @@ 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 = options: commonOptions:
|
showOptions =
|
||||||
|
options: commonOptions:
|
||||||
let
|
let
|
||||||
allOptions = options // commonOptions;
|
allOptions = options // commonOptions;
|
||||||
showCategory = cat: ''
|
showCategory = cat: ''
|
||||||
${optionalString (cat != "") "**${cat}:**"}
|
${optionalString (cat != "") "**${cat}:**"}
|
||||||
|
|
||||||
${listOptions (filterAttrs (n: v: v.category == cat) allOptions)}
|
${listOptions (filterAttrs (n: v: v.category == cat) allOptions)}
|
||||||
'';
|
'';
|
||||||
listOptions = opts: concatStringsSep "\n" (attrValues (mapAttrs showOption opts));
|
listOptions = 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 = sort lessThan (unique (map (cmd: cmd.category) (attrValues allOptions)));
|
categories = sort lessThan (unique (map (cmd: cmd.category) (attrValues allOptions)));
|
||||||
in concatStrings (map showCategory categories);
|
in
|
||||||
in squash result;
|
concatStrings (map showCategory categories);
|
||||||
|
in
|
||||||
|
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";
|
||||||
|
@ -138,14 +182,21 @@ 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";
|
||||||
|
|
||||||
storeDocs =
|
storeDocs =
|
||||||
let
|
let
|
||||||
showStore = name: { settings, doc, experimentalFeature }:
|
showStore =
|
||||||
|
name:
|
||||||
|
{
|
||||||
|
settings,
|
||||||
|
doc,
|
||||||
|
experimentalFeature,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
experimentalFeatureNote = optionalString (experimentalFeature != null) ''
|
experimentalFeatureNote = optionalString (experimentalFeature != null) ''
|
||||||
> **Warning**
|
> **Warning**
|
||||||
|
@ -161,7 +212,8 @@ let
|
||||||
extra-experimental-features = ${experimentalFeature}
|
extra-experimental-features = ${experimentalFeature}
|
||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
in ''
|
in
|
||||||
|
''
|
||||||
## ${name}
|
## ${name}
|
||||||
|
|
||||||
${doc}
|
${doc}
|
||||||
|
@ -172,6 +224,7 @@ let
|
||||||
|
|
||||||
${showSettings { inherit inlineHTML; } settings}
|
${showSettings { inherit inlineHTML; } settings}
|
||||||
'';
|
'';
|
||||||
in concatStrings (attrValues (mapAttrs showStore commandInfo.stores));
|
in
|
||||||
|
concatStrings (attrValues (mapAttrs showStore commandInfo.stores));
|
||||||
in (listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; }
|
in
|
||||||
|
(listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; }
|
||||||
|
|
|
@ -2,8 +2,8 @@ with builtins;
|
||||||
with import ./utils.nix;
|
with import ./utils.nix;
|
||||||
|
|
||||||
let
|
let
|
||||||
showExperimentalFeature = name: doc:
|
showExperimentalFeature = name: doc: ''
|
||||||
''
|
- [`${name}`](@docroot@/contributing/experimental-features.md#xp-feature-${name})
|
||||||
- [`${name}`](@docroot@/contributing/experimental-features.md#xp-feature-${name})
|
'';
|
||||||
'';
|
in
|
||||||
in xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps)))
|
xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps)))
|
||||||
|
|
|
@ -2,10 +2,12 @@ with builtins;
|
||||||
with import ./utils.nix;
|
with import ./utils.nix;
|
||||||
|
|
||||||
let
|
let
|
||||||
showExperimentalFeature = name: doc:
|
showExperimentalFeature =
|
||||||
|
name: doc:
|
||||||
squash ''
|
squash ''
|
||||||
## [`${name}`]{#xp-feature-${name}}
|
## [`${name}`]{#xp-feature-${name}}
|
||||||
|
|
||||||
${doc}
|
${doc}
|
||||||
'';
|
'';
|
||||||
in xps: (concatStringsSep "\n" (attrValues (mapAttrs showExperimentalFeature xps)))
|
in
|
||||||
|
xps: (concatStringsSep "\n" (attrValues (mapAttrs showExperimentalFeature xps)))
|
||||||
|
|
|
@ -5,10 +5,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"
|
||||||
|
@ -16,14 +21,16 @@ 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;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -31,76 +38,102 @@ 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 "";
|
||||||
|
|
||||||
showSetting = { inlineHTML }: name: { description, documentDefault, defaultValue, aliases, value, experimentalFeature }:
|
showSetting =
|
||||||
|
{ inlineHTML }:
|
||||||
|
name:
|
||||||
|
{
|
||||||
|
description,
|
||||||
|
documentDefault,
|
||||||
|
defaultValue,
|
||||||
|
aliases,
|
||||||
|
value,
|
||||||
|
experimentalFeature,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
result = squash ''
|
result = squash ''
|
||||||
- ${if inlineHTML
|
- ${
|
||||||
then ''<span id="conf-${name}">[`${name}`](#conf-${name})</span>''
|
if inlineHTML then ''<span id="conf-${name}">[`${name}`](#conf-${name})</span>'' else ''`${name}`''
|
||||||
else ''`${name}`''}
|
}
|
||||||
|
|
||||||
${indent " " body}
|
${indent " " body}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
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@/contributing/experimental-features.md).
|
> [experimental feature](@docroot@/contributing/experimental-features.md).
|
||||||
|
|
||||||
To change this setting, you need to make sure the corresponding experimental feature,
|
To change this setting, you need to make sure the corresponding experimental feature,
|
||||||
[`${experimentalFeature}`](@docroot@/contributing/experimental-features.md#xp-feature-${experimentalFeature}),
|
[`${experimentalFeature}`](@docroot@/contributing/experimental-features.md#xp-feature-${experimentalFeature}),
|
||||||
is enabled.
|
is enabled.
|
||||||
For example, include the following in [`nix.conf`](#):
|
For example, include the following in [`nix.conf`](#):
|
||||||
|
|
||||||
```
|
```
|
||||||
extra-experimental-features = ${experimentalFeature}
|
extra-experimental-features = ${experimentalFeature}
|
||||||
${name} = ...
|
${name} = ...
|
||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# separate body to cleanly handle indentation
|
# separate body to cleanly handle indentation
|
||||||
body = ''
|
body = ''
|
||||||
${description}
|
${description}
|
||||||
|
|
||||||
${experimentalFeatureNote}
|
${experimentalFeatureNote}
|
||||||
|
|
||||||
**Default:** ${showDefault documentDefault defaultValue}
|
**Default:** ${showDefault documentDefault defaultValue}
|
||||||
|
|
||||||
${showAliases aliases}
|
${showAliases aliases}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
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;
|
indent =
|
||||||
|
prefix: s: concatStringsSep "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s));
|
||||||
|
|
||||||
indent = prefix: s:
|
showSettings =
|
||||||
concatStringsSep "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s));
|
args: settingsInfo: concatStrings (attrValues (mapAttrs (showSetting args) settingsInfo));
|
||||||
|
|
||||||
showSettings = args: settingsInfo: concatStrings (attrValues (mapAttrs (showSetting args) settingsInfo));
|
|
||||||
}
|
}
|
||||||
|
|
379
docker.nix
379
docker.nix
|
@ -1,70 +1,71 @@
|
||||||
{ 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 (
|
// lib.listToAttrs (
|
||||||
map
|
map (n: {
|
||||||
(
|
name = "nixbld${toString n}";
|
||||||
n: {
|
value = {
|
||||||
name = "nixbld${toString n}";
|
uid = 30000 + n;
|
||||||
value = {
|
gid = 30000;
|
||||||
uid = 30000 + n;
|
groups = [ "nixbld" ];
|
||||||
gid = 30000;
|
description = "Nix build user ${toString n}";
|
||||||
groups = [ "nixbld" ];
|
};
|
||||||
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 +75,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 +98,28 @@ 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 ++ map (group: { inherit user group; }) groups
|
||||||
acc ++ map
|
) [ ] (lib.attrNames users)
|
||||||
(group: {
|
|
||||||
inherit user group;
|
|
||||||
})
|
|
||||||
groups
|
|
||||||
)
|
|
||||||
[ ]
|
|
||||||
(lib.attrNames users)
|
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
(
|
(builtins.foldl' (
|
||||||
builtins.foldl'
|
acc: v: acc // { ${v.group} = acc.${v.group} or [ ] ++ [ v.user ]; }
|
||||||
(
|
) { } mappings)
|
||||||
acc: v: acc // {
|
|
||||||
${v.group} = acc.${v.group} or [ ] ++ [ v.user ];
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{ }
|
|
||||||
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 +127,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 +156,31 @@ 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}";
|
${
|
||||||
outPath = "${drv}";
|
lib.concatStringsSep "\n" (
|
||||||
system = "${drv.system}";
|
builtins.map (output: ''
|
||||||
type = "derivation";
|
${output} = { outPath = "${lib.getOutput output drv}"; };
|
||||||
meta = { };
|
'') outputs
|
||||||
}
|
)
|
||||||
'') defaultPkgs)}
|
}
|
||||||
|
outputs = [ ${lib.concatStringsSep " " (builtins.map (x: "\"${x}\"") outputs)} ];
|
||||||
|
name = "${drv.name}";
|
||||||
|
outPath = "${drv}";
|
||||||
|
system = "${drv.system}";
|
||||||
|
type = "derivation";
|
||||||
|
meta = { };
|
||||||
|
}
|
||||||
|
''
|
||||||
|
) defaultPkgs
|
||||||
|
)}
|
||||||
]
|
]
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
@ -190,16 +189,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,63 +213,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 $out/nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
|
ln -s $out/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 $out/nix/var/nix/profiles/per-user/root/channels-1-link $out/nix/var/nix/profiles/per-user/root/channels
|
ln -s $out/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 $out/nix/var/nix/profiles/per-user/root/channels $out/root/.nix-defexpr/channels
|
ln -s $out/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"
|
|
||||||
mkdir -p $out$nixCacheDir
|
|
||||||
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
|
||||||
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
|
|
||||||
mkdir -p $out/nix/var/nix/gcroots/auto
|
|
||||||
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
|
|
||||||
''));
|
|
||||||
|
|
||||||
|
''
|
||||||
|
+ (lib.optionalString (flake-registry-path != null) ''
|
||||||
|
nixCacheDir="/root/.cache/nix"
|
||||||
|
mkdir -p $out$nixCacheDir
|
||||||
|
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
||||||
|
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
|
||||||
|
mkdir -p $out/nix/var/nix/gcroots/auto
|
||||||
|
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,20 +293,23 @@ 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"
|
||||||
"NIX_PATH=/nix/var/nix/profiles/per-user/root/channels:/root/.nix-defexpr/channels"
|
"NIX_PATH=/nix/var/nix/profiles/per-user/root/channels:/root/.nix-defexpr/channels"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
579
flake.nix
579
flake.nix
|
@ -12,10 +12,20 @@
|
||||||
nixpkgs-stable.follows = "nixpkgs";
|
nixpkgs-stable.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
flake-compat = {
|
||||||
|
url = "github:edolstra/flake-compat";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nixpkgs-regression, pre-commit-hooks, flake-compat }:
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
nixpkgs-regression,
|
||||||
|
pre-commit-hooks,
|
||||||
|
flake-compat,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
@ -27,73 +37,98 @@
|
||||||
|
|
||||||
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 = [
|
||||||
"armv6l-linux" "armv7l-linux"
|
"armv6l-linux"
|
||||||
"x86_64-freebsd13" "x86_64-netbsd"
|
"armv7l-linux"
|
||||||
|
"x86_64-freebsd13"
|
||||||
|
"x86_64-netbsd"
|
||||||
];
|
];
|
||||||
|
|
||||||
stdenvs = [ "gccStdenv" "clangStdenv" "stdenv" "libcxxStdenv" "ccacheStdenv" ];
|
stdenvs = [
|
||||||
|
"gccStdenv"
|
||||||
|
"clangStdenv"
|
||||||
|
"stdenv"
|
||||||
|
"libcxxStdenv"
|
||||||
|
"ccacheStdenv"
|
||||||
|
];
|
||||||
|
|
||||||
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);
|
);
|
||||||
|
|
||||||
# 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 {
|
||||||
crossSystem = if crossSystem == null then null else {
|
localSystem = {
|
||||||
system = crossSystem;
|
inherit system;
|
||||||
} // lib.optionalAttrs (crossSystem == "x86_64-freebsd13") {
|
};
|
||||||
useLLVM = true;
|
crossSystem =
|
||||||
};
|
if crossSystem == null then
|
||||||
overlays = [
|
null
|
||||||
(overlayFor (p: p.${stdenv}))
|
else
|
||||||
(final: prev: {
|
{
|
||||||
nixfmt = final.callPackage ./nix-support/nixfmt.nix {};
|
system = crossSystem;
|
||||||
})
|
}
|
||||||
];
|
// lib.optionalAttrs (crossSystem == "x86_64-freebsd13") { useLLVM = true; };
|
||||||
|
overlays = [
|
||||||
|
(overlayFor (p: p.${stdenv}))
|
||||||
|
(final: prev: { nixfmt = final.callPackage ./nix-support/nixfmt.nix { }; })
|
||||||
|
];
|
||||||
|
|
||||||
config.permittedInsecurePackages = [ "nix-2.13.6" ];
|
config.permittedInsecurePackages = [ "nix-2.13.6" ];
|
||||||
};
|
};
|
||||||
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:
|
binaryTarball =
|
||||||
|
nix: pkgs:
|
||||||
let
|
let
|
||||||
inherit (pkgs) buildPackages;
|
inherit (pkgs) buildPackages;
|
||||||
installerClosureInfo = buildPackages.closureInfo { rootPaths = [ nix ]; };
|
installerClosureInfo = buildPackages.closureInfo { rootPaths = [ nix ]; };
|
||||||
in
|
in
|
||||||
|
|
||||||
buildPackages.runCommand "nix-binary-tarball-${version}"
|
buildPackages.runCommand "nix-binary-tarball-${version}"
|
||||||
{ #nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck;
|
{
|
||||||
|
#nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck;
|
||||||
meta.description = "Distribution-independent Nix bootstrap binaries for ${pkgs.system}";
|
meta.description = "Distribution-independent Nix bootstrap binaries for ${pkgs.system}";
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
|
@ -114,17 +149,18 @@
|
||||||
$(cat ${installerClosureInfo}/store-paths)
|
$(cat ${installerClosureInfo}/store-paths)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
overlayFor = getStdenv: final: prev:
|
overlayFor =
|
||||||
|
getStdenv: final: prev:
|
||||||
let
|
let
|
||||||
currentStdenv = getStdenv final;
|
currentStdenv = getStdenv final;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
nixStable = prev.nix;
|
nixStable = prev.nix;
|
||||||
|
|
||||||
# Forward from the previous stage as we don’t want it to pick the lowdown override
|
# Forward from the previous stage as we don’t want it to pick the lowdown override
|
||||||
nixUnstable = prev.nixUnstable;
|
nixUnstable = prev.nixUnstable;
|
||||||
|
|
||||||
build-release-notes =
|
build-release-notes = final.buildPackages.callPackage ./maintainers/build-release-notes.nix { };
|
||||||
final.buildPackages.callPackage ./maintainers/build-release-notes.nix { };
|
|
||||||
clangbuildanalyzer = final.buildPackages.callPackage ./misc/clangbuildanalyzer.nix { };
|
clangbuildanalyzer = final.buildPackages.callPackage ./misc/clangbuildanalyzer.nix { };
|
||||||
|
|
||||||
default-busybox-sandbox-shell = final.busybox.override {
|
default-busybox-sandbox-shell = final.busybox.override {
|
||||||
|
@ -161,8 +197,8 @@
|
||||||
# for consumers of this flake.
|
# for consumers of this flake.
|
||||||
boehmgc-nix = final.nix.boehmgc-nix;
|
boehmgc-nix = final.nix.boehmgc-nix;
|
||||||
};
|
};
|
||||||
|
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);
|
||||||
|
@ -172,58 +208,67 @@
|
||||||
# Binary package for various platforms.
|
# Binary package for various platforms.
|
||||||
build = forAllSystems (system: self.packages.${system}.nix);
|
build = forAllSystems (system: self.packages.${system}.nix);
|
||||||
|
|
||||||
rl-next = forAllSystems (system:
|
rl-next = forAllSystems (
|
||||||
|
system:
|
||||||
let
|
let
|
||||||
rl-next-check = name: dir:
|
rl-next-check =
|
||||||
let pkgs = nixpkgsFor.${system}.native;
|
name: dir:
|
||||||
in pkgs.buildPackages.runCommand "test-${name}-release-notes" { } ''
|
let
|
||||||
LANG=C.UTF-8 ${lib.getExe pkgs.build-release-notes} ${dir} >$out
|
pkgs = nixpkgsFor.${system}.native;
|
||||||
'';
|
in
|
||||||
|
pkgs.buildPackages.runCommand "test-${name}-release-notes" { } ''
|
||||||
|
LANG=C.UTF-8 ${lib.getExe pkgs.build-release-notes} ${dir} >$out
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
user = rl-next-check "rl-next" ./doc/manual/rl-next;
|
user = rl-next-check "rl-next" ./doc/manual/rl-next;
|
||||||
dev = rl-next-check "rl-next-dev" ./doc/manual/rl-next-dev;
|
dev = rl-next-check "rl-next-dev" ./doc/manual/rl-next-dev;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
# FIXME(Qyriad): remove this when the migration to Meson has been completed.
|
# FIXME(Qyriad): remove this when the migration to Meson has been completed.
|
||||||
# NOTE: mesonBuildClang depends on mesonBuild depends on build to avoid OOMs
|
# NOTE: mesonBuildClang depends on mesonBuild depends on build to avoid OOMs
|
||||||
# on aarch64 builders caused by too many parallel compiler/linker processes.
|
# on aarch64 builders caused by too many parallel compiler/linker processes.
|
||||||
mesonBuild = forAllSystems (system:
|
mesonBuild = forAllSystems (
|
||||||
(self.packages.${system}.nix.override {
|
system:
|
||||||
buildWithMeson = true;
|
(self.packages.${system}.nix.override { buildWithMeson = true; }).overrideAttrs (prev: {
|
||||||
}).overrideAttrs (prev: {
|
|
||||||
buildInputs = prev.buildInputs ++ [ self.packages.${system}.nix ];
|
buildInputs = prev.buildInputs ++ [ self.packages.${system}.nix ];
|
||||||
}));
|
|
||||||
mesonBuildClang = forAllSystems (system:
|
|
||||||
(nixpkgsFor.${system}.stdenvs.clangStdenvPackages.nix.override {
|
|
||||||
buildWithMeson = true;
|
|
||||||
}).overrideAttrs (prev: {
|
|
||||||
buildInputs = prev.buildInputs ++ [ self.hydraJobs.mesonBuild.${system} ];
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
mesonBuildClang = forAllSystems (
|
||||||
|
system:
|
||||||
|
(nixpkgsFor.${system}.stdenvs.clangStdenvPackages.nix.override { buildWithMeson = true; })
|
||||||
|
.overrideAttrs
|
||||||
|
(prev: {
|
||||||
|
buildInputs = prev.buildInputs ++ [ self.hydraJobs.mesonBuild.${system} ];
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
# Perl bindings for various platforms.
|
# Perl bindings for various platforms.
|
||||||
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix.perl-bindings);
|
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix.perl-bindings);
|
||||||
|
|
||||||
# Binary tarball for various platforms, containing a Nix store
|
# Binary tarball for various platforms, containing a Nix store
|
||||||
# with the closure of 'nix' package.
|
# with the closure of 'nix' package.
|
||||||
binaryTarball = forAllSystems (system: binaryTarball nixpkgsFor.${system}.native.nix nixpkgsFor.${system}.native);
|
binaryTarball = forAllSystems (
|
||||||
|
system: binaryTarball nixpkgsFor.${system}.native.nix nixpkgsFor.${system}.native
|
||||||
|
);
|
||||||
|
|
||||||
# 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);
|
||||||
|
|
||||||
# API docs for Nix's unstable internal C++ interfaces.
|
# API docs for Nix's unstable internal C++ interfaces.
|
||||||
internal-api-docs = let
|
internal-api-docs =
|
||||||
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
let
|
||||||
inherit (nixpkgs) pkgs;
|
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||||
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
||||||
nix = pkgs.callPackage ./package.nix {
|
nix = pkgs.callPackage ./package.nix {
|
||||||
inherit versionSuffix officialRelease buildUnreleasedNotes;
|
inherit versionSuffix officialRelease buildUnreleasedNotes;
|
||||||
inherit (pkgs) build-release-notes;
|
inherit (pkgs) build-release-notes;
|
||||||
internalApiDocs = true;
|
internalApiDocs = true;
|
||||||
busybox-sandbox-shell = pkgs.busybox-sandbox-shell;
|
busybox-sandbox-shell = pkgs.busybox-sandbox-shell;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
nix.overrideAttrs (prev: {
|
nix.overrideAttrs (prev: {
|
||||||
# This Hydra job is just for the internal API docs.
|
# This Hydra job is just for the internal API docs.
|
||||||
# We don't need the build artifacts here.
|
# We don't need the build artifacts here.
|
||||||
|
@ -239,195 +284,237 @@
|
||||||
# on a particular version of Nixpkgs.
|
# on a particular version of Nixpkgs.
|
||||||
evalNixpkgs =
|
evalNixpkgs =
|
||||||
with nixpkgsFor.x86_64-linux.native;
|
with nixpkgsFor.x86_64-linux.native;
|
||||||
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.
|
time nix-env --store dummy:// -f ${nixpkgs-regression} -qaP --drv-path | sort | grep -v nixos-install-tools > packages
|
||||||
time nix-env --store dummy:// -f ${nixpkgs-regression} -qaP --drv-path | sort | grep -v nixos-install-tools > packages
|
[[ $(sha1sum < packages | cut -c1-40) = 402242fca90874112b34718b8199d844e8b03d12 ]]
|
||||||
[[ $(sha1sum < packages | cut -c1-40) = 402242fca90874112b34718b8199d844e8b03d12 ]]
|
mkdir $out
|
||||||
mkdir $out
|
'';
|
||||||
'';
|
|
||||||
|
|
||||||
nixpkgsLibTests =
|
nixpkgsLibTests = forAllSystems (
|
||||||
forAllSystems (system:
|
system:
|
||||||
import (nixpkgs + "/lib/tests/release.nix")
|
import (nixpkgs + "/lib/tests/release.nix") {
|
||||||
{ pkgs = nixpkgsFor.${system}.native;
|
pkgs = nixpkgsFor.${system}.native;
|
||||||
nixVersions = [ self.packages.${system}.nix ];
|
nixVersions = [ self.packages.${system}.nix ];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
pre-commit = builtins.mapAttrs (system: pre-commit-lib: pre-commit-lib.run {
|
pre-commit = builtins.mapAttrs (
|
||||||
src = self;
|
system: pre-commit-lib:
|
||||||
hooks = {
|
pre-commit-lib.run {
|
||||||
no-commit-to-branch = {
|
src = self;
|
||||||
enable = true;
|
hooks = {
|
||||||
settings.branch = ["main"];
|
no-commit-to-branch = {
|
||||||
|
enable = true;
|
||||||
|
settings.branch = [ "main" ];
|
||||||
|
};
|
||||||
|
check-case-conflicts.enable = true;
|
||||||
|
check-executables-have-shebangs = {
|
||||||
|
enable = true;
|
||||||
|
stages = [ "commit" ];
|
||||||
|
};
|
||||||
|
check-shebang-scripts-are-executable = {
|
||||||
|
enable = true;
|
||||||
|
stages = [ "commit" ];
|
||||||
|
};
|
||||||
|
check-symlinks = {
|
||||||
|
enable = true;
|
||||||
|
excludes = [ "^tests/functional/lang/symlink-resolution/broken$" ];
|
||||||
|
};
|
||||||
|
check-merge-conflicts.enable = true;
|
||||||
|
end-of-file-fixer = {
|
||||||
|
enable = true;
|
||||||
|
excludes = [
|
||||||
|
"\\.drv$"
|
||||||
|
"^tests/functional/lang/"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
mixed-line-endings = {
|
||||||
|
enable = true;
|
||||||
|
excludes = [ "^tests/functional/lang/" ];
|
||||||
|
};
|
||||||
|
# TODO: Once the test suite is nicer, clean up and start
|
||||||
|
# enforcing trailing whitespace on tests that don't explicitly
|
||||||
|
# check for it.
|
||||||
|
trim-trailing-whitespace = {
|
||||||
|
enable = true;
|
||||||
|
stages = [ "commit" ];
|
||||||
|
excludes = [ "^tests/functional/lang/" ];
|
||||||
|
};
|
||||||
|
treefmt = {
|
||||||
|
enable = true;
|
||||||
|
settings.formatters =
|
||||||
|
let
|
||||||
|
pkgs = nixpkgsFor.${system}.native;
|
||||||
|
in
|
||||||
|
[ pkgs.nixfmt ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
check-case-conflicts.enable = true;
|
}
|
||||||
check-executables-have-shebangs = {
|
) pre-commit-hooks.lib;
|
||||||
enable = true;
|
|
||||||
stages = [ "commit" ];
|
|
||||||
};
|
|
||||||
check-shebang-scripts-are-executable = {
|
|
||||||
enable = true;
|
|
||||||
stages = [ "commit" ];
|
|
||||||
};
|
|
||||||
check-symlinks = {
|
|
||||||
enable = true;
|
|
||||||
excludes = [ "^tests/functional/lang/symlink-resolution/broken$" ];
|
|
||||||
};
|
|
||||||
check-merge-conflicts.enable = true;
|
|
||||||
end-of-file-fixer = {
|
|
||||||
enable = true;
|
|
||||||
excludes = [
|
|
||||||
"\\.drv$"
|
|
||||||
"^tests/functional/lang/"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
mixed-line-endings = {
|
|
||||||
enable = true;
|
|
||||||
excludes = [ "^tests/functional/lang/" ];
|
|
||||||
};
|
|
||||||
# TODO: Once the test suite is nicer, clean up and start
|
|
||||||
# enforcing trailing whitespace on tests that don't explicitly
|
|
||||||
# check for it.
|
|
||||||
trim-trailing-whitespace = {
|
|
||||||
enable = true;
|
|
||||||
stages = [ "commit" ];
|
|
||||||
excludes = [ "^tests/functional/lang/" ];
|
|
||||||
};
|
|
||||||
treefmt = {
|
|
||||||
enable = true;
|
|
||||||
settings.formatters =
|
|
||||||
let
|
|
||||||
pkgs = nixpkgsFor.${system}.native;
|
|
||||||
in
|
|
||||||
[ pkgs.nixfmt ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}) pre-commit-hooks.lib;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# NOTE *do not* add fresh derivations to checks, always add them to
|
# NOTE *do not* add fresh derivations to checks, always add them to
|
||||||
# hydraJobs first (so CI will pick them up) and only link them here
|
# hydraJobs first (so CI will pick them up) and only link them here
|
||||||
checks = forAllSystems (system: {
|
checks = forAllSystems (
|
||||||
# FIXME(Qyriad): remove this when the migration to Meson has been completed.
|
system:
|
||||||
mesonBuild = self.hydraJobs.mesonBuild.${system};
|
{
|
||||||
mesonBuildClang = self.hydraJobs.mesonBuildClang.${system};
|
# FIXME(Qyriad): remove this when the migration to Meson has been completed.
|
||||||
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
mesonBuild = self.hydraJobs.mesonBuild.${system};
|
||||||
perlBindings = self.hydraJobs.perlBindings.${system};
|
mesonBuildClang = self.hydraJobs.mesonBuildClang.${system};
|
||||||
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
|
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
||||||
rl-next = self.hydraJobs.rl-next.${system}.user;
|
perlBindings = self.hydraJobs.perlBindings.${system};
|
||||||
rl-next-dev = self.hydraJobs.rl-next.${system}.dev;
|
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
|
||||||
pre-commit = self.hydraJobs.pre-commit.${system};
|
rl-next = self.hydraJobs.rl-next.${system}.user;
|
||||||
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
rl-next-dev = self.hydraJobs.rl-next.${system}.dev;
|
||||||
dockerImage = self.hydraJobs.dockerImage.${system};
|
pre-commit = self.hydraJobs.pre-commit.${system};
|
||||||
});
|
}
|
||||||
|
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
||||||
|
dockerImage = self.hydraJobs.dockerImage.${system};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
packages = forAllSystems (system: rec {
|
packages = forAllSystems (
|
||||||
inherit (nixpkgsFor.${system}.native) nix;
|
system:
|
||||||
default = nix;
|
rec {
|
||||||
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
inherit (nixpkgsFor.${system}.native) nix;
|
||||||
nix-static = nixpkgsFor.${system}.static.nix;
|
default = nix;
|
||||||
dockerImage =
|
}
|
||||||
let
|
// (
|
||||||
pkgs = nixpkgsFor.${system}.native;
|
lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||||
image = import ./docker.nix { inherit pkgs; tag = version; };
|
nix-static = nixpkgsFor.${system}.static.nix;
|
||||||
in
|
dockerImage =
|
||||||
pkgs.runCommand
|
let
|
||||||
"docker-image-tarball-${version}"
|
pkgs = nixpkgsFor.${system}.native;
|
||||||
{ meta.description = "Docker image with Nix for ${system}"; }
|
image = import ./docker.nix {
|
||||||
''
|
inherit pkgs;
|
||||||
mkdir -p $out/nix-support
|
tag = version;
|
||||||
image=$out/image.tar.gz
|
};
|
||||||
ln -s ${image} $image
|
in
|
||||||
echo "file binary-dist $image" >> $out/nix-support/hydra-build-products
|
pkgs.runCommand "docker-image-tarball-${version}"
|
||||||
'';
|
{ meta.description = "Docker image with Nix for ${system}"; }
|
||||||
} // builtins.listToAttrs (map
|
''
|
||||||
(crossSystem: {
|
mkdir -p $out/nix-support
|
||||||
name = "nix-${crossSystem}";
|
image=$out/image.tar.gz
|
||||||
value = nixpkgsFor.${system}.cross.${crossSystem}.nix;
|
ln -s ${image} $image
|
||||||
})
|
echo "file binary-dist $image" >> $out/nix-support/hydra-build-products
|
||||||
crossSystems)
|
'';
|
||||||
// builtins.listToAttrs (map
|
}
|
||||||
(stdenvName: {
|
// builtins.listToAttrs (
|
||||||
name = "nix-${stdenvName}";
|
map (crossSystem: {
|
||||||
value = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nix;
|
name = "nix-${crossSystem}";
|
||||||
})
|
value = nixpkgsFor.${system}.cross.${crossSystem}.nix;
|
||||||
stdenvs)));
|
}) crossSystems
|
||||||
|
)
|
||||||
|
// builtins.listToAttrs (
|
||||||
|
map (stdenvName: {
|
||||||
|
name = "nix-${stdenvName}";
|
||||||
|
value = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nix;
|
||||||
|
}) stdenvs
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
devShells = let
|
devShells =
|
||||||
makeShell = pkgs: stdenv:
|
let
|
||||||
let
|
makeShell =
|
||||||
nix = pkgs.callPackage ./package.nix {
|
pkgs: stdenv:
|
||||||
inherit stdenv versionSuffix;
|
let
|
||||||
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox;
|
nix = pkgs.callPackage ./package.nix {
|
||||||
forDevShell = true;
|
inherit stdenv versionSuffix;
|
||||||
};
|
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox;
|
||||||
pre-commit = self.hydraJobs.pre-commit.${pkgs.system} or {};
|
forDevShell = true;
|
||||||
in
|
};
|
||||||
|
pre-commit = self.hydraJobs.pre-commit.${pkgs.system} or { };
|
||||||
|
in
|
||||||
(nix.override {
|
(nix.override {
|
||||||
buildUnreleasedNotes = true;
|
buildUnreleasedNotes = true;
|
||||||
officialRelease = false;
|
officialRelease = false;
|
||||||
}).overrideAttrs (prev: {
|
}).overrideAttrs
|
||||||
# Required for clang-tidy checks
|
(
|
||||||
buildInputs = prev.buildInputs
|
prev:
|
||||||
++ [ pkgs.just pkgs.nixfmt ]
|
{
|
||||||
++ lib.optional (pre-commit ? enabledPackages) pre-commit.enabledPackages
|
# Required for clang-tidy checks
|
||||||
++ lib.optionals (stdenv.cc.isClang) [ pkgs.llvmPackages.llvm pkgs.llvmPackages.clang-unwrapped.dev ];
|
buildInputs =
|
||||||
nativeBuildInputs = prev.nativeBuildInputs
|
prev.buildInputs
|
||||||
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
|
++ [
|
||||||
# Required for clang-tidy checks
|
pkgs.just
|
||||||
++ lib.optionals (stdenv.cc.isClang) [ pkgs.buildPackages.cmake pkgs.buildPackages.ninja pkgs.buildPackages.llvmPackages.llvm.dev ]
|
pkgs.nixfmt
|
||||||
++ lib.optional
|
]
|
||||||
(stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
|
++ lib.optional (pre-commit ? enabledPackages) pre-commit.enabledPackages
|
||||||
# for some reason that seems accidental and was changed in
|
++ lib.optionals (stdenv.cc.isClang) [
|
||||||
# NixOS 24.05-pre, clang-tools is pinned to LLVM 14 when
|
pkgs.llvmPackages.llvm
|
||||||
# default LLVM is newer.
|
pkgs.llvmPackages.clang-unwrapped.dev
|
||||||
(pkgs.buildPackages.clang-tools.override { inherit (pkgs.buildPackages) llvmPackages; })
|
];
|
||||||
++ [
|
nativeBuildInputs =
|
||||||
# FIXME(Qyriad): remove once the migration to Meson is complete.
|
prev.nativeBuildInputs
|
||||||
pkgs.buildPackages.meson
|
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
|
||||||
pkgs.buildPackages.ninja
|
# Required for clang-tidy checks
|
||||||
pkgs.buildPackages.cmake
|
++ lib.optionals (stdenv.cc.isClang) [
|
||||||
|
pkgs.buildPackages.cmake
|
||||||
|
pkgs.buildPackages.ninja
|
||||||
|
pkgs.buildPackages.llvmPackages.llvm.dev
|
||||||
|
]
|
||||||
|
++
|
||||||
|
lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
|
||||||
|
# for some reason that seems accidental and was changed in
|
||||||
|
# NixOS 24.05-pre, clang-tools is pinned to LLVM 14 when
|
||||||
|
# default LLVM is newer.
|
||||||
|
(pkgs.buildPackages.clang-tools.override { inherit (pkgs.buildPackages) llvmPackages; })
|
||||||
|
++ [
|
||||||
|
# FIXME(Qyriad): remove once the migration to Meson is complete.
|
||||||
|
pkgs.buildPackages.meson
|
||||||
|
pkgs.buildPackages.ninja
|
||||||
|
pkgs.buildPackages.cmake
|
||||||
|
|
||||||
pkgs.buildPackages.clangbuildanalyzer
|
pkgs.buildPackages.clangbuildanalyzer
|
||||||
];
|
];
|
||||||
|
|
||||||
src = null;
|
src = null;
|
||||||
|
|
||||||
installFlags = "sysconfdir=$(out)/etc";
|
installFlags = "sysconfdir=$(out)/etc";
|
||||||
strictDeps = false;
|
strictDeps = false;
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
PATH=$prefix/bin:$PATH
|
PATH=$prefix/bin:$PATH
|
||||||
unset PYTHONPATH
|
unset PYTHONPATH
|
||||||
export MANPATH=$out/share/man:$MANPATH
|
export MANPATH=$out/share/man:$MANPATH
|
||||||
|
|
||||||
# Make bash completion work.
|
# Make bash completion work.
|
||||||
XDG_DATA_DIRS+=:$out/share
|
XDG_DATA_DIRS+=:$out/share
|
||||||
|
|
||||||
${lib.optionalString (pre-commit ? shellHook) pre-commit.shellHook}
|
${lib.optionalString (pre-commit ? shellHook) pre-commit.shellHook}
|
||||||
'';
|
'';
|
||||||
} // lib.optionalAttrs (stdenv.buildPlatform.isLinux && pkgs.glibcLocales != null) {
|
}
|
||||||
# Required to make non-NixOS Linux not complain about missing locale files during configure in a dev shell
|
// lib.optionalAttrs (stdenv.buildPlatform.isLinux && pkgs.glibcLocales != null) {
|
||||||
LOCALE_ARCHIVE = "${lib.getLib pkgs.glibcLocales}/lib/locale/locale-archive";
|
# Required to make non-NixOS Linux not complain about missing locale files during configure in a dev shell
|
||||||
});
|
LOCALE_ARCHIVE = "${lib.getLib pkgs.glibcLocales}/lib/locale/locale-archive";
|
||||||
|
}
|
||||||
|
);
|
||||||
in
|
in
|
||||||
forAllSystems (system:
|
forAllSystems (
|
||||||
|
system:
|
||||||
let
|
let
|
||||||
makeShells = prefix: pkgs:
|
makeShells =
|
||||||
lib.mapAttrs'
|
prefix: pkgs:
|
||||||
(k: v: lib.nameValuePair "${prefix}-${k}" v)
|
lib.mapAttrs' (k: v: lib.nameValuePair "${prefix}-${k}" v) (
|
||||||
(forAllStdenvs (stdenvName: makeShell pkgs pkgs.${stdenvName}));
|
forAllStdenvs (stdenvName: makeShell pkgs pkgs.${stdenvName})
|
||||||
|
);
|
||||||
in
|
in
|
||||||
(makeShells "native" nixpkgsFor.${system}.native) //
|
(makeShells "native" nixpkgsFor.${system}.native)
|
||||||
(makeShells "static" nixpkgsFor.${system}.static) //
|
// (makeShells "static" nixpkgsFor.${system}.static)
|
||||||
(forAllCrossSystems (crossSystem: let pkgs = nixpkgsFor.${system}.cross.${crossSystem}; in makeShell pkgs pkgs.stdenv)) //
|
// (forAllCrossSystems (
|
||||||
{
|
crossSystem:
|
||||||
default = self.devShells.${system}.native-stdenvPackages;
|
let
|
||||||
}
|
pkgs = nixpkgsFor.${system}.cross.${crossSystem};
|
||||||
|
in
|
||||||
|
makeShell pkgs pkgs.stdenv
|
||||||
|
))
|
||||||
|
// {
|
||||||
|
default = self.devShells.${system}.native-stdenvPackages;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
{
|
{ rustPlatform, lib }:
|
||||||
rustPlatform,
|
|
||||||
lib
|
|
||||||
}:
|
|
||||||
|
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
name = "lix-doc";
|
name = "lix-doc";
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{ lib, python3, writeShellScriptBin }:
|
{
|
||||||
|
lib,
|
||||||
|
python3,
|
||||||
|
writeShellScriptBin,
|
||||||
|
}:
|
||||||
|
|
||||||
writeShellScriptBin "build-release-notes" ''
|
writeShellScriptBin "build-release-notes" ''
|
||||||
exec ${lib.getExe (python3.withPackages (p: [ p.python-frontmatter ]))} \
|
exec ${lib.getExe (python3.withPackages (p: [ p.python-frontmatter ]))} \
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# Upstreaming here, can be deleted once it's upstreamed:
|
# Upstreaming here, can be deleted once it's upstreamed:
|
||||||
# https://github.com/NixOS/nixpkgs/pull/297102
|
# https://github.com/NixOS/nixpkgs/pull/297102
|
||||||
{ stdenv, lib, cmake, fetchFromGitHub }:
|
{
|
||||||
|
stdenv,
|
||||||
|
lib,
|
||||||
|
cmake,
|
||||||
|
fetchFromGitHub,
|
||||||
|
}:
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "clangbuildanalyzer";
|
pname = "clangbuildanalyzer";
|
||||||
version = "1.5.0";
|
version = "1.5.0";
|
||||||
|
@ -12,9 +17,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
sha256 = "sha256-kmgdk634zM0W0OoRoP/RzepArSipa5bNqdVgdZO9gxo=";
|
sha256 = "sha256-kmgdk634zM0W0OoRoP/RzepArSipa5bNqdVgdZO9gxo=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ cmake ];
|
||||||
cmake
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Tool for analyzing Clang's -ftrace-time files";
|
description = "Tool for analyzing Clang's -ftrace-time files";
|
||||||
|
|
294
package.nix
294
package.nix
|
@ -69,9 +69,7 @@
|
||||||
__forDefaults ? {
|
__forDefaults ? {
|
||||||
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||||
|
|
||||||
boehmgc-nix = (boehmgc.override {
|
boehmgc-nix = (boehmgc.override { enableLargeConfig = true; }).overrideAttrs {
|
||||||
enableLargeConfig = true;
|
|
||||||
}).overrideAttrs {
|
|
||||||
patches = [
|
patches = [
|
||||||
# We do *not* include prev.patches (which doesn't exist in normal pkgs.boehmgc anyway)
|
# We do *not* include prev.patches (which doesn't exist in normal pkgs.boehmgc anyway)
|
||||||
# because if the caller of this package passed a patched boehm as `boehmgc` instead of
|
# because if the caller of this package passed a patched boehm as `boehmgc` instead of
|
||||||
|
@ -85,20 +83,22 @@
|
||||||
|
|
||||||
lix-doc = pkgs.callPackage ./lix-doc/package.nix { };
|
lix-doc = pkgs.callPackage ./lix-doc/package.nix { };
|
||||||
},
|
},
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
inherit (__forDefaults) canRunInstalled;
|
inherit (__forDefaults) canRunInstalled;
|
||||||
inherit (lib) fileset;
|
inherit (lib) fileset;
|
||||||
|
|
||||||
version = lib.fileContents ./.version + versionSuffix;
|
version = lib.fileContents ./.version + versionSuffix;
|
||||||
|
|
||||||
aws-sdk-cpp-nix = aws-sdk-cpp.override {
|
aws-sdk-cpp-nix = aws-sdk-cpp.override {
|
||||||
apis = [ "s3" "transfer" ];
|
apis = [
|
||||||
|
"s3"
|
||||||
|
"transfer"
|
||||||
|
];
|
||||||
customMemoryManagement = false;
|
customMemoryManagement = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
testConfigureFlags = [
|
testConfigureFlags = [ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ];
|
||||||
"RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"
|
|
||||||
];
|
|
||||||
|
|
||||||
# The internal API docs need these for the build, but if we're not building
|
# The internal API docs need these for the build, but if we're not building
|
||||||
# Nix itself, then these don't need to be propagated.
|
# Nix itself, then these don't need to be propagated.
|
||||||
|
@ -120,48 +120,60 @@
|
||||||
./README.md
|
./README.md
|
||||||
];
|
];
|
||||||
|
|
||||||
topLevelBuildFiles = fileset.unions ([
|
topLevelBuildFiles = fileset.unions (
|
||||||
./local.mk
|
[
|
||||||
./Makefile
|
./local.mk
|
||||||
./Makefile.config.in
|
./Makefile
|
||||||
./mk
|
./Makefile.config.in
|
||||||
] ++ lib.optionals buildWithMeson [
|
./mk
|
||||||
./meson.build
|
]
|
||||||
./meson.options
|
++ lib.optionals buildWithMeson [
|
||||||
./meson
|
./meson.build
|
||||||
./scripts/meson.build
|
./meson.options
|
||||||
]);
|
./meson
|
||||||
|
./scripts/meson.build
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
functionalTestFiles = fileset.unions [
|
functionalTestFiles = fileset.unions [
|
||||||
./tests/functional
|
./tests/functional
|
||||||
./tests/unit
|
./tests/unit
|
||||||
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
|
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
|
||||||
];
|
];
|
||||||
|
in
|
||||||
in stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
|
|
||||||
src = fileset.toSource {
|
src = fileset.toSource {
|
||||||
root = ./.;
|
root = ./.;
|
||||||
fileset = fileset.intersection baseFiles (fileset.unions ([
|
fileset = fileset.intersection baseFiles (
|
||||||
configureFiles
|
fileset.unions (
|
||||||
topLevelBuildFiles
|
[
|
||||||
functionalTestFiles
|
configureFiles
|
||||||
] ++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [
|
topLevelBuildFiles
|
||||||
./boehmgc-coroutine-sp-fallback.diff
|
functionalTestFiles
|
||||||
./doc
|
]
|
||||||
./misc
|
++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [
|
||||||
./precompiled-headers.h
|
./boehmgc-coroutine-sp-fallback.diff
|
||||||
./src
|
./doc
|
||||||
./COPYING
|
./misc
|
||||||
./scripts/local.mk
|
./precompiled-headers.h
|
||||||
]));
|
./src
|
||||||
|
./COPYING
|
||||||
|
./scripts/local.mk
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
VERSION_SUFFIX = versionSuffix;
|
VERSION_SUFFIX = versionSuffix;
|
||||||
|
|
||||||
outputs = [ "out" ]
|
outputs =
|
||||||
++ lib.optionals (!finalAttrs.dontBuild) [ "dev" "doc" ];
|
[ "out" ]
|
||||||
|
++ lib.optionals (!finalAttrs.dontBuild) [
|
||||||
|
"dev"
|
||||||
|
"doc"
|
||||||
|
];
|
||||||
|
|
||||||
dontBuild = false;
|
dontBuild = false;
|
||||||
|
|
||||||
|
@ -173,53 +185,61 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
# We only include CMake so that Meson can locate toml11, which only ships CMake dependency metadata.
|
# We only include CMake so that Meson can locate toml11, which only ships CMake dependency metadata.
|
||||||
dontUseCmakeConfigure = true;
|
dontUseCmakeConfigure = true;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs =
|
||||||
bison
|
[
|
||||||
flex
|
bison
|
||||||
python3
|
flex
|
||||||
] ++ [
|
python3
|
||||||
(lib.getBin lowdown)
|
]
|
||||||
mdbook
|
++ [
|
||||||
mdbook-linkcheck
|
(lib.getBin lowdown)
|
||||||
autoconf-archive
|
mdbook
|
||||||
] ++ lib.optional (!buildWithMeson) autoreconfHook ++ [
|
mdbook-linkcheck
|
||||||
pkg-config
|
autoconf-archive
|
||||||
|
]
|
||||||
|
++ lib.optional (!buildWithMeson) autoreconfHook
|
||||||
|
++ [
|
||||||
|
pkg-config
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
git
|
git
|
||||||
mercurial
|
mercurial
|
||||||
jq
|
jq
|
||||||
lsof
|
lsof
|
||||||
] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal
|
]
|
||||||
|
++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal
|
||||||
++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes
|
++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes
|
||||||
++ lib.optional internalApiDocs doxygen
|
++ lib.optional internalApiDocs doxygen
|
||||||
++ lib.optionals buildWithMeson [
|
++ lib.optionals buildWithMeson [
|
||||||
meson
|
meson
|
||||||
ninja
|
ninja
|
||||||
cmake
|
cmake
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs =
|
||||||
curl
|
[
|
||||||
bzip2
|
curl
|
||||||
xz
|
bzip2
|
||||||
brotli
|
xz
|
||||||
editline
|
brotli
|
||||||
openssl
|
editline
|
||||||
sqlite
|
openssl
|
||||||
libarchive
|
sqlite
|
||||||
boost
|
libarchive
|
||||||
lowdown
|
boost
|
||||||
libsodium
|
lowdown
|
||||||
toml11
|
libsodium
|
||||||
lix-doc
|
toml11
|
||||||
]
|
lix-doc
|
||||||
++ lib.optionals stdenv.hostPlatform.isLinux [ libseccomp busybox-sandbox-shell ]
|
]
|
||||||
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||||
|
libseccomp
|
||||||
|
busybox-sandbox-shell
|
||||||
|
]
|
||||||
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
|
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
|
||||||
# There have been issues building these dependencies
|
# There have been issues building these dependencies
|
||||||
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix
|
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix
|
||||||
++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs
|
++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs;
|
||||||
;
|
|
||||||
|
|
||||||
checkInputs = [
|
checkInputs = [
|
||||||
gtest
|
gtest
|
||||||
|
@ -228,9 +248,7 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs;
|
propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs;
|
||||||
|
|
||||||
disallowedReferences = [
|
disallowedReferences = [ boost ];
|
||||||
boost
|
|
||||||
];
|
|
||||||
|
|
||||||
# Needed for Meson to find Boost.
|
# Needed for Meson to find Boost.
|
||||||
# https://github.com/NixOS/nixpkgs/issues/86131.
|
# https://github.com/NixOS/nixpkgs/issues/86131.
|
||||||
|
@ -239,46 +257,47 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
|
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
|
||||||
};
|
};
|
||||||
|
|
||||||
preConfigure = lib.optionalString (!finalAttrs.dontBuild && !stdenv.hostPlatform.isStatic) ''
|
preConfigure =
|
||||||
# Copy libboost_context so we don't get all of Boost in our closure.
|
lib.optionalString (!finalAttrs.dontBuild && !stdenv.hostPlatform.isStatic) ''
|
||||||
# https://github.com/NixOS/nixpkgs/issues/45462
|
# Copy libboost_context so we don't get all of Boost in our closure.
|
||||||
mkdir -p $out/lib
|
# https://github.com/NixOS/nixpkgs/issues/45462
|
||||||
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
mkdir -p $out/lib
|
||||||
rm -f $out/lib/*.a
|
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
||||||
'' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) ''
|
rm -f $out/lib/*.a
|
||||||
chmod u+w $out/lib/*.so.*
|
''
|
||||||
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
+ lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) ''
|
||||||
'' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) ''
|
chmod u+w $out/lib/*.so.*
|
||||||
for LIB in $out/lib/*.dylib; do
|
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
||||||
chmod u+w $LIB
|
''
|
||||||
install_name_tool -id $LIB $LIB
|
+ lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) ''
|
||||||
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
|
for LIB in $out/lib/*.dylib; do
|
||||||
done
|
chmod u+w $LIB
|
||||||
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
|
install_name_tool -id $LIB $LIB
|
||||||
'' + ''
|
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
|
||||||
# Workaround https://github.com/NixOS/nixpkgs/issues/294890.
|
done
|
||||||
if [[ -n "''${doCheck:-}" ]]; then
|
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
|
||||||
appendToVar configureFlags "--enable-tests"
|
''
|
||||||
else
|
+ ''
|
||||||
appendToVar configureFlags "--disable-tests"
|
# Workaround https://github.com/NixOS/nixpkgs/issues/294890.
|
||||||
fi
|
if [[ -n "''${doCheck:-}" ]]; then
|
||||||
'';
|
appendToVar configureFlags "--enable-tests"
|
||||||
|
else
|
||||||
|
appendToVar configureFlags "--disable-tests"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
configureFlags = [
|
configureFlags =
|
||||||
"--with-boost=${boost}/lib"
|
[ "--with-boost=${boost}/lib" ]
|
||||||
] ++ lib.optionals stdenv.isLinux [
|
++ lib.optionals stdenv.isLinux [ "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox" ]
|
||||||
"--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
|
++ lib.optionals (
|
||||||
] ++ lib.optionals (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) [
|
stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")
|
||||||
"LDFLAGS=-fuse-ld=gold"
|
) [ "LDFLAGS=-fuse-ld=gold" ]
|
||||||
]
|
|
||||||
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell"
|
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell"
|
||||||
++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags
|
++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags
|
||||||
++ lib.optional (!canRunInstalled) "--disable-doc-gen"
|
++ lib.optional (!canRunInstalled) "--disable-doc-gen"
|
||||||
++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ]
|
++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ]
|
||||||
++ lib.optional (!forDevShell) "--sysconfdir=/etc"
|
++ lib.optional (!forDevShell) "--sysconfdir=/etc"
|
||||||
++ [
|
++ [ "TOML11_HEADERS=${lib.getDev toml11}/include" ];
|
||||||
"TOML11_HEADERS=${lib.getDev toml11}/include"
|
|
||||||
];
|
|
||||||
|
|
||||||
mesonBuildType = lib.optional (buildWithMeson || forDevShell) "debugoptimized";
|
mesonBuildType = lib.optional (buildWithMeson || forDevShell) "debugoptimized";
|
||||||
|
|
||||||
|
@ -290,37 +309,37 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [
|
mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [ "--suite=check" ];
|
||||||
"--suite=check"
|
|
||||||
];
|
|
||||||
|
|
||||||
installFlags = "sysconfdir=$(out)/etc";
|
installFlags = "sysconfdir=$(out)/etc";
|
||||||
|
|
||||||
postInstall = lib.optionalString (!finalAttrs.dontBuild) ''
|
postInstall =
|
||||||
mkdir -p $doc/nix-support
|
lib.optionalString (!finalAttrs.dontBuild) ''
|
||||||
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
mkdir -p $doc/nix-support
|
||||||
'' + lib.optionalString stdenv.hostPlatform.isStatic ''
|
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
||||||
mkdir -p $out/nix-support
|
''
|
||||||
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
+ lib.optionalString stdenv.hostPlatform.isStatic ''
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
mkdir -p $out/nix-support
|
||||||
for lib in libnixutil.dylib libnixexpr.dylib; do
|
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
||||||
install_name_tool \
|
''
|
||||||
-change "${lib.getLib boost}/lib/libboost_context.dylib" \
|
+ lib.optionalString stdenv.isDarwin ''
|
||||||
"$out/lib/libboost_context.dylib" \
|
for lib in libnixutil.dylib libnixexpr.dylib; do
|
||||||
"$out/lib/$lib"
|
install_name_tool \
|
||||||
done
|
-change "${lib.getLib boost}/lib/libboost_context.dylib" \
|
||||||
'' + lib.optionalString internalApiDocs ''
|
"$out/lib/libboost_context.dylib" \
|
||||||
mkdir -p $out/nix-support
|
"$out/lib/$lib"
|
||||||
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> "$out/nix-support/hydra-build-products"
|
done
|
||||||
'';
|
''
|
||||||
|
+ lib.optionalString internalApiDocs ''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> "$out/nix-support/hydra-build-products"
|
||||||
|
'';
|
||||||
|
|
||||||
doInstallCheck = finalAttrs.doCheck;
|
doInstallCheck = finalAttrs.doCheck;
|
||||||
installCheckFlags = "sysconfdir=$(out)/etc";
|
installCheckFlags = "sysconfdir=$(out)/etc";
|
||||||
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
|
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
|
||||||
|
|
||||||
mesonInstallCheckFlags = [
|
mesonInstallCheckFlags = [ "--suite=installcheck" ];
|
||||||
"--suite=installcheck"
|
|
||||||
];
|
|
||||||
|
|
||||||
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||||
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
||||||
|
@ -338,14 +357,11 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
# strictoverflow is disabled because we trap on signed overflow instead
|
# strictoverflow is disabled because we trap on signed overflow instead
|
||||||
hardeningDisable = [ "strictoverflow" ]
|
hardeningDisable = [ "strictoverflow" ] ++ lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||||
++ lib.optional stdenv.hostPlatform.isStatic "pie";
|
|
||||||
|
|
||||||
meta.platforms = lib.platforms.unix;
|
meta.platforms = lib.platforms.unix;
|
||||||
|
|
||||||
passthru.perl-bindings = pkgs.callPackage ./perl {
|
passthru.perl-bindings = pkgs.callPackage ./perl { inherit fileset stdenv buildWithMeson; };
|
||||||
inherit fileset stdenv buildWithMeson;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Export the patched version of boehmgc.
|
# Export the patched version of boehmgc.
|
||||||
# flake.nix exports that into its overlay.
|
# flake.nix exports that into its overlay.
|
||||||
|
|
127
perl/default.nix
127
perl/default.nix
|
@ -1,63 +1,80 @@
|
||||||
{ lib, fileset
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, perl, perlPackages
|
fileset,
|
||||||
, autoconf-archive, autoreconfHook, pkg-config
|
stdenv,
|
||||||
, nix, curl, bzip2, xz, boost, libsodium, darwin
|
perl,
|
||||||
, meson
|
perlPackages,
|
||||||
, ninja
|
autoconf-archive,
|
||||||
, buildWithMeson ? false,
|
autoreconfHook,
|
||||||
|
pkg-config,
|
||||||
|
nix,
|
||||||
|
curl,
|
||||||
|
bzip2,
|
||||||
|
xz,
|
||||||
|
boost,
|
||||||
|
libsodium,
|
||||||
|
darwin,
|
||||||
|
meson,
|
||||||
|
ninja,
|
||||||
|
buildWithMeson ? false,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
perl.pkgs.toPerlModule (stdenv.mkDerivation {
|
perl.pkgs.toPerlModule (
|
||||||
name = "nix-perl-${nix.version}";
|
stdenv.mkDerivation {
|
||||||
|
name = "nix-perl-${nix.version}";
|
||||||
|
|
||||||
src = fileset.toSource {
|
src = fileset.toSource {
|
||||||
root = ../.;
|
root = ../.;
|
||||||
fileset = fileset.unions ([
|
fileset = fileset.unions (
|
||||||
../.version
|
[
|
||||||
./lib
|
../.version
|
||||||
] ++ lib.optionals (!buildWithMeson) [
|
./lib
|
||||||
# FIXME(Qyriad): What the hell is this?
|
]
|
||||||
# What is it used for and do we still need it?
|
++ lib.optionals (!buildWithMeson) [
|
||||||
./MANIFEST
|
# FIXME(Qyriad): What the hell is this?
|
||||||
../m4
|
# What is it used for and do we still need it?
|
||||||
../mk
|
./MANIFEST
|
||||||
./Makefile
|
../m4
|
||||||
./Makefile.config.in
|
../mk
|
||||||
./configure.ac
|
./Makefile
|
||||||
./local.mk
|
./Makefile.config.in
|
||||||
] ++ lib.optionals buildWithMeson [
|
./configure.ac
|
||||||
./meson.build
|
./local.mk
|
||||||
]);
|
]
|
||||||
};
|
++ lib.optionals buildWithMeson [ ./meson.build ]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs =
|
||||||
pkg-config
|
[ pkg-config ]
|
||||||
] ++ lib.optionals (!buildWithMeson) [
|
++ lib.optionals (!buildWithMeson) [
|
||||||
autoconf-archive
|
autoconf-archive
|
||||||
autoreconfHook
|
autoreconfHook
|
||||||
] ++ lib.optionals buildWithMeson [
|
]
|
||||||
meson
|
++ lib.optionals buildWithMeson [
|
||||||
ninja
|
meson
|
||||||
];
|
ninja
|
||||||
|
];
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[ nix
|
[
|
||||||
curl
|
nix
|
||||||
bzip2
|
curl
|
||||||
xz
|
bzip2
|
||||||
perl
|
xz
|
||||||
boost
|
perl
|
||||||
perlPackages.DBI
|
boost
|
||||||
perlPackages.DBDSQLite
|
perlPackages.DBI
|
||||||
]
|
perlPackages.DBDSQLite
|
||||||
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
]
|
||||||
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
|
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
||||||
|
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
|
||||||
|
|
||||||
# Nixpkgs' Meson hook likes to set this to "plain".
|
# Nixpkgs' Meson hook likes to set this to "plain".
|
||||||
mesonBuildType = "debugoptimized";
|
mesonBuildType = "debugoptimized";
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
postUnpack = "sourceRoot=$sourceRoot/perl";
|
postUnpack = "sourceRoot=$sourceRoot/perl";
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
|
@ -1,43 +1,75 @@
|
||||||
{ 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;
|
||||||
|
|
||||||
impureEnvVars = [
|
impureEnvVars = [
|
||||||
# We borrow these environment variables from the caller to allow
|
# We borrow these environment variables from the caller to allow
|
||||||
# easy proxy configuration. This is impure, but a fixed-output
|
# easy proxy configuration. This is impure, but a fixed-output
|
||||||
# derivation like fetchurl is allowed to do so since its result is
|
# derivation like fetchurl is allowed to do so since its result is
|
||||||
# by definition pure.
|
# by definition pure.
|
||||||
"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; }))
|
)
|
||||||
|
|
|
@ -4,69 +4,69 @@ let
|
||||||
|
|
||||||
lockFile = builtins.fromJSON lockFileStr;
|
lockFile = builtins.fromJSON lockFileStr;
|
||||||
|
|
||||||
allNodes =
|
allNodes = builtins.mapAttrs (
|
||||||
builtins.mapAttrs
|
key: node:
|
||||||
(key: node:
|
let
|
||||||
let
|
|
||||||
|
|
||||||
sourceInfo =
|
sourceInfo =
|
||||||
if key == lockFile.root
|
if key == lockFile.root then
|
||||||
then rootSrc
|
rootSrc
|
||||||
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
else
|
||||||
|
fetchTree (node.info or { } // removeAttrs node.locked [ "dir" ]);
|
||||||
|
|
||||||
subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
|
subdir = if key == lockFile.root then rootSubdir else 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 {});
|
);
|
||||||
|
|
||||||
# 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
|
||||||
else
|
nodeName
|
||||||
getInputByPath
|
else
|
||||||
# Since this could be a 'follows' input, call resolveInput.
|
getInputByPath
|
||||||
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
|
# Since this could be a 'follows' input, call resolveInput.
|
||||||
(builtins.tail path);
|
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
|
||||||
|
(builtins.tail path);
|
||||||
|
|
||||||
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;
|
||||||
in
|
_type = "flake";
|
||||||
if node.flake or true then
|
};
|
||||||
assert builtins.isFunction flake.outputs;
|
in
|
||||||
result
|
if node.flake or true then
|
||||||
else
|
assert builtins.isFunction flake.outputs;
|
||||||
sourceInfo
|
result
|
||||||
)
|
else
|
||||||
lockFile.nodes;
|
sourceInfo
|
||||||
|
) lockFile.nodes;
|
||||||
in allNodes.${lockFile.root}
|
in
|
||||||
|
allNodes.${lockFile.root}
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
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
|
||||||
in (builtins.head outputsList).value
|
(builtins.head outputsList).value
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
/* This is the implementation of the ‘derivation’ builtin function.
|
/*
|
||||||
It's actually a wrapper around the ‘derivationStrict’ primop. */
|
This is the implementation of the ‘derivation’ builtin function.
|
||||||
|
It's actually a wrapper around the ‘derivationStrict’ primop.
|
||||||
|
*/
|
||||||
|
|
||||||
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
|
||||||
in (builtins.head outputsList).value
|
(builtins.head outputsList).value
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{ name, channelName, src }:
|
{
|
||||||
|
name,
|
||||||
|
channelName,
|
||||||
|
src,
|
||||||
|
}:
|
||||||
|
|
||||||
derivation {
|
derivation {
|
||||||
builder = "builtin:unpack-channel";
|
builder = "builtin:unpack-channel";
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
[formatter]
|
[formatter.nix]
|
||||||
# [formatter.nix]
|
command = "nixfmt"
|
||||||
# command = "nixfmt"
|
includes = ["*.nix"]
|
||||||
# includes = ["*.nix"]
|
excludes = ["tests/**"]
|
||||||
# excludes = ["tests/**"]
|
|
||||||
|
|
Loading…
Reference in a new issue