File tree Expand file tree Collapse file tree 16 files changed +127
-125
lines changed Expand file tree Collapse file tree 16 files changed +127
-125
lines changed Original file line number Diff line number Diff line change 38
38
} ;
39
39
outputs = inputs : let
40
40
blockTypes = import ./src/blocktypes.nix { inherit ( inputs ) nixpkgs ; } ;
41
+ sharedActions = import ./src/actions.nix { inherit ( inputs ) nixpkgs ; } ;
41
42
deSystemize = inputs . nosys . lib . deSys ;
42
43
grow = import ./src/grow.nix {
43
44
inherit ( inputs ) nixpkgs yants ;
58
59
in
59
60
{
60
61
inherit ( inputs ) yants dmerge incl ; # convenience re-exports
61
- inherit blockTypes ;
62
+ inherit blockTypes sharedActions ;
62
63
inherit ( blockTypes ) runnables installables functions data devshells containers files microvms nixago nomadJobManifests ;
63
64
inherit grow growOn deSystemize pick harvest winnow ;
64
65
systems = l . systems . doubles ;
Original file line number Diff line number Diff line change
1
+ { nixpkgs } : let
2
+ l = nixpkgs . lib // builtins ;
3
+ mkCommand = import ./mkCommand.nix { inherit nixpkgs ; } ;
4
+
5
+ contextFreeDrv = target : l . unsafeDiscardStringContext target . drvPath ;
6
+
7
+ build = system : target :
8
+ mkCommand system {
9
+ name = "build" ;
10
+ description = "build it" ;
11
+ command = ''
12
+ # ${ target }
13
+ nix build ${ contextFreeDrv target }
14
+ '' ;
15
+ targetDrv = target . drvPath ;
16
+ proviso =
17
+ # bash
18
+ ''
19
+ function proviso() {
20
+ local -n input=$1
21
+ local -n output=$2
22
+
23
+ local drvs
24
+ local -a uncached
25
+
26
+ # FIXME: merge upstream to avoid any need for runtime context
27
+ command nix build github:divnix/nix-uncached/v2.12.1
28
+
29
+ drvs="$(command jq -r '.targetDrv | select(. != "null")' <<< "'' ${input[@]}")"
30
+
31
+ mapfile -t uncached < <(command nix show-derivation $drvs | jq -r '.[].outputs.out.path' | result/bin/nix-uncached)
32
+
33
+ if [[ -n '' ${uncached[*]} ]]; then
34
+ mapfile -t uncached < <(command nix show-derivation '' ${uncached[@]} \
35
+ | command jq -r '.| to_entries[] | select(.value|.env.preferLocalBuild != "1") | .key')
36
+ fi
37
+
38
+ if [[ -n '' ${uncached[*]} ]]; then
39
+ local list filtered
40
+
41
+ list=$(command jq -ncR '[inputs]' <<< "'' ${uncached[@]}")
42
+ filtered=$(command jq -c 'select([.targetDrv] | inside($p))' --argjson p "$list" <<< "'' ${input[@]}")
43
+
44
+ output=$(command jq -cs '. += $p' --argjson p "$output" <<< "$filtered")
45
+ fi
46
+ }
47
+ '' ;
48
+ } ;
49
+
50
+ run = system : target : let
51
+ programName =
52
+ target . meta . mainProgram
53
+ or ( l . getName target ) ;
54
+ in
55
+ mkCommand system {
56
+ name = "run" ;
57
+ description = "run it" ;
58
+ # this is the exact sequence mentioned by the `nix run` docs
59
+ # and so should be compatible
60
+ command = ''
61
+ ${ target . program or "${ target } /bin/${ programName } " } "$@"
62
+ '' ;
63
+ } ;
64
+ in { inherit build run ; }
Original file line number Diff line number Diff line change 1
1
{ nixpkgs } : let
2
- mkCommand = system : type : args :
3
- args
4
- // {
5
- command = ( nixpkgs . legacyPackages . ${ system } . writeShellScript "${ type } -${ args . name } " args . command ) . overrideAttrs ( self : {
6
- passthru =
7
- self . passthru
8
- or { }
9
- // nixpkgs . lib . optionalAttrs ( args ? proviso ) {
10
- proviso = builtins . toFile "${ args . name } -proviso" args . proviso ;
11
- }
12
- // nixpkgs . lib . optionalAttrs ( args ? targetDrv ) {
13
- inherit ( args ) targetDrv ;
14
- } ;
15
- } ) ;
16
- } ;
2
+ sharedActions = import ./actions.nix { inherit nixpkgs ; } ;
3
+ mkCommand = import ./mkCommand.nix { inherit nixpkgs ; } ;
17
4
in {
18
- runnables = import ./blocktypes/runnables.nix { inherit nixpkgs mkCommand ; } ;
19
- installables = import ./blocktypes/installables.nix { inherit nixpkgs mkCommand ; } ;
5
+ runnables = import ./blocktypes/runnables.nix { inherit nixpkgs mkCommand sharedActions ; } ;
6
+ installables = import ./blocktypes/installables.nix { inherit nixpkgs mkCommand sharedActions ; } ;
20
7
functions = import ./blocktypes/functions.nix { inherit nixpkgs mkCommand ; } ;
21
8
data = import ./blocktypes/data.nix { inherit nixpkgs mkCommand ; } ;
22
- devshells = import ./blocktypes/devshells.nix { inherit nixpkgs mkCommand ; } ;
23
- containers = import ./blocktypes/containers.nix { inherit nixpkgs mkCommand ; } ;
9
+ devshells = import ./blocktypes/devshells.nix { inherit nixpkgs mkCommand sharedActions ; } ;
10
+ containers = import ./blocktypes/containers.nix { inherit nixpkgs mkCommand sharedActions ; } ;
24
11
files = import ./blocktypes/files.nix { inherit nixpkgs mkCommand ; } ;
25
12
microvms = import ./blocktypes/microvms.nix { inherit nixpkgs mkCommand ; } ;
26
13
nixago = import ./blocktypes/nixago.nix { inherit nixpkgs mkCommand ; } ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 25
25
} : let
26
26
cmd = "arion --prebuilt-file ${ target . config . out . dockerComposeYaml } " ;
27
27
in [
28
- ( mkCommand system "arion" {
28
+ ( mkCommand system {
29
29
name = "up" ;
30
30
description = "arion up" ;
31
31
command = ''
32
32
${ cmd } up "$@"
33
33
'' ;
34
34
} )
35
- ( mkCommand system "arion" {
35
+ ( mkCommand system {
36
36
name = "ps" ;
37
37
description = "exec this arion task to ps" ;
38
38
command = ''
39
39
${ cmd } ps "$@"
40
40
'' ;
41
41
} )
42
- ( mkCommand system "arion" {
42
+ ( mkCommand system {
43
43
name = "stop" ;
44
44
description = "arion stop" ;
45
45
command = ''
46
46
${ cmd } stop "$@"
47
47
'' ;
48
48
} )
49
- ( mkCommand system "arion" {
49
+ ( mkCommand system {
50
50
name = "rm" ;
51
51
description = "arion rm" ;
52
52
command = ''
53
53
${ cmd } rm "$@"
54
54
'' ;
55
55
} )
56
- ( mkCommand system "arion" {
56
+ ( mkCommand system {
57
57
name = "config" ;
58
58
description = "check the docker-compose yaml file" ;
59
59
command = ''
60
60
${ cmd } config "$@"
61
61
'' ;
62
62
} )
63
- ( mkCommand system "arion" {
63
+ ( mkCommand system {
64
64
name = "arion" ;
65
65
description = "pass any command to arion" ;
66
66
command = ''
Original file line number Diff line number Diff line change 1
1
{
2
2
nixpkgs ,
3
3
mkCommand ,
4
+ sharedActions ,
4
5
} : let
5
6
l = nixpkgs . lib // builtins ;
6
7
/*
22
23
fragmentRelPath ,
23
24
target ,
24
25
} : [
25
- ( import ./actions/ build.nix target ( mkCommand system "containers" ) )
26
- ( mkCommand system "containers" {
26
+ ( sharedActions . build system target )
27
+ ( mkCommand system {
27
28
name = "print-image" ;
28
29
description = "print out the image name & tag" ;
29
30
command = ''
30
31
echo
31
32
echo "${ target . imageName } :${ target . imageTag } "
32
33
'' ;
33
34
} )
34
- ( mkCommand system "containers" {
35
+ ( mkCommand system {
35
36
name = "publish" ;
36
37
description = "copy the image to its remote registry" ;
37
38
command = let
86
87
}
87
88
'' ;
88
89
} )
89
- ( mkCommand system "containers" {
90
+ ( mkCommand system {
90
91
name = "copy-to-registry" ;
91
92
description = "copy the image to its remote registry" ;
92
93
command = ''
93
94
${ target . copyToRegistry } /bin/copy-to-registry
94
95
'' ;
95
96
} )
96
- ( mkCommand system "containers" {
97
+ ( mkCommand system {
97
98
name = "copy-to-docker" ;
98
99
description = "copy the image to the local docker registry" ;
99
100
command = ''
100
101
${ target . copyToDockerDaemon } /bin/copy-to-docker-daemon
101
102
'' ;
102
103
} )
103
- ( mkCommand system "containers" {
104
+ ( mkCommand system {
104
105
name = "copy-to-podman" ;
105
106
description = "copy the image to the local podman registry" ;
106
107
command = ''
Original file line number Diff line number Diff line change 32
32
jq = [ "${ pkgs . jq } /bin/jq" "-r" "'.'" "${ json } " ] ;
33
33
fx = [ "|" "xargs" "cat" "|" "${ pkgs . fx } /bin/fx" ] ;
34
34
in [
35
- ( mkCommand system "data" {
35
+ ( mkCommand system {
36
36
name = "write" ;
37
37
description = "write to file" ;
38
38
command = "echo ${ json } " ;
39
39
} )
40
- ( mkCommand system "data" {
40
+ ( mkCommand system {
41
41
name = "explore" ;
42
42
description = "interactively explore" ;
43
43
command = l . concatStringsSep "\t " ( jq ++ fx ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
nixpkgs ,
3
3
mkCommand ,
4
+ sharedActions ,
4
5
} : let
5
6
l = nixpkgs . lib // builtins ;
6
7
mkDevelopDrv = import ../devshell-drv.nix ;
23
24
} : let
24
25
developDrv = mkDevelopDrv target ;
25
26
in [
26
- ( import ./actions/ build.nix developDrv ( mkCommand system "devshells" ) )
27
- ( mkCommand system "devshells" {
27
+ ( sharedActions . build system target )
28
+ ( mkCommand system {
28
29
name = "enter" ;
29
30
description = "enter this devshell" ;
30
31
command = ''
Original file line number Diff line number Diff line change 21
21
file = toString target ;
22
22
bat = "${ nixpkgs . legacyPackages . ${ system } . bat } /bin/bat" ;
23
23
in [
24
- ( mkCommand system "files" {
24
+ ( mkCommand system {
25
25
name = "explore" ;
26
26
description = "interactively explore with bat" ;
27
27
command = ''
You can’t perform that action at this time.
0 commit comments