diff --git a/.drone.yml b/.drone.yml index e613092..956a3db 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,21 +3,20 @@ name: default type: exec steps: - - name: submodules + - name: lfs commands: - - git submodule init - - git submodule update --recursive --remote + - git lfs install + - git lfs pull - name: build commands: - - nix-build + - nix build -L - name: push environment: NETLIFY_AUTH_TOKEN: from_secret: netlify_auth_token commands: - - nix-shell -I nixpkgs=./pkgs.nix --run "netlify deploy --prod -d $(readlink -f result)" - -node: - nix: 1 + - cp --no-preserve=mode -rL result netlify-does-not-follow-symlinks + - nix develop -c netlify deploy --prod -d netlify-does-not-follow-symlinks + - rm -rf netlify-does-not-follow-symlinks diff --git a/.envrc b/.envrc index 1d953f4..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/.gitignore b/.gitignore index 6368f3f..15329b4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,7 @@ # reveal js (generated) /revealjs/*/index.html +# dependencies added by shell hook +/revealjs/_assets/reveal.js + /result diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 26c721c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "revealjs/_assets/reveal.js"] - path = revealjs/_assets/reveal.js - url = https://github.com/hakimel/reveal.js diff --git a/default.nix b/default.nix deleted file mode 100644 index b5cef2e..0000000 --- a/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -let - sources = import ./nix/sources.nix; - pkgs = import sources.nixpkgs {}; - - inherit (import sources.gitignore { inherit (pkgs) lib; }) gitignoreSource; - - python = (pkgs.python38.withPackages (ps: with ps; [ - CommonMark - jinja2 - pyyaml - ])); - - texlive = pkgs.texlive.combine { - inherit (pkgs.texlive) scheme-medium - appendixnumberbeamer - beamertheme-focus - beamertheme-metropolis - biber - biblatex - csquotes - datetime - datetime2 - datetime2-german - enumitem - fmtcount - multirow - pgfopts; - }; -in -pkgs.stdenv.mkDerivation { - name = "presis"; - - nativeBuildInputs = [ - python - texlive - ]; - - src = gitignoreSource ./.; - - FONTCONFIG_FILE = pkgs.makeFontsConf { - fontDirectories = with pkgs; [ - fira - iosevka - ]; - }; - - enableParallelBuilding = true; - - dontFixup = true; - - installPhase = '' - cp -r . $out; - ''; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ca29bdb --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1620759905, + "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1620842550, + "narHash": "sha256-hpJOMy5HOKIOxJ5aJoFuXqYjEbkYrFY7pDlXYWowxLg=", + "owner": "sbruder", + "repo": "nixpkgs", + "rev": "3a4a2227bb38ec1f3c773829f5d724248af9632c", + "type": "github" + }, + "original": { + "owner": "sbruder", + "ref": "fix-netlify-cli", + "repo": "nixpkgs", + "type": "github" + } + }, + "revealjs": { + "flake": false, + "locked": { + "lastModified": 1602496264, + "narHash": "sha256-oN77CUmmvrzObhQbORXAujjb+4IkiYbKVLsi7hddsIM=", + "owner": "hakimel", + "repo": "reveal.js", + "rev": "0582f57517c97a4c7bfeb58762138c78883f94c5", + "type": "github" + }, + "original": { + "owner": "hakimel", + "ref": "4.1.0", + "repo": "reveal.js", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "revealjs": "revealjs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f85d316 --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + inputs = { + #nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + # At the time of writing, netlify-cli’s build is failing on unstable. + nixpkgs.url = "github:sbruder/nixpkgs/fix-netlify-cli"; + flake-utils.url = "github:numtide/flake-utils"; + + revealjs.url = "github:hakimel/reveal.js/4.1.0"; + revealjs.flake = false; + }; + + outputs = { self, flake-utils, nixpkgs, revealjs }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + rec { + packages.sbruder.presis = + let + python = (pkgs.python38.withPackages (ps: with ps; [ + CommonMark + jinja2 + pyyaml + ])); + + texlive = pkgs.texlive.combine { + inherit (pkgs.texlive) + scheme-medium + appendixnumberbeamer + beamertheme-focus + beamertheme-metropolis + biber + biblatex + csquotes + datetime + datetime2 + datetime2-german + enumitem + fmtcount + multirow + pgfopts; + }; + in + pkgs.stdenv.mkDerivation { + name = "sbruder-presis"; + + nativeBuildInputs = [ + python + texlive + ]; + + src = self; + + FONTCONFIG_FILE = pkgs.makeFontsConf { + fontDirectories = with pkgs; [ + fira + iosevka + ]; + }; + + enableParallelBuilding = true; + + configurePhase = '' + ln -sfT ${revealjs} revealjs/_assets/reveal.js + ''; + + installPhase = '' + cp -r . $out; + ''; + + dontFixup = true; + }; + + defaultPackage = packages.sbruder.presis; + + devShell = pkgs.mkShell { + buildInputs = packages.sbruder.presis.nativeBuildInputs ++ (with pkgs; [ + bash + netlify-cli + ]); + + shellHook = packages.sbruder.presis.configurePhase; + }; + }); +} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 3fb6420..0000000 --- a/nix/sources.json +++ /dev/null @@ -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///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "release-20.09", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "99f8282a65821f148df596ba389606e732eaf99d", - "sha256": "1mm4j1vjs875yzv03plng43ivny0qm09hxpn0if8g9vc849rwc2g", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/99f8282a65821f148df596ba389606e732eaf99d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index b64b8f8..0000000 --- a/nix/sources.nix +++ /dev/null @@ -1,148 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of 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 = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (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); } diff --git a/pkgs.nix b/pkgs.nix deleted file mode 100644 index 4ccc1ca..0000000 --- a/pkgs.nix +++ /dev/null @@ -1 +0,0 @@ -import (import ./nix/sources.nix).nixpkgs diff --git a/revealjs/_assets/reveal.js b/revealjs/_assets/reveal.js deleted file mode 160000 index 15815ef..0000000 --- a/revealjs/_assets/reveal.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 15815efe05ca69c35ce66cfdbf93316e1db66ecb diff --git a/shell.nix b/shell.nix deleted file mode 100644 index d4cf217..0000000 --- a/shell.nix +++ /dev/null @@ -1,9 +0,0 @@ -let - pkgs = import (import ./nix/sources.nix).nixpkgs {}; -in -(import ./default.nix).overrideAttrs(o: o // { - nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [ - bash - netlify-cli - ]); -})