Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixpkgs update and few fixes #394

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"image": "std-vscode",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
"image": "std-vscode",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
10 changes: 3 additions & 7 deletions .github/workflows/update-subflake.sh
Original file line number Diff line number Diff line change
@@ -2,11 +2,7 @@
nix store add-path --name source .

# update the subflake lockfile to the (now existing) store path
# set lastModified to 1 because unknown issues in the GH action environment
(cd ./src/local && nix flake lock --update-input std && (
jq '.nodes.std.locked.lastModified = 1' flake.lock > flake.lock.new && rm flake.lock && mv flake.lock.new flake.lock
) && git add -f flake.lock)
(cd ./src/tests && nix flake lock --update-input std && (
jq '.nodes.std.locked.lastModified = 1' flake.lock > flake.lock.new && rm flake.lock && mv flake.lock.new flake.lock
) &&git add -f flake.lock)
(cd ./src/local && nix flake lock --update-input std && git add -f flake.lock)
(cd ./src/mdbook && nix flake lock --update-input std && git add -f flake.lock)
(cd ./src/tests && nix flake lock --update-input std && git add -f flake.lock)
# continue normally ...
88 changes: 44 additions & 44 deletions docs/theme/highlight.js
Original file line number Diff line number Diff line change
@@ -81,11 +81,11 @@ var hljs = (function () {
? e
: n
: "start" === n[0].event
? e
: n
? e
: n
: e.length
? e
: n;
? e
: n;
}
function c(e) {
s +=
@@ -281,7 +281,7 @@ var hljs = (function () {
0 !== e.index && n.ignoreMatch();
},
},
e
e,
)
);
},
@@ -348,10 +348,10 @@ var hljs = (function () {
return n
? +n
: (function (e) {
return N.includes(e.toLowerCase());
})(e)
? 0
: 1;
return N.includes(e.toLowerCase());
})(e)
? 0
: 1;
}
const R = t,
y = r,
@@ -464,7 +464,7 @@ var hljs = (function () {
r.endSameAsBegin &&
(r.endRe = RegExp(
t.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
"m"
"m",
)),
r.skip
? (A += t)
@@ -481,7 +481,7 @@ var hljs = (function () {
i +
'" for mode "' +
(y.className || "<unnamed>") +
'"'
'"',
);
throw ((e.mode = y), e);
}
@@ -529,7 +529,7 @@ var hljs = (function () {
if ("illegal" === r.type && "" === i) return 1;
if (B > 1e5 && B > 3 * r.index)
throw Error(
"potential infinite loop, way more iterations than matches"
"potential infinite loop, way more iterations than matches",
);
return (A += i), i.length;
}
@@ -543,7 +543,7 @@ var hljs = (function () {
function n(n, t) {
return RegExp(
d(n),
"m" + (e.case_insensitive ? "i" : "") + (t ? "g" : "")
"m" + (e.case_insensitive ? "i" : "") + (t ? "g" : ""),
);
}
class t {
@@ -593,7 +593,7 @@ var hljs = (function () {
}
return a;
})(e),
!0
!0,
)),
(this.lastIndex = 0);
}
@@ -649,7 +649,7 @@ var hljs = (function () {
}
if (e.contains && e.contains.includes("self"))
throw Error(
"ERR: contains `self` is not supported at the top-level of a language. See documentation."
"ERR: contains `self` is not supported at the top-level of a language. See documentation.",
);
return (function t(s, o) {
const l = s;
@@ -683,7 +683,7 @@ var hljs = (function () {
s.lexemes && c)
)
throw Error(
"ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) "
"ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ",
);
return (
(l.keywordPatternRe = n(s.lexemes || c || /\w+/, !0)),
@@ -718,15 +718,15 @@ var hljs = (function () {
e.cached_variants
? e.cached_variants
: (function e(n) {
return !!n && (n.endsWithParent || e(n.starts));
})(e)
? r(e, { starts: e.starts ? r(e.starts) : null })
: Object.isFrozen(e)
? r(e)
: e
return !!n && (n.endsWithParent || e(n.starts));
})(e)
? r(e, { starts: e.starts ? r(e.starts) : null })
: Object.isFrozen(e)
? r(e)
: e
);
})("self" === e ? s : e);
})
}),
)),
s.contains.forEach(function (e) {
t(e, l);
@@ -736,7 +736,7 @@ var hljs = (function () {
const n = new a();
return (
e.contains.forEach((e) =>
n.addRule(e.begin, { rule: e, type: "begin" })
n.addRule(e.begin, { rule: e, type: "begin" }),
),
e.terminator_end &&
n.addRule(e.terminator_end, { type: "end" }),
@@ -847,8 +847,8 @@ var hljs = (function () {
? "<br>"
: e
: f.tabReplace
? e.replace(/\t/g, f.tabReplace)
: e
? e.replace(/\t/g, f.tabReplace)
: e,
)
: e;
}
@@ -865,7 +865,7 @@ var hljs = (function () {
(console.warn(g.replace("{}", t[1])),
console.warn(
"Falling back to no-highlight mode for this block.",
e
e,
)),
r ? t[1] : "no-highlight"
);
@@ -957,8 +957,8 @@ var hljs = (function () {
(console.error(
"Language definition for '{}' could not be registered.".replace(
"{}",
e
)
e,
),
),
!l)
)
@@ -979,7 +979,7 @@ var hljs = (function () {
var n = T(e);
if (n) return n;
throw Error(
"The '{}' language is required, but not loaded.".replace("{}", e)
"The '{}' language is required, but not loaded.".replace("{}", e),
);
},
autoDetection: I,
@@ -1127,7 +1127,7 @@ hljs.registerLanguage(
],
};
};
})()
})(),
);
hljs.registerLanguage(
"markdown",
@@ -1252,7 +1252,7 @@ hljs.registerLanguage(
}
);
};
})()
})(),
);
hljs.registerLanguage(
"perl",
@@ -1347,7 +1347,7 @@ hljs.registerLanguage(
{ name: "Perl", aliases: ["pl", "pm"], keywords: n, contains: a }
);
};
})()
})(),
);
hljs.registerLanguage(
"plaintext",
@@ -1360,7 +1360,7 @@ hljs.registerLanguage(
disableAutodetect: !0,
};
};
})()
})(),
);
hljs.registerLanguage(
"ini",
@@ -1427,15 +1427,15 @@ hljs.registerLanguage(
"(\\s*\\.\\s*",
g,
")*",
n("(?=", /\s*=\s*[^#\s]/, ")")
n("(?=", /\s*=\s*[^#\s]/, ")"),
),
className: "attr",
starts: { end: /$/, contains: [i, c, r, t, l, s] },
},
],
};
};
})()
})(),
);
hljs.registerLanguage(
"json",
@@ -1481,7 +1481,7 @@ hljs.registerLanguage(
{ name: "JSON", contains: t, keywords: e, illegal: "\\S" }
);
};
})()
})(),
);
hljs.registerLanguage(
"ruby",
@@ -1626,7 +1626,7 @@ hljs.registerLanguage(
contains: r.concat(g).concat(d),
};
};
})()
})(),
);
hljs.registerLanguage(
"yaml",
@@ -1737,7 +1737,7 @@ hljs.registerLanguage(
}
);
};
})()
})(),
);
hljs.registerLanguage(
"haskell",
@@ -1837,7 +1837,7 @@ hljs.registerLanguage(
],
};
};
})()
})(),
);
hljs.registerLanguage(
"nix",
@@ -1876,7 +1876,7 @@ hljs.registerLanguage(
{ name: "Nix", aliases: ["nixos"], keywords: n, contains: s }
);
};
})()
})(),
);
hljs.registerLanguage(
"bash",
@@ -1953,7 +1953,7 @@ hljs.registerLanguage(
],
};
};
})()
})(),
);
hljs.registerLanguage(
"shell",
@@ -1972,7 +1972,7 @@ hljs.registerLanguage(
],
};
};
})()
})(),
);
hljs.registerLanguage(
"python",
@@ -2092,5 +2092,5 @@ hljs.registerLanguage(
}
);
};
})()
})(),
);
85 changes: 47 additions & 38 deletions docs/theme/pagetoc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
// Un-active everything when you click it
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
el.addEventHandler("click", function() {
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
el.classList.remove("active");
});
el.classList.add("active");
Array.prototype.forEach.call(
document.getElementsByClassName("pagetoc")[0].children,
function (el) {
el.addEventHandler("click", function () {
Array.prototype.forEach.call(
document.getElementsByClassName("pagetoc")[0].children,
function (el) {
el.classList.remove("active");
},
);
el.classList.add("active");
});
});
},
);

var updateFunction = function() {
var updateFunction = function () {
var id;
var elements = document.getElementsByClassName("header");
Array.prototype.forEach.call(elements, function (el) {
if (window.pageYOffset >= el.offsetTop) {
id = el;
}
});

var id;
var elements = document.getElementsByClassName("header");
Array.prototype.forEach.call(elements, function(el) {
if (window.pageYOffset >= el.offsetTop) {
id = el;
}
});

Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
el.classList.remove("active");
});
if (!id) return;
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
if (id.href.localeCompare(el.href) == 0) {
el.classList.add("active");
}
});
Array.prototype.forEach.call(
document.getElementsByClassName("pagetoc")[0].children,
function (el) {
el.classList.remove("active");
},
);
if (!id) return;
Array.prototype.forEach.call(
document.getElementsByClassName("pagetoc")[0].children,
function (el) {
if (id.href.localeCompare(el.href) == 0) {
el.classList.add("active");
}
},
);
};

// Populate sidebar on load
window.addEventListener('load', function() {
var pagetoc = document.getElementsByClassName("pagetoc")[0];
var elements = document.getElementsByClassName("header");
Array.prototype.forEach.call(elements, function (el) {
var link = document.createElement("a");
link.appendChild(document.createTextNode(el.text));
link.href = el.href;
link.classList.add("pagetoc-" + el.parentElement.tagName);
pagetoc.appendChild(link);
});
updateFunction.call();
window.addEventListener("load", function () {
var pagetoc = document.getElementsByClassName("pagetoc")[0];
var elements = document.getElementsByClassName("header");
Array.prototype.forEach.call(elements, function (el) {
var link = document.createElement("a");
link.appendChild(document.createTextNode(el.text));
link.href = el.href;
link.classList.add("pagetoc-" + el.parentElement.tagName);
pagetoc.appendChild(link);
});
updateFunction.call();
});



// Handle active elements on scroll
window.addEventListener("scroll", updateFunction);
2 changes: 1 addition & 1 deletion dogfood.nix
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ in
}
(std.grow {
inherit inputs;
cellsFrom = incl ./src ["std" "lib" "data"];
cellsFrom = incl ./src ["std" "lib" "data" "mdbook"];
cellBlocks = with std.blockTypes; [
## For downstream use

14 changes: 7 additions & 7 deletions flake.lock
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
{
description = "The Nix Flakes framework for perfectionists with deadlines";
# override downstream with inputs.std.inputs.nixpkgs.follows = ...
inputs.nixpkgs.url = "github:nixos/nixpkgs/release-23.11";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
inputs.lib.url = "github:nix-community/nixpkgs.lib";
inputs = {
paisano.url = "github:paisano-nix/core/0.2.0";
34 changes: 5 additions & 29 deletions src/data/configs/mdbook.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
let
inherit (inputs) nixpkgs;
inherit (inputs.mdbook-paisano-preprocessor.app.package) mdbook-paisano-preprocessor;
in {
hook.mode = "copy"; # let CI pick it up outside of devshell
packages = [
nixpkgs.alejandra
nixpkgs.nodePackages.prettier
nixpkgs.nodePackages.prettier-plugin-toml
nixpkgs.shfmt
mdbook-paisano-preprocessor
];

data = {
book = {
language = "en";
multilingual = false;
src = "docs";
title = "Documentation";
};
build = {
build-dir = "docs/book";
};
preprocessor.paisano-preprocessor = {
before = ["links"];
registry = ".#__std.init";
};
};
}
/*
extracted out to separate cell to fix https://github.com/divnix/std/issues/393
you can read the real source at /src/mdbook/configs/mdbook.nix
*/
inputs.cells.mdbook.configs.mdbook
5 changes: 4 additions & 1 deletion src/data/configs/treefmt.nix
Original file line number Diff line number Diff line change
@@ -10,14 +10,17 @@ in {
];

data = {
global.excludes = [
"**/flake.lock" # just for treefmt cries that formatter is not configured
];
formatter = {
nix = {
command = lib.getExe nixpkgs.alejandra;
includes = ["*.nix"];
};
prettier = {
command = lib.getExe nixpkgs.nodePackages.prettier;
options = ["--plugin" "${nixpkgs.nodePackages.prettier-plugin-toml}/lib/node_modules/prettier-plugin-toml/lib/api.js" "--write"];
options = ["--plugin" "${nixpkgs.nodePackages.prettier-plugin-toml}/lib/node_modules/prettier-plugin-toml/lib/index.cjs" "--write"];
includes = [
"*.css"
"*.html"
2 changes: 1 addition & 1 deletion src/lib/cfg/lefthook.nix
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ let
mkScript = stage:
nixpkgs.writeScript "lefthook-${stage}" ''
#!${nixpkgs.runtimeShell}
[ "$LEFTHOOK" == "0" ] || ${lib.getExe nixpkgs.lefthook} run "${stage}" "$@"
[ "$LEFTHOOK" == "0" ] || ${lib.getExe nixpkgs.lefthook} run --no-auto-install "${stage}" "$@"
Copy link
Contributor Author

@nazarewk nazarewk Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we could switch to 24.05 since it contains this flag implemented at https://github.com/evilmartians/lefthook/releases/tag/v1.6.11

'';

toStagesConfig = config:
7 changes: 5 additions & 2 deletions src/local/configs.nix
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
inputs,
cell,
}: let
inherit (inputs) nixpkgs;
inherit (inputs) nixpkgs dmerge;
inherit (inputs.std.data) configs;
inherit (inputs.std.lib.dev) mkNixago;
in {
@@ -15,7 +15,10 @@ in {
};
treefmt = (mkNixago configs.treefmt) {
data = {
global.excludes = ["src/std/templates/**"];
global.excludes = dmerge.append [
"CHANGELOG.md" # significantly reformats the file structure
"src/std/templates/**"
];
formatter = {
go = {
command = "gofmt";
52 changes: 27 additions & 25 deletions src/local/flake.lock
12 changes: 12 additions & 0 deletions src/mdbook/configs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let
inherit (inputs) cells;
inherit (inputs.std) findTargets;

inherit (inputs.nixpkgs.lib) recursiveUpdate mapAttrs;

data = findTargets {
inherit inputs cell;
block = ./.;
};
in
mapAttrs (name: config: recursiveUpdate config (data.${name} or {})) cells.lib.cfg
25 changes: 25 additions & 0 deletions src/mdbook/configs/mdbook.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let
inherit (inputs) nixpkgs;
inherit (inputs.mdbook-paisano-preprocessor.app.package) mdbook-paisano-preprocessor;
in {
hook.mode = "copy"; # let CI pick it up outside of devshell
packages = [
mdbook-paisano-preprocessor
];

data = {
book = {
language = "en";
multilingual = false;
src = "docs";
title = "Documentation";
};
build = {
build-dir = "docs/book";
};
preprocessor.paisano-preprocessor = {
before = ["links"];
registry = ".#__std.init";
};
};
}
File renamed without changes.
File renamed without changes.
17 changes: 8 additions & 9 deletions src/std/fwlib/actions/build-proviso.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
declare action="$1"
declare targetDrv

eval "$(jq -r '@sh "targetDrv=\(.targetDrv)"' <<< "$action" )"
eval "$(jq -r '@sh "targetDrv=\(.targetDrv)"' <<<"$action")"

mapfile -t uncached < <(
command nix-store --realise --dry-run "$targetDrv" 2>&1 1>/dev/null \
| command sed -nr '
command nix-store --realise --dry-run "$targetDrv" 2>&1 1>/dev/null |
command sed -nr '
# If the line "will be built" is matched ...
/will be built/ {
# Create a label to iterate over dervivations
@@ -28,18 +28,17 @@ mapfile -t uncached < <(
'
)

if [[ ${#uncached[@]} -eq 0 ]];
then
if [[ ${#uncached[@]} -eq 0 ]]; then
exit 1
fi

if ! (
command nix show-derivation ''${uncached[@]} 2> /dev/null \
| command jq --exit-status \
' with_entries(
command nix show-derivation ''${uncached[@]} 2>/dev/null |
command jq --exit-status \
' with_entries(
select(.value|.env.preferLocalBuild != "1")
) | any
' 1> /dev/null
' 1>/dev/null
); then
exit 1
fi
2 changes: 1 addition & 1 deletion src/std/fwlib/blockTypes/containers-proviso.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare action="$1"
declare image

eval "$(jq -r '@sh "image=\(.meta.image)"' <<< "$action" )"
eval "$(jq -r '@sh "image=\(.meta.image)"' <<<"$action")"

if command skopeo inspect --insecure-policy "docker://$image" &>/dev/null; then
exit 1
2 changes: 1 addition & 1 deletion src/std/fwlib/blockTypes/devshells.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
root,
super,
}:
12 changes: 6 additions & 6 deletions src/std/fwlib/flakeModule.nix
Original file line number Diff line number Diff line change
@@ -168,12 +168,12 @@ in
};
config = {
flake = let
grown = grow ({
inherit inputs;
inherit (config) systems;
# access them explicitly to trigger a module system error if not defined
inherit (cfg.grow) cellsFrom cellBlocks nixpkgsConfig;
});
grown = grow {
inherit inputs;
inherit (config) systems;
# access them explicitly to trigger a module system error if not defined
inherit (cfg.grow) cellsFrom cellBlocks nixpkgsConfig;
};
picked = mapAttrs (_: v: pick grown v) cfg.pick;
harvested = mapAttrs (_: v: harvest grown v) cfg.harvest;
winnowed = zipAttrsWith (n: v: winnow (head v) grown (head (tail v))) [cfg.winnowIf cfg.winnow];
241 changes: 164 additions & 77 deletions src/tests/flake.lock

Large diffs are not rendered by default.