Skip to content

Commit 475ec1b

Browse files
committed
treewide: nixfmt
Command run: ``` fd -tf nix$ --exec nixfmt ```
1 parent d0c12e9 commit 475ec1b

File tree

8 files changed

+150
-113
lines changed

8 files changed

+150
-113
lines changed

default.nix

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,63 +28,71 @@ let
2828
pkgs.perl
2929
];
3030
# generated with nix run github:rgri/tex2nix -- *.tex *.sty
31-
nix-dev-latex = [ (pkgs.callPackage ./nix/tex-env.nix {
32-
extraTexPackages = {
33-
inherit (pkgs.texlive) latexmk gnu-freefont;
34-
};
35-
}) ];
36-
nix-dev =
37-
pkgs.stdenv.mkDerivation {
38-
name = "nix-dev";
39-
src = ./.;
40-
nativeBuildInputs = [
41-
nix-dev-python-pkgs
42-
nix-dev-latex
43-
];
44-
buildPhase =
45-
let
46-
substitutedNixManualReference = pkgs.substitute {
47-
src = ./source/reference/nix-manual.md;
48-
substitutions = lib.concatLists (lib.mapAttrsToList (from: to: [ "--subst-var-by" from to ]) releases.substitutions);
49-
};
50-
in
51-
''
52-
${lib.optionalString withManuals "cp -f ${substitutedNixManualReference} source/reference/nix-manual.md"}
53-
make html
54-
make latexpdf
55-
'';
56-
installPhase =
57-
let
58-
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
59-
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
60-
release = version: nix: ''
61-
cp -R --no-preserve=mode ${nix.doc}/share/doc/nix/manual $out/manual/nix/${version}
31+
nix-dev-latex = [
32+
(pkgs.callPackage ./nix/tex-env.nix {
33+
extraTexPackages = {
34+
inherit (pkgs.texlive) latexmk gnu-freefont;
35+
};
36+
})
37+
];
38+
nix-dev = pkgs.stdenv.mkDerivation {
39+
name = "nix-dev";
40+
src = ./.;
41+
nativeBuildInputs = [
42+
nix-dev-python-pkgs
43+
nix-dev-latex
44+
];
45+
buildPhase =
46+
let
47+
substitutedNixManualReference = pkgs.substitute {
48+
src = ./source/reference/nix-manual.md;
49+
substitutions = lib.concatLists (
50+
lib.mapAttrsToList (from: to: [
51+
"--subst-var-by"
52+
from
53+
to
54+
]) releases.substitutions
55+
);
56+
};
57+
in
58+
''
59+
${lib.optionalString withManuals "cp -f ${substitutedNixManualReference} source/reference/nix-manual.md"}
60+
make html
61+
make latexpdf
62+
'';
63+
installPhase =
64+
let
65+
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
66+
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
67+
release = version: nix: ''
68+
cp -R --no-preserve=mode ${nix.doc}/share/doc/nix/manual $out/manual/nix/${version}
6269
63-
# add upstream page redirects of the form `<from> <to> <status>`, excluding comments and empty lines
64-
# not all releases have that though
65-
if [[ -f ${nix.doc}/share/doc/nix/manual/_redirects ]]; then
66-
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix.doc}/share/doc/nix/manual/_redirects >> $out/_redirects
67-
fi
70+
# add upstream page redirects of the form `<from> <to> <status>`, excluding comments and empty lines
71+
# not all releases have that though
72+
if [[ -f ${nix.doc}/share/doc/nix/manual/_redirects ]]; then
73+
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix.doc}/share/doc/nix/manual/_redirects >> $out/_redirects
74+
fi
6875
69-
# provide a single-page view from mdBook's print feature.
70-
# this is hacky but cheap and does work.
71-
sed -z 's|\s*window\.addEventListener(\x27load\x27, function() {\s*window\.setTimeout(window.print, 100);\s*});||g' ${nix.doc}/share/doc/nix/manual/print.html > $out/manual/nix/${version}/nix-${version}.html
72-
'';
73-
# Redirects from mutable URLs like /manual/nix/latest/... to /manual/nix/2.21/...
74-
mutableRedirect = mutable: immutable: ''
75-
echo "/manual/nix/${mutable}/* /manual/nix/${immutable}/:splat 302" >> $out/_redirects
76-
'';
77-
in
78-
''
79-
mkdir -p $out/manual/nix
80-
cp -R build/html/* $out/
81-
cp build/latex/nix-dev.pdf $out/
82-
cp netlify.toml $out/
83-
'' + lib.optionalString withManuals ''
84-
${lib.concatStringsSep "\n" (lib.mapAttrsToList release releases.nixReleases)}
85-
${lib.concatStringsSep "\n" (lib.mapAttrsToList mutableRedirect releases.mutableNixManualRedirects)}
76+
# provide a single-page view from mdBook's print feature.
77+
# this is hacky but cheap and does work.
78+
sed -z 's|\s*window\.addEventListener(\x27load\x27, function() {\s*window\.setTimeout(window.print, 100);\s*});||g' ${nix.doc}/share/doc/nix/manual/print.html > $out/manual/nix/${version}/nix-${version}.html
8679
'';
87-
};
80+
# Redirects from mutable URLs like /manual/nix/latest/... to /manual/nix/2.21/...
81+
mutableRedirect = mutable: immutable: ''
82+
echo "/manual/nix/${mutable}/* /manual/nix/${immutable}/:splat 302" >> $out/_redirects
83+
'';
84+
in
85+
''
86+
mkdir -p $out/manual/nix
87+
cp -R build/html/* $out/
88+
cp build/latex/nix-dev.pdf $out/
89+
cp netlify.toml $out/
90+
''
91+
+ lib.optionalString withManuals ''
92+
${lib.concatStringsSep "\n" (lib.mapAttrsToList release releases.nixReleases)}
93+
${lib.concatStringsSep "\n" (lib.mapAttrsToList mutableRedirect releases.mutableNixManualRedirects)}
94+
'';
95+
};
8896

8997
devmode = pkgs.devmode.override {
9098
buildArgs = ''-A build --show-trace'';

nix/inputs.nix

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@
1313
# {
1414
# <version> = <source>;
1515
# }
16-
nix =
17-
builtins.mapAttrs (name: value:
18-
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
19-
fetchTarball {
20-
name = "source";
21-
url = value.url;
22-
sha256 = value.sha256;
23-
}
24-
) (builtins.fromJSON (builtins.readFile ./nix-versions.json));
16+
nix = builtins.mapAttrs (
17+
name: value:
18+
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
19+
fetchTarball {
20+
name = "source";
21+
url = value.url;
22+
sha256 = value.sha256;
23+
}
24+
) (builtins.fromJSON (builtins.readFile ./nix-versions.json));
2525

2626
# Sources for Nixpkgs releases, the attribute name is the release name.
2727
# These can be updated with the standard npins tooling, but are tracked separately to avoid having to filter them out during processing.
2828
# See ./update-nixpkgs-releases.nix
29-
nixpkgs =
30-
builtins.mapAttrs (name: value:
31-
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
32-
fetchTarball {
33-
name = "source";
34-
url = value.url;
35-
sha256 = value.hash;
36-
}
37-
) (builtins.fromJSON (builtins.readFile ./sources.json)).pins;
29+
nixpkgs = builtins.mapAttrs (
30+
name: value:
31+
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
32+
fetchTarball {
33+
name = "source";
34+
url = value.url;
35+
sha256 = value.hash;
36+
}
37+
) (builtins.fromJSON (builtins.readFile ./sources.json)).pins;
3838

3939
}

nix/overlay.nix

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
final: prev: let
2-
python-module-sphinx-sitemap = {
3-
lib,
4-
buildPythonPackage,
5-
fetchPypi,
6-
sphinx,
7-
pytest,
8-
}: let
9-
pname = "sphinx-sitemap";
10-
version = "2.5.1";
11-
in
1+
final: prev:
2+
let
3+
python-module-sphinx-sitemap =
4+
{
5+
lib,
6+
buildPythonPackage,
7+
fetchPypi,
8+
sphinx,
9+
pytest,
10+
}:
11+
let
12+
pname = "sphinx-sitemap";
13+
version = "2.5.1";
14+
in
1215
buildPythonPackage {
1316
inherit pname version;
1417

@@ -37,7 +40,8 @@ final: prev: let
3740
license = licenses.mit;
3841
};
3942
};
40-
in {
43+
in
44+
{
4145
python310 = prev.python310.override {
4246
packageOverrides = python-final: python-prev: {
4347
sphinx-sitemap = python-module-sphinx-sitemap {

nix/releases.nix

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
{ lib, inputs, system }:
1+
{
2+
lib,
3+
inputs,
4+
system,
5+
}:
26
let
37
# Import Nixpkgs, get the pkgs set back
4-
pkgsFor = source:
8+
pkgsFor =
9+
source:
510
import source {
611
inherit system;
712
config = { };
@@ -16,9 +21,7 @@ let
1621
# "23.11" = pkgs...;
1722
# "23.05" = pkgs...;
1823
# }
19-
pkgsReleases = lib.mapAttrs (release: source:
20-
pkgsFor source
21-
) inputs.nixpkgs;
24+
pkgsReleases = lib.mapAttrs (release: source: pkgsFor source) inputs.nixpkgs;
2225

2326
# Information on Nixpkgs versions
2427
nixpkgsVersions = rec {
@@ -33,7 +36,8 @@ let
3336
};
3437

3538
# The Nix version string for a pkgs, e.g. "2.18"
36-
nixVersionForPkgs = pkgs:
39+
nixVersionForPkgs =
40+
pkgs:
3741
# XXX: We ignore the patch version here, which means that we may show a different (slightly more up-to-date) version than what's actually in Nixpkgs.
3842
# This is not a big issue, and simplifies the setup a lot.
3943
lib.versions.majorMinor pkgs.nix.version;
@@ -44,7 +48,8 @@ let
4448
# "2.19" = { outPath = ...; ... };
4549
# ...
4650
# }
47-
nixReleases = lib.mapAttrs (release: source:
51+
nixReleases = lib.mapAttrs (
52+
release: source:
4853
# XXX: Unfortunately, the use of flake-compat prevents passing `system` with stable Nix...
4954
(import source).default
5055
) inputs.nix;
@@ -81,9 +86,8 @@ let
8186
substitutions = {
8287
nixpkgs-stable = nixpkgsVersions.latest;
8388
nixpkgs-prev-stable = nixpkgsVersions.prevLatest;
84-
} // lib.mapAttrs' (name: value:
85-
lib.nameValuePair "nix-${name}" value
86-
) mutableNixManualRedirects;
89+
}
90+
// lib.mapAttrs' (name: value: lib.nameValuePair "nix-${name}" value) mutableNixManualRedirects;
8791
in
8892
{
8993
inherit nixReleases mutableNixManualRedirects substitutions;

nix/tex-env.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Generated with tex2nix 0.0.0
2-
{ texlive, extraTexPackages ? {} }:
3-
(texlive.combine ({
2+
{
3+
texlive,
4+
extraTexPackages ? { },
5+
}:
6+
(texlive.combine (
7+
{
48
inherit (texlive) scheme-small;
59
"amsmath" = texlive."amsmath";
610
"atbegshi" = texlive."atbegshi";
@@ -49,4 +53,6 @@
4953
"wrapfig" = texlive."wrapfig";
5054
"xcolor" = texlive."xcolor";
5155

52-
} // extraTexPackages))
56+
}
57+
// extraTexPackages
58+
))

nix/update-nix-releases.nix

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
{ writeShellApplication
2-
, git
3-
, nix
4-
, ripgrep
5-
, coreutils
6-
, jq
1+
{
2+
writeShellApplication,
3+
git,
4+
nix,
5+
ripgrep,
6+
coreutils,
7+
jq,
78
}:
89
# Custom update mechanism for Nix releases in ./nix-versions.json
910
writeShellApplication {
1011
name = "update-nix-releases";
11-
runtimeInputs = [ git nix ripgrep coreutils jq ];
12+
runtimeInputs = [
13+
git
14+
nix
15+
ripgrep
16+
coreutils
17+
jq
18+
];
1219
text = ''
1320
tmp=$(mktemp -d)
1421
trap 'rm -rf "$tmp"' EXIT

nix/update-nixpkgs-releases.nix

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
{ writeShellApplication
2-
, git
3-
, npins
4-
, nix
5-
, ripgrep
6-
, coreutils
7-
, jq
1+
{
2+
writeShellApplication,
3+
git,
4+
npins,
5+
nix,
6+
ripgrep,
7+
coreutils,
8+
jq,
89
}:
910
# add or update Nixpkgs releases using `npins`
1011
writeShellApplication {
1112
name = "update-nixpkgs-releases";
12-
runtimeInputs = [ git npins nix ripgrep jq coreutils ];
13+
runtimeInputs = [
14+
git
15+
npins
16+
nix
17+
ripgrep
18+
jq
19+
coreutils
20+
];
1321
text = ''
1422
echo >&2 "Updating rolling"
1523
npins update nixpkgs-rolling

source/tutorials/module-system/a-basic-module/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let
2-
pkgs = import <nixpkgs> {};
2+
pkgs = import <nixpkgs> { };
33
result = pkgs.lib.evalModules {
44
modules = [
55
./options.nix

0 commit comments

Comments
 (0)