tangled
alpha
login
or
join now
oeiuwq.com
/
den
8
fork
atom
Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/
den.oeiuwq.com
configurations
den
dendritic
nix
aspect
oriented
8
fork
atom
overview
issues
4
pulls
2
pipelines
move denShell apps to den.lib
oeiuwq.com
2 weeks ago
4bbaa294
1254aaeb
1/1
mirror.yml
success
3s
+98
-67
5 changed files
expand all
collapse all
unified
split
modules
context
types.nix
nix
lib.nix
nh.nix
templates
noflake
default.nix
modules
nh.nix
+1
-2
modules/context/types.nix
reviewed
···
1
1
{ den, lib, ... }:
2
2
let
3
3
inherit (den.lib.aspects.types) aspectSubmodule;
4
4
-
5
5
-
ctxApply = import ./../../nix/ctx-apply.nix { inherit lib den; };
4
4
+
inherit (den.lib) ctxApply;
6
5
7
6
# a context-definiton is an aspect extended with into.* transformations
8
7
# and a fixed functor to apply them.
+14
nix/lib.nix
reviewed
···
5
5
...
6
6
}:
7
7
let
8
8
+
inherit (config) den;
8
9
9
10
# "Just Give 'Em One of These" - Moe Szyslak
10
11
# A __functor that applies context to parametric includes (functions)
···
103
104
104
105
__findFile = import ./den-brackets.nix { inherit lib config; };
105
106
107
107
+
nh = import ./nh.nix {
108
108
+
inherit
109
109
+
lib
110
110
+
config
111
111
+
den
112
112
+
inputs
113
113
+
;
114
114
+
};
115
115
+
116
116
+
ctxApply = import ./ctx-apply.nix { inherit lib den; };
117
117
+
106
118
den-lib = {
107
119
inherit
108
120
parametric
···
114
126
canTake
115
127
take
116
128
isStatic
129
129
+
ctxApply
130
130
+
nh
117
131
;
118
132
};
119
133
in
+75
nix/nh.nix
reviewed
···
1
1
+
# Provides shell utilities under `den.sh` for building OS configurations using
2
2
+
# github:nix-community/nh instead of nixos-rebuild, etc
3
3
+
{ lib, den, ... }:
4
4
+
let
5
5
+
defaultAction = "build";
6
6
+
7
7
+
denShell =
8
8
+
pkgs:
9
9
+
pkgs.mkShell {
10
10
+
buildInputs = [ pkgs.nh ] ++ (denApps pkgs);
11
11
+
};
12
12
+
13
13
+
hosts = lib.concatMap lib.attrValues (lib.attrValues den.hosts);
14
14
+
homes = lib.concatMap lib.attrValues (lib.attrValues den.homes);
15
15
+
16
16
+
hostApps = pkgs: map (os pkgs) hosts;
17
17
+
homeApps = pkgs: map (hm pkgs) homes;
18
18
+
denApps = pkgs: (hostApps pkgs) ++ (homeApps pkgs);
19
19
+
20
20
+
os =
21
21
+
pkgs: host:
22
22
+
pkgs.writeShellApplication {
23
23
+
name = host.name;
24
24
+
runtimeInputs = [ pkgs.nh ];
25
25
+
text =
26
26
+
let
27
27
+
command =
28
28
+
{
29
29
+
darwin = "darwin";
30
30
+
nixos = "os";
31
31
+
}
32
32
+
.${host.class};
33
33
+
attr = lib.concatStringsSep "." ([ "flake" ] ++ host.intoAttr);
34
34
+
args = lib.concatStringsSep " " [
35
35
+
"--file"
36
36
+
"."
37
37
+
attr
38
38
+
];
39
39
+
in
40
40
+
''
41
41
+
action="''${1:-${defaultAction}}"
42
42
+
shift || true
43
43
+
exec nh ${command} "$action" ${args} "$@"
44
44
+
'';
45
45
+
};
46
46
+
47
47
+
hm =
48
48
+
pkgs: home:
49
49
+
pkgs.writeShellApplication {
50
50
+
name = home.name;
51
51
+
runtimeInputs = [ pkgs.nh ];
52
52
+
text =
53
53
+
let
54
54
+
attr = lib.concatStringsSep "." ([ "flake" ] ++ home.intoAttr);
55
55
+
args = lib.concatStringsSep " " [
56
56
+
"--file"
57
57
+
"."
58
58
+
attr
59
59
+
];
60
60
+
in
61
61
+
''
62
62
+
action="''${1:-${defaultAction}}"
63
63
+
shift || true
64
64
+
exec nh home "$action" ${args} "$@"
65
65
+
'';
66
66
+
};
67
67
+
in
68
68
+
{
69
69
+
inherit
70
70
+
denShell
71
71
+
homeApps
72
72
+
hostApps
73
73
+
denApps
74
74
+
;
75
75
+
}
+1
-1
templates/noflake/default.nix
reviewed
···
2
2
sources = import ./npins;
3
3
with-inputs = import sources.with-inputs sources {
4
4
# uncomment for local checkout on CI
5
5
-
# den.outPath = ./../..;
5
5
+
den.outPath = ./../..;
6
6
};
7
7
8
8
outputs =
+7
-64
templates/noflake/modules/nh.nix
reviewed
···
1
1
# Provides shell utilities under `den.sh` for building OS configurations using
2
2
# github:nix-community/nh instead of nixos-rebuild, etc
3
3
-
{ lib, den, inputs, ... }:
4
4
-
let
5
5
-
defaultAction = "build";
6
6
-
7
7
-
denShell =
8
8
-
pkgs:
9
9
-
pkgs.mkShell {
10
10
-
buildInputs = [ pkgs.nh ] ++ (denApps pkgs);
11
11
-
};
12
12
-
13
13
-
hosts = lib.concatMap lib.attrValues (lib.attrValues den.hosts);
14
14
-
homes = lib.concatMap lib.attrValues (lib.attrValues den.homes);
15
15
-
16
16
-
denApps = pkgs: (map (os pkgs) hosts) ++ (map (hm pkgs) homes);
17
17
-
18
18
-
os =
19
19
-
pkgs: host:
20
20
-
pkgs.writeShellApplication {
21
21
-
name = host.name;
22
22
-
runtimeInputs = [ pkgs.nh ];
23
23
-
text =
24
24
-
let
25
25
-
command =
26
26
-
{
27
27
-
darwin = "darwin";
28
28
-
nixos = "os";
29
29
-
}
30
30
-
.${host.class};
31
31
-
attr = lib.concatStringsSep "." ([ "flake" ] ++ host.intoAttr);
32
32
-
args = lib.concatStringsSep " " [
33
33
-
"--file"
34
34
-
"."
35
35
-
attr
36
36
-
];
37
37
-
in
38
38
-
''
39
39
-
action="''${1:-${defaultAction}}"
40
40
-
shift || true
41
41
-
exec nh ${command} "$action" ${args} "$@"
42
42
-
'';
43
43
-
};
44
44
-
45
45
-
hm =
46
46
-
pkgs: home:
47
47
-
pkgs.writeShellApplication {
48
48
-
name = home.name;
49
49
-
runtimeInputs = [ pkgs.nh ];
50
50
-
text =
51
51
-
let
52
52
-
attr = lib.concatStringsSep "." ([ "flake" ] ++ home.intoAttr);
53
53
-
args = lib.concatStringsSep " " [
54
54
-
"--file"
55
55
-
"."
56
56
-
attr
57
57
-
];
58
58
-
in
59
59
-
''
60
60
-
action="''${1:-${defaultAction}}"
61
61
-
shift || true
62
62
-
exec nh home "$action" ${args} "$@"
63
63
-
'';
64
64
-
};
65
65
-
in
3
3
+
{
4
4
+
lib,
5
5
+
den,
6
6
+
inputs,
7
7
+
...
8
8
+
}:
66
9
{
67
10
options.den.sh = lib.mkOption {
68
11
description = "Non-flake Den shell environment";
69
69
-
default = denShell (import inputs.nixpkgs { });
12
12
+
default = den.lib.nh.denShell (import inputs.nixpkgs { });
70
13
};
71
14
}