Convert to flake
This commit is contained in:
parent
5563e08a37
commit
cb5792e729
|
@ -5,4 +5,5 @@ type: exec
|
|||
steps:
|
||||
- name: build
|
||||
commands:
|
||||
- nix-build
|
||||
- nix build -L
|
||||
- readlink -f result
|
||||
|
|
143
default.nix
143
default.nix
|
@ -1,143 +0,0 @@
|
|||
let
|
||||
sources = import ./nix/sources.nix;
|
||||
pkgs = import sources.nixpkgs {};
|
||||
inherit (import sources.gitignore { inherit (pkgs) lib; }) gitignoreSource;
|
||||
|
||||
stdenv = pkgs.stdenv;
|
||||
|
||||
python3Packages = pkgs.python3Packages;
|
||||
buildPythonPackage = python3Packages.buildPythonPackage;
|
||||
fetchPypi = python3Packages.fetchPypi;
|
||||
|
||||
lunr = buildPythonPackage rec {
|
||||
pname = "lunr";
|
||||
version = "0.5.8";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0vn2j5iyy40sv0f4v8nin5n5xs4a020g6gcbcgfpbxzgk0xhdyy4";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
future
|
||||
six
|
||||
];
|
||||
|
||||
checkInputs = with python3Packages; [
|
||||
mock
|
||||
pytest
|
||||
];
|
||||
};
|
||||
|
||||
# FIXME: use nixpkgs’s mkdocs once it is ≥1.1
|
||||
mkdocs = buildPythonPackage rec {
|
||||
pname = "mkdocs";
|
||||
version = "1.1.2";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0fgv5zawpyyv0vd4j5y8m4h058lh9jkwfcm0xy4pg7dr09a1xdph";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = (with python3Packages; [
|
||||
backports_tempfile
|
||||
click
|
||||
jinja2
|
||||
livereload
|
||||
markdown
|
||||
nltk
|
||||
pyyaml
|
||||
tornado
|
||||
]) ++ [
|
||||
lunr
|
||||
];
|
||||
|
||||
doCheck = false; # circular depdendency
|
||||
};
|
||||
|
||||
pymdown-extensions = buildPythonPackage rec {
|
||||
pname = "pymdown-extensions";
|
||||
version = "8.0.1";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "07p5xks6qf73nbv0qb7jrspkpmxdyr7dpxv3rnkh9p2b5l2h99wv";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
markdown
|
||||
];
|
||||
|
||||
doCheck = false; # they fail?
|
||||
};
|
||||
|
||||
mkdocs-material-extensions = buildPythonPackage rec {
|
||||
pname = "mkdocs-material-extensions";
|
||||
version = "1.0.1";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "13y617sql4hqs376c3dfcb6v7q41km9x7fh52k3f74a2brzzniv9";
|
||||
};
|
||||
|
||||
# circular dependency
|
||||
doCheck = false;
|
||||
postPatch = ''
|
||||
sed -i 's/mkdocs-material>=5.0.0//' requirements/project.txt
|
||||
'';
|
||||
};
|
||||
|
||||
mkdocs-material = buildPythonPackage rec {
|
||||
pname = "mkdocs-material";
|
||||
version = "6.1.2";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0yifc1df94rsaxy72hqnhjkv4c50c30j5kg0yxybkxy07p7kafic";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = (with python3Packages; [
|
||||
markdown
|
||||
pygments
|
||||
]) ++ [
|
||||
mkdocs
|
||||
mkdocs-material-extensions
|
||||
pymdown-extensions
|
||||
];
|
||||
};
|
||||
|
||||
iosevka-web = stdenv.mkDerivation rec {
|
||||
pname = "iosevka-web";
|
||||
version = "3.7.1";
|
||||
|
||||
src = pkgs.fetchzip {
|
||||
url = "https://github.com/be5invis/Iosevka/releases/download/v${version}/pkg-iosevka-${version}.zip";
|
||||
sha256 = "0d012aqfnyqlpl4smfa2x2qz2qmbbfxb6jr4awv8gp6r359rc9k1";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r woff woff2 ttf *.css $out
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "wiki";
|
||||
|
||||
src = gitignoreSource ./.;
|
||||
|
||||
buildPhase = "mkdocs build -d $out";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/assets/fonts
|
||||
ln -s ${iosevka-web} $out/assets/fonts/iosevka
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
mkdocs
|
||||
mkdocs-material
|
||||
];
|
||||
}
|
43
flake.lock
Normal file
43
flake.lock
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1619345332,
|
||||
"narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1619796933,
|
||||
"narHash": "sha256-Tw9QyuOL8ROhMKkpYBmj8r8h9ehEn9JKhZ+VyK4OfMI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c8dff328e51f62760bf646bc345e3aabcfd82046",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
189
flake.nix
Normal file
189
flake.nix
Normal file
|
@ -0,0 +1,189 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
rec {
|
||||
packages = nixpkgs.lib.mapAttrs
|
||||
(name: value: pkgs.python3Packages.callPackage value { })
|
||||
{
|
||||
lunr =
|
||||
{ buildPythonPackage, fetchPypi, future, six, mock, pytest }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "lunr";
|
||||
version = "0.5.8";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0vn2j5iyy40sv0f4v8nin5n5xs4a020g6gcbcgfpbxzgk0xhdyy4";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
future
|
||||
six
|
||||
];
|
||||
|
||||
checkInputs = [
|
||||
mock
|
||||
pytest
|
||||
];
|
||||
};
|
||||
|
||||
# FIXME: use nixpkgs’s mkdocs once it is ≥1.1
|
||||
mkdocs =
|
||||
{ buildPythonPackage
|
||||
, fetchPypi
|
||||
, backports_tempfile
|
||||
, click
|
||||
, jinja2
|
||||
, livereload
|
||||
, markdown
|
||||
, nltk
|
||||
, pyyaml
|
||||
, tornado
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "mkdocs";
|
||||
version = "1.1.2";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0fgv5zawpyyv0vd4j5y8m4h058lh9jkwfcm0xy4pg7dr09a1xdph";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
backports_tempfile
|
||||
click
|
||||
jinja2
|
||||
livereload
|
||||
markdown
|
||||
nltk
|
||||
pyyaml
|
||||
tornado
|
||||
|
||||
packages.lunr
|
||||
];
|
||||
|
||||
doCheck = false; # circular depdendency
|
||||
};
|
||||
|
||||
pymdown-extensions =
|
||||
{ buildPythonPackage, fetchPypi, markdown }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "pymdown-extensions";
|
||||
version = "8.0.1";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "07p5xks6qf73nbv0qb7jrspkpmxdyr7dpxv3rnkh9p2b5l2h99wv";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
markdown
|
||||
];
|
||||
|
||||
doCheck = false; # they fail?
|
||||
};
|
||||
|
||||
mkdocs-material-extensions =
|
||||
{ buildPythonPackage, fetchPypi }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "mkdocs-material-extensions";
|
||||
version = "1.0.1";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "13y617sql4hqs376c3dfcb6v7q41km9x7fh52k3f74a2brzzniv9";
|
||||
};
|
||||
|
||||
# circular dependency
|
||||
doCheck = false;
|
||||
postPatch = ''
|
||||
sed -i 's/mkdocs-material>=5.0.0//' requirements/project.txt
|
||||
'';
|
||||
};
|
||||
|
||||
mkdocs-material =
|
||||
{ buildPythonPackage, fetchPypi, markdown, pygments }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "mkdocs-material";
|
||||
version = "6.1.2";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0yifc1df94rsaxy72hqnhjkv4c50c30j5kg0yxybkxy07p7kafic";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
markdown
|
||||
pygments
|
||||
|
||||
packages.mkdocs
|
||||
packages.mkdocs-material-extensions
|
||||
packages.pymdown-extensions
|
||||
];
|
||||
};
|
||||
|
||||
iosevka-web =
|
||||
{ stdenv, fetchzip }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "iosevka-web";
|
||||
version = "3.7.1";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://github.com/be5invis/Iosevka/releases/download/v${version}/pkg-iosevka-${version}.zip";
|
||||
sha256 = "0d012aqfnyqlpl4smfa2x2qz2qmbbfxb6jr4awv8gp6r359rc9k1";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r woff woff2 ttf *.css $out
|
||||
'';
|
||||
};
|
||||
|
||||
wiki =
|
||||
{ stdenv }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "wiki";
|
||||
|
||||
src = self;
|
||||
|
||||
buildPhase = "mkdocs build -d $out";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/assets/fonts
|
||||
ln -s ${packages.iosevka-web} $out/assets/fonts/iosevka
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
packages.mkdocs
|
||||
packages.mkdocs-material
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
defaultPackage = packages.wiki;
|
||||
|
||||
apps = {
|
||||
serve = pkgs.writeShellScriptBin "serve" ''
|
||||
${pkgs.miniserve}/bin/miniserve --index index.html ${packages.wiki}
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"gitignore": {
|
||||
"branch": "master",
|
||||
"description": "Nix function for filtering local git sources",
|
||||
"homepage": "",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore",
|
||||
"rev": "c4662e662462e7bf3c2a968483478a665d00e717",
|
||||
"sha256": "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/hercules-ci/gitignore/archive/c4662e662462e7bf3c2a968483478a665d00e717.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "nixos-unstable",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "34ad166a830d3ac1541dcce571c52231f2f0865a",
|
||||
"sha256": "1jvi1562x3kq65w642vfimpszv65zbc7c2nv8gakhzcx4n3f47xq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/34ad166a830d3ac1541dcce571c52231f2f0865a.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
148
nix/sources.nix
148
nix/sources.nix
|
@ -1,148 +0,0 @@
|
|||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
|
||||
# sanitize the name, though nix will still fail if name starts with period
|
||||
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
fetch_builtin-tarball = name: throw
|
||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
|
||||
fetch_builtin-url = name: throw
|
||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||
# the path directly as opposed to the fetched source.
|
||||
replace = name: drv:
|
||||
let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else ersatz;
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# 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));
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit name url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
Loading…
Reference in a new issue