-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.nix
executable file
·37 lines (34 loc) · 1.01 KB
/
bootstrap.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env nix-build
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
# This file is used to tangle the contents of this repo into a usable form
# Also, yes this is metaprogramming!
let myNUR = builtins.getFlake "git+https://git.sr.ht/~hutzdog/NUR"; in
{ system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { inherit system; }
, lmt ? myNUR.packages."${system}".lmt
, path ? ./.
}:
pkgs.stdenv.mkDerivation {
name = "tangle";
nativeBuildInputs = [ lmt ];
src = builtins.path {
filter = p: t: let
bn = baseNameOf p;
inherit (pkgs) lib;
in t != "symlink" && (t != "directory" || bn != "out") && !(bn == "index.md") && !(lib.hasPrefix "." bn);
inherit path;
name = "src";
};
buildPhase = ''
export PATHS=$(find ./ -type f -name '*.md')
lmt $PATHS
rm -rf $PATHS
'';
installPhase = ''
cp -r ./ "$out"
'';
}