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
8 changes: 4 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs ? import ./nix/inputs.nix,
system ? builtins.currentSystem,
pkgs ? import inputs.nixpkgs."23.05" {
pkgs ? import inputs.nixpkgs."25.05" {
config = { };
overlays = [ (import ./nix/overlay.nix) ];
inherit system;
Expand All @@ -21,7 +21,7 @@ let
pkgs.stdenv.mkDerivation {
name = "nix-dev";
src = ./.;
nativeBuildInputs = with pkgs.python310.pkgs; [
nativeBuildInputs = with pkgs.python3.pkgs; [
linkify-it-py
myst-parser
sphinx
Expand All @@ -36,7 +36,7 @@ let
let
substitutedNixManualReference = pkgs.substitute {
src = ./source/reference/nix-manual.md;
replacements = lib.concatLists (lib.mapAttrsToList (from: to: [ "--subst-var-by" from to ]) releases.substitutions);
substitutions = lib.concatLists (lib.mapAttrsToList (from: to: [ "--subst-var-by" from to ]) releases.substitutions);
};
in
''
Expand Down Expand Up @@ -92,7 +92,7 @@ in
update-nix-releases
update-nixpkgs-releases
pkgs.npins
pkgs.python310.pkgs.black
pkgs.python3.pkgs.black
pkgs.vale
pkgs.netlify-cli
];
Expand Down
2 changes: 1 addition & 1 deletion maintainers/google-season-of-docs-2024.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Google Season of Docs 2024: write Nix docker and cross compilation guides
# Google season of docs 2024: write Nix docker and cross compilation guides

## About Nix

Expand Down
146 changes: 146 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
This file is provided under the MIT licence:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range =
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";

# If the environment variable NPINS_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
# (Taken from Niv for compatibility)
mayOverride =
name: path:
let
envVarName = "NPINS_OVERRIDE_${saneName}";
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv envVarName;
in
if ersatz == "" then
path
else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
if builtins.substring 0 1 ersatz == "/" then
/. + ersatz
else
/. + builtins.getEnv "PWD" + "/${ersatz}"
);

mkSource =
name: spec:
assert spec ? type;
let
path =
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else if spec.type == "Tarball" then
mkTarballSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = mayOverride name path; };

mkGitSource =
{
repository,
revision,
url ? null,
submodules,
hash,
branch ? null,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null && !submodules then
builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
}
else
let
url =
if repository.type == "Git" then
repository.url
else if repository.type == "GitHub" then
"https://github.com/${repository.owner}/${repository.repo}.git"
else if repository.type == "GitLab" then
"${repository.server}/${repository.repo_path}.git"
else
throw "Unrecognized repository type ${repository.type}";
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;

short = builtins.substring 0 7 rev;

appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName url revision;
in
builtins.fetchGit {
rev = revision;
inherit name;
# hash = hash;
inherit url submodules;
};

mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};

mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};

mkTarballSource =
{
url,
locked_url ? url,
hash,
...
}:
builtins.fetchTarball {
url = locked_url;
sha256 = hash;
};
in
if version == 5 then
builtins.mapAttrs mkSource data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
14 changes: 10 additions & 4 deletions nix/inputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# {
# <name> = <source>;
# }
main = import ../npins { };
main = import ../npins;

# Sources for Nix releases, the attribute name is the release version.
# These are done specially because updating these is non-trivial.
Expand All @@ -26,8 +26,14 @@
# 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 = import ../npins {
json = ./sources.json;
};
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;

}
134 changes: 21 additions & 113 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,113 +1,5 @@
{
"pins": {
"18.09": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-18.09",
"revision": "a7e559a5504572008567383c3dc8e142fa7a8633",
"url": "https://github.com/nixos/nixpkgs/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz",
"hash": "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6"
},
"19.03": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-19.03",
"revision": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59",
"url": "https://github.com/nixos/nixpkgs/archive/34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59.tar.gz",
"hash": "11z6ajj108fy2q5g8y4higlcaqncrbjm3dnv17pvif6avagw4mcb"
},
"19.09": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-19.09",
"revision": "75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1",
"url": "https://github.com/nixos/nixpkgs/archive/75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1.tar.gz",
"hash": "157c64220lf825ll4c0cxsdwg7cxqdx4z559fdp7kpz0g6p8fhhr"
},
"20.03": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-20.03",
"revision": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205",
"url": "https://github.com/nixos/nixpkgs/archive/1db42b7fe3878f3f5f7a4f2dc210772fd080e205.tar.gz",
"hash": "05k9y9ki6jhaqdhycnidnk5zrdzsdammbk5lsmsbz249hjhhgcgh"
},
"20.09": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-20.09",
"revision": "1c1f5649bb9c1b0d98637c8c365228f57126f361",
"url": "https://github.com/nixos/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz",
"hash": "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl"
},
"21.05": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-21.05",
"revision": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf",
"url": "https://github.com/nixos/nixpkgs/archive/022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf.tar.gz",
"hash": "12q00nbd7fb812zchbcnmdg3pw45qhxm74hgpjmshc2dfmgkjh4n"
},
"21.11": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-21.11",
"revision": "eabc38219184cc3e04a974fe31857d8e0eac098d",
"url": "https://github.com/nixos/nixpkgs/archive/eabc38219184cc3e04a974fe31857d8e0eac098d.tar.gz",
"hash": "04ffwp2gzq0hhz7siskw6qh9ys8ragp7285vi1zh8xjksxn1msc5"
},
"22.05": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-22.05",
"revision": "380be19fbd2d9079f677978361792cb25e8a3635",
"url": "https://github.com/nixos/nixpkgs/archive/380be19fbd2d9079f677978361792cb25e8a3635.tar.gz",
"hash": "154x9swf494mqwi4z8nbq2f0sp8pwp4fvx51lqzindjfbb9yxxv5"
},
"22.11": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-22.11",
"revision": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
"url": "https://github.com/nixos/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz",
"hash": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll"
},
"23.05": {
"type": "Git",
"repository": {
Expand All @@ -116,6 +8,7 @@
"repo": "nixpkgs"
},
"branch": "nixos-23.05",
"submodules": false,
"revision": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421",
"url": "https://github.com/nixos/nixpkgs/archive/70bdadeb94ffc8806c0570eb5c2695ad29f0e421.tar.gz",
"hash": "05cbl1k193c9la9xhlz4y6y8ijpb2mkaqrab30zij6z4kqgclsrd"
Expand All @@ -128,6 +21,7 @@
"repo": "nixpkgs"
},
"branch": "nixos-23.11",
"submodules": false,
"revision": "205fd4226592cc83fd4c0885a3e4c9c400efabb5",
"url": "https://github.com/nixos/nixpkgs/archive/205fd4226592cc83fd4c0885a3e4c9c400efabb5.tar.gz",
"hash": "1f5d2g1p6nfwycpmrnnmc2xmcszp804adp16knjvdkj8nz36y1fg"
Expand All @@ -140,6 +34,7 @@
"repo": "nixpkgs"
},
"branch": "nixos-24.05",
"submodules": false,
"revision": "b134951a4c9f3c995fd7be05f3243f8ecd65d798",
"url": "https://github.com/nixos/nixpkgs/archive/b134951a4c9f3c995fd7be05f3243f8ecd65d798.tar.gz",
"hash": "0zydsqiaz8qi4zd63zsb2gij2p614cgkcaisnk11wjy3nmiq0x1s"
Expand All @@ -152,11 +47,24 @@
"repo": "nixpkgs"
},
"branch": "nixos-24.11",
"revision": "62c435d93bf046a5396f3016472e8f7c8e2aed65",
"url": "https://github.com/nixos/nixpkgs/archive/62c435d93bf046a5396f3016472e8f7c8e2aed65.tar.gz",
"hash": "0zpvadqbs19jblnd0j2rfs9m7j0n5spx0vilq8907g2gqrx63fqp"
"submodules": false,
"revision": "2baa12ff69913392faf0ace833bc54bba297ea95",
"url": "https://github.com/nixos/nixpkgs/archive/2baa12ff69913392faf0ace833bc54bba297ea95.tar.gz",
"hash": "0b98zjp4klps935sch2n0mysfr3l9sz13d2r74dsgnsnklsxm0ak"
},
"25.05": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nixos",
"repo": "nixpkgs"
},
"branch": "nixos-25.05",
"submodules": false,
"revision": "55d1f923c480dadce40f5231feb472e81b0bab48",
"url": "https://github.com/nixos/nixpkgs/archive/55d1f923c480dadce40f5231feb472e81b0bab48.tar.gz",
"hash": "0i0ayb1p7ypbjnjf837qlfn6n3i3468cvalha54yakjdi6a6srnb"
}
},
"version": 3
"version": 5
}

Loading