Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file contains a list of commits that are not likely what you
# are looking for in a blame, such as mass reformatting or renaming.
#
# treewide: nixfmt
475ec1b3eb17b29c7254ad20aec9ee9cb81d18b8
116 changes: 62 additions & 54 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,63 +28,71 @@ let
pkgs.perl
];
# generated with nix run github:rgri/tex2nix -- *.tex *.sty
nix-dev-latex = [ (pkgs.callPackage ./nix/tex-env.nix {
extraTexPackages = {
inherit (pkgs.texlive) latexmk gnu-freefont;
};
}) ];
nix-dev =
pkgs.stdenv.mkDerivation {
name = "nix-dev";
src = ./.;
nativeBuildInputs = [
nix-dev-python-pkgs
nix-dev-latex
];
buildPhase =
let
substitutedNixManualReference = pkgs.substitute {
src = ./source/reference/nix-manual.md;
substitutions = lib.concatLists (lib.mapAttrsToList (from: to: [ "--subst-var-by" from to ]) releases.substitutions);
};
in
''
${lib.optionalString withManuals "cp -f ${substitutedNixManualReference} source/reference/nix-manual.md"}
make html
make latexpdf
'';
installPhase =
let
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
release = version: nix: ''
cp -R --no-preserve=mode ${nix.doc}/share/doc/nix/manual $out/manual/nix/${version}
nix-dev-latex = [
(pkgs.callPackage ./nix/tex-env.nix {
extraTexPackages = {
inherit (pkgs.texlive) latexmk gnu-freefont;
};
})
];
nix-dev = pkgs.stdenv.mkDerivation {
name = "nix-dev";
src = ./.;
nativeBuildInputs = [
nix-dev-python-pkgs
nix-dev-latex
];
buildPhase =
let
substitutedNixManualReference = pkgs.substitute {
src = ./source/reference/nix-manual.md;
substitutions = lib.concatLists (
lib.mapAttrsToList (from: to: [
"--subst-var-by"
from
to
]) releases.substitutions
);
};
in
''
${lib.optionalString withManuals "cp -f ${substitutedNixManualReference} source/reference/nix-manual.md"}
make html
make latexpdf
'';
installPhase =
let
# Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed.
# FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details.
release = version: nix: ''
cp -R --no-preserve=mode ${nix.doc}/share/doc/nix/manual $out/manual/nix/${version}

# add upstream page redirects of the form `<from> <to> <status>`, excluding comments and empty lines
# not all releases have that though
if [[ -f ${nix.doc}/share/doc/nix/manual/_redirects ]]; then
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix.doc}/share/doc/nix/manual/_redirects >> $out/_redirects
fi
# add upstream page redirects of the form `<from> <to> <status>`, excluding comments and empty lines
# not all releases have that though
if [[ -f ${nix.doc}/share/doc/nix/manual/_redirects ]]; then
sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix.doc}/share/doc/nix/manual/_redirects >> $out/_redirects
fi

# provide a single-page view from mdBook's print feature.
# this is hacky but cheap and does work.
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
'';
# Redirects from mutable URLs like /manual/nix/latest/... to /manual/nix/2.21/...
mutableRedirect = mutable: immutable: ''
echo "/manual/nix/${mutable}/* /manual/nix/${immutable}/:splat 302" >> $out/_redirects
'';
in
''
mkdir -p $out/manual/nix
cp -R build/html/* $out/
cp build/latex/nix-dev.pdf $out/
cp netlify.toml $out/
'' + lib.optionalString withManuals ''
${lib.concatStringsSep "\n" (lib.mapAttrsToList release releases.nixReleases)}
${lib.concatStringsSep "\n" (lib.mapAttrsToList mutableRedirect releases.mutableNixManualRedirects)}
# provide a single-page view from mdBook's print feature.
# this is hacky but cheap and does work.
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
'';
};
# Redirects from mutable URLs like /manual/nix/latest/... to /manual/nix/2.21/...
mutableRedirect = mutable: immutable: ''
echo "/manual/nix/${mutable}/* /manual/nix/${immutable}/:splat 302" >> $out/_redirects
'';
in
''
mkdir -p $out/manual/nix
cp -R build/html/* $out/
cp build/latex/nix-dev.pdf $out/
cp netlify.toml $out/
''
+ lib.optionalString withManuals ''
${lib.concatStringsSep "\n" (lib.mapAttrsToList release releases.nixReleases)}
${lib.concatStringsSep "\n" (lib.mapAttrsToList mutableRedirect releases.mutableNixManualRedirects)}
'';
};

devmode = pkgs.devmode.override {
buildArgs = ''-A build --show-trace'';
Expand Down
36 changes: 18 additions & 18 deletions nix/inputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
# {
# <version> = <source>;
# }
nix =
builtins.mapAttrs (name: value:
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
fetchTarball {
name = "source";
url = value.url;
sha256 = value.sha256;
}
) (builtins.fromJSON (builtins.readFile ./nix-versions.json));
nix = builtins.mapAttrs (
name: value:
# This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix
fetchTarball {
name = "source";
url = value.url;
sha256 = value.sha256;
}
) (builtins.fromJSON (builtins.readFile ./nix-versions.json));

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

}
28 changes: 16 additions & 12 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
final: prev: let
python-module-sphinx-sitemap = {
lib,
buildPythonPackage,
fetchPypi,
sphinx,
pytest,
}: let
pname = "sphinx-sitemap";
version = "2.5.1";
in
final: prev:
let
python-module-sphinx-sitemap =
{
lib,
buildPythonPackage,
fetchPypi,
sphinx,
pytest,
}:
let
pname = "sphinx-sitemap";
version = "2.5.1";
in
buildPythonPackage {
inherit pname version;

Expand Down Expand Up @@ -37,7 +40,8 @@ final: prev: let
license = licenses.mit;
};
};
in {
in
{
python310 = prev.python310.override {
packageOverrides = python-final: python-prev: {
sphinx-sitemap = python-module-sphinx-sitemap {
Expand Down
24 changes: 14 additions & 10 deletions nix/releases.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{ lib, inputs, system }:
{
lib,
inputs,
system,
}:
let
# Import Nixpkgs, get the pkgs set back
pkgsFor = source:
pkgsFor =
source:
import source {
inherit system;
config = { };
Expand All @@ -16,9 +21,7 @@ let
# "23.11" = pkgs...;
# "23.05" = pkgs...;
# }
pkgsReleases = lib.mapAttrs (release: source:
pkgsFor source
) inputs.nixpkgs;
pkgsReleases = lib.mapAttrs (release: source: pkgsFor source) inputs.nixpkgs;

# Information on Nixpkgs versions
nixpkgsVersions = rec {
Expand All @@ -33,7 +36,8 @@ let
};

# The Nix version string for a pkgs, e.g. "2.18"
nixVersionForPkgs = pkgs:
nixVersionForPkgs =
pkgs:
# 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.
# This is not a big issue, and simplifies the setup a lot.
lib.versions.majorMinor pkgs.nix.version;
Expand All @@ -44,7 +48,8 @@ let
# "2.19" = { outPath = ...; ... };
# ...
# }
nixReleases = lib.mapAttrs (release: source:
nixReleases = lib.mapAttrs (
release: source:
# XXX: Unfortunately, the use of flake-compat prevents passing `system` with stable Nix...
(import source).default
) inputs.nix;
Expand Down Expand Up @@ -81,9 +86,8 @@ let
substitutions = {
nixpkgs-stable = nixpkgsVersions.latest;
nixpkgs-prev-stable = nixpkgsVersions.prevLatest;
} // lib.mapAttrs' (name: value:
lib.nameValuePair "nix-${name}" value
) mutableNixManualRedirects;
}
// lib.mapAttrs' (name: value: lib.nameValuePair "nix-${name}" value) mutableNixManualRedirects;
in
{
inherit nixReleases mutableNixManualRedirects substitutions;
Expand Down
12 changes: 9 additions & 3 deletions nix/tex-env.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Generated with tex2nix 0.0.0
{ texlive, extraTexPackages ? {} }:
(texlive.combine ({
{
texlive,
extraTexPackages ? { },
}:
(texlive.combine (
{
inherit (texlive) scheme-small;
"amsmath" = texlive."amsmath";
"atbegshi" = texlive."atbegshi";
Expand Down Expand Up @@ -49,4 +53,6 @@
"wrapfig" = texlive."wrapfig";
"xcolor" = texlive."xcolor";

} // extraTexPackages))
}
// extraTexPackages
))
21 changes: 14 additions & 7 deletions nix/update-nix-releases.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{ writeShellApplication
, git
, nix
, ripgrep
, coreutils
, jq
{
writeShellApplication,
git,
nix,
ripgrep,
coreutils,
jq,
}:
# Custom update mechanism for Nix releases in ./nix-versions.json
writeShellApplication {
name = "update-nix-releases";
runtimeInputs = [ git nix ripgrep coreutils jq ];
runtimeInputs = [
git
nix
ripgrep
coreutils
jq
];
text = ''
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
Expand Down
24 changes: 16 additions & 8 deletions nix/update-nixpkgs-releases.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{ writeShellApplication
, git
, npins
, nix
, ripgrep
, coreutils
, jq
{
writeShellApplication,
git,
npins,
nix,
ripgrep,
coreutils,
jq,
}:
# add or update Nixpkgs releases using `npins`
writeShellApplication {
name = "update-nixpkgs-releases";
runtimeInputs = [ git npins nix ripgrep jq coreutils ];
runtimeInputs = [
git
npins
nix
ripgrep
jq
coreutils
];
text = ''
echo >&2 "Updating rolling"
npins update nixpkgs-rolling
Expand Down
6 changes: 3 additions & 3 deletions npins/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
},
"branch": "nixpkgs-unstable",
"submodules": false,
"revision": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1",
"url": "https://github.com/nixos/nixpkgs/archive/fe51d34885f7b5e3e7b59572796e1bcb427eccb1.tar.gz",
"hash": "0pg3ibyagan1y57l1q1rwyrygrwg02p59p0fbgl23hf1nw58asda"
"revision": "2dad7af78a183b6c486702c18af8a9544f298377",
"url": "https://github.com/nixos/nixpkgs/archive/2dad7af78a183b6c486702c18af8a9544f298377.tar.gz",
"hash": "12icrzyc8h6yh5c60wdhaypzc17ygwz664h92jj112pf6whgi2id"
},
"poetry2nix": {
"type": "Git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let
pkgs = import <nixpkgs> {};
pkgs = import <nixpkgs> { };
result = pkgs.lib.evalModules {
modules = [
./options.nix
Expand Down