blob: ae6273e3ba3555a320c035bc27275490546ad220 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
{
description = "Mashup of various utility functions that I use often.";
inputs = {
systems.url = "github:nix-systems/default";
};
outputs =
{ self, ... }:
let
systems = (import self.inputs.systems);
in
{
lib = {
# Equivalent to flake-utils' eachDefaultSystem
# Taken from flake-utils
eachSystem =
f:
let
# Merge together the outptus for all systems
op =
attrs: system:
let
ret = f system;
op =
attrs: key:
attrs
// {
${key} = (attrs.${key} or { }) // {
${system} = ret.${key};
};
};
in
builtins.foldl' op attrs (builtins.attrNames ret);
in
builtins.foldl' op { } (
systems
++
# add the current system if --impure is used
(
if builtins ? currentSystem then
if builtins.elem builtins.currentSystem systems then [ ] else [ builtins.currentSystem ]
else
[ ]
)
);
# Like mkShell, but with less dependencies.
# Taken from https://fzakaria.com/2021/08/02/a-minimal-nix-shell.html
minimalMkShell =
pkgs:
let
stdenvMinimal = pkgs.stdenvNoCC.override {
cc = null;
preHook = "";
allowedRequisites = null;
initialPath = pkgs.lib.filter (
a: pkgs.lib.hasPrefix "coreutils" a.name
) pkgs.stdenvNoCC.initialPath;
extraNativeBuildInputs = [ ];
};
in
pkgs.mkShell.override { stdenv = stdenvMinimal; };
};
templates = {
eachSystem = {
path = ./examples/simple;
description = "Example showing off a few simple functions.";
};
};
};
}
|